[PATCH]mq:a patch stores

Ling, Xiaofeng xiaofeng.ling at intel.com
Tue Sep 13 09:19:55 CDT 2005


I just feel I need this feature.
some times, I hope remove some patches and add back again.
so I create a stores file, all the patch that use qdelete will be
tracked in this file.And each patch can be added back at any 
time.
now, qseries will like:
hg qseries -v
00 A mq-list.patch
01 A myhg.patch
02 A qrefresh.patch
03 A qnew.patch
04 A stores.patch
05 A qimport.patch
06 A qdelete.patch
-------stores-------
00 B test.patch
01 B test2.patch
02 B he.patch
03 B hello.patch
04 B a.patch
05 B b.patch
03 B hello.patch

------------------------------------------------------------------------
diff -r 02b1a874a53d contrib/mq
--- a/contrib/mq	Tue Sep 13 06:09:13 2005
+++ b/contrib/mq	Tue Sep 13 17:36:55 2005
@@ -21,10 +21,14 @@
         self.ui = ui
         self.series = []
         self.applied = []
+        self.stores = []
         self.applied_dirty = 0
         self.series_dirty = 0
+        self.stores_dirty = 0
+
         self.series_path = os.path.join(self.path, "series")
         self.status_path = os.path.join(self.path, "status")
+        self.stores_path = os.path.join(self.path, "stores")
         
         s = self.series_path
         if os.path.exists(s):
@@ -32,6 +36,9 @@
         s = self.status_path
         if os.path.exists(s):
             self.applied = self.opener(s).read().splitlines()
+        s = self.stores_path
+        if os.path.exists(s):
+            self.stores = self.opener(s).read().splitlines()
 
     def __del__(self):
         if self.applied_dirty:
@@ -48,6 +55,13 @@
                 nl = ""
             f = self.opener(self.series_path, "w")
             f.write("\n".join(self.series) + nl)
+        if self.stores_dirty:
+            if len(self.stores) > 0:
+                nl = "\n"
+            else:
+                nl = ""
+            f = self.opener(self.stores_path, "w")
+            f.write("\n".join(self.stores) + nl)
 
     def apply(self, repo, series, list=False):
         # TODO unify with commands.py
@@ -169,6 +183,8 @@
             self.ui.warn("patch %s not in series file\n" % patch)
             sys.exit(1)
         i = self.series.index(patch)
+        self.stores.append(self.series[i])
+        self.stores_dirty = 1
         del self.series[i]
         self.series_dirty = 1
     
@@ -556,6 +607,12 @@
             if self.ui.verbose:
                 self.ui.write("%02d U " % self.series.index(p))
             self.ui.write("%s\n" %  p)
+
+        if self.ui.verbose:
+            self.ui.write("-------stores-------\n")
+        for p in self.stores:
+            if self.ui.verbose:
+                self.ui.write("%02d B %s\n" % (self.stores.index(p), p))
 
     def issaveline(self, l):
         name = l.split(':')[1]

-------------------
Ling Xiaofeng(Daniel)
Open Source Technology Center
Intel China Software Center
iNet: 8-752-1243
8621-52574545-1243(O)
xfling at users.sourceforge.net



More information about the Mercurial mailing list