mq: alter location of "status" file [patch]

Hermann Lauer Hermann.Lauer at iwr.uni-heidelberg.de
Wed Jan 20 03:56:04 CST 2010


On Thu, Jan 07, 2010 at 04:15:27PM +0100, Dirkjan Ochtman wrote:
> On Thu, Jan 7, 2010 at 16:11, Hermann Lauer
> <Hermann.Lauer at iwr.uni-heidelberg.de> wrote:
> > Would simply setting self.status_path = "../mqstatus" in mq.py
> > have some undesired side effects ?
> 
> I guess that could work.

Did not work because of the auditing stuff in mercurial, which forbids
the usage of "..".

Appended ist a first (ugly) patch that works for me - could/should be 
improved, if others are also interested in sharing .hg/patches physically.

Now sharing of the patches directory and keeping it outside
of build trees is easy, which fits well into the workflow
here for patching and rebuilding of kernels and debian packages. 

To the mq .hg/patches discussion: The .hg/patches directory should be keept, 
because patches fits so well in the Linux world of software development.

Just my 2 cents,
 Hermann  

-- 
Netzwerkadministration/Zentrale Dienste, Interdiziplinaeres 
Zentrum fuer wissenschaftliches Rechnen der Universitaet Heidelberg
IWR; INF 368; 69120 Heidelberg; Tel: (06221)54-8236 Fax: -5224
Email: Hermann.Lauer at iwr.uni-heidelberg.de
-------------- next part --------------
mqstatus patch, 1. Version

diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -216,20 +216,22 @@
     def __init__(self, ui, path, patchdir=None):
         self.basepath = path
         self.path = patchdir or os.path.join(path, "patches")
+        self.statpath = patchdir or path
         self.opener = util.opener(self.path)
+        self.statopener = util.opener(self.statpath)
         self.ui = ui
         self.applied_dirty = 0
         self.series_dirty = 0
         self.series_path = "series"
-        self.status_path = "status"
+        self.status_path = "mqstatus"
         self.guards_path = "guards"
         self.active_guards = None
         self.guards_dirty = False
 
     @util.propertycache
     def applied(self):
-        if os.path.exists(self.join(self.status_path)):
-            lines = self.opener(self.status_path).read().splitlines()
+        if os.path.exists(os.path.join(self.statpath,self.status_path)):
+            lines = self.statopener(self.status_path).read().splitlines()
             return [statusentry(l) for l in lines]
         return []
 
@@ -420,7 +422,12 @@
             for i in items:
                 fp.write("%s\n" % i)
             fp.close()
-        if self.applied_dirty: write_list(map(str, self.applied), self.status_path)
+        def write_statlist(items, path):
+            fp = self.statopener(path, 'w')
+            for i in items:
+                fp.write("%s\n" % i)
+            fp.close()
+        if self.applied_dirty: write_statlist(map(str, self.applied), self.status_path)
         if self.series_dirty: write_list(self.full_series, self.series_path)
         if self.guards_dirty: write_list(self.active_guards, self.guards_path)
 


More information about the Mercurial mailing list