How do I import a quilt patch series into hg/mq?

Paul Jackson pj at sgi.com
Fri Nov 25 03:54:59 UTC 2005


Samuel wrote:
> Yes, for the original version of mq that is true. However i am working
> on version controlling the patch queue which will require a hg qinit

Ok - I hope I can still import one of Andrew Morton's *-mm broken-out
patch sets (quilt based), by some simple process.


> Well I think this is because you have a blank line in your series
> which will break it.

That was it - the following patch works with blank lines and stuff
in the series file.  You're welcome to make whatever use of you
like.  It probably doesn't fit your coding style - sorry.  I just
copied some code I had working from my sendpatchset utility:
http://www.speakeasy.org/~pj99/sgi/sendpatchset

--- mq.orig/hgext/mq.py	2005-11-23 22:09:37.469209000 -0800
+++ mq/hgext/mq.py	2005-11-24 18:48:26.169769108 -0800
@@ -10,6 +10,28 @@ from mercurial.demandload import *
 demandload(globals(), "os sys re struct traceback errno")
 from mercurial import ui, hg, revlog, commands, util
 
+# trim trailing lineseparator, if present
+def chomp(str, sep=os.linesep):
+    n = len(sep)
+    if str[-n:] == sep:
+        str = str[:-n]
+    return str
+
+def strip_comments_blanks(s):
+    r = []
+    for line in s:
+        line = chomp(line);
+
+        # remove optional comment and strip line
+        i = line.find('#')
+        if i >= 0:
+            line = line[:i]
+        line = line.strip()
+        if not line:
+            continue
+        r.append(line)
+    return r
+
 versionstr = "0.35"
 
 repomap = {}
@@ -33,6 +55,7 @@ class queue:
         s = self.series_path
         if os.path.exists(s):
             self.series = self.opener(s).read().splitlines()
+            self.series = strip_comments_blanks(self.series)
         s = self.status_path
         if os.path.exists(s):
             self.applied = self.opener(s).read().splitlines()

-- 
                  I won't rest till it's the best ...
                  Programmer, Linux Scalability
                  Paul Jackson <pj at sgi.com> 1.925.600.0401



More information about the Mercurial mailing list