mq: record more data in patchheader class (no behavior changes)
authorSteve Borho <steve@borho.org>
Fri, 31 Dec 2010 17:09:38 -0600
changeset 13229 f3058dd05281
parent 13228 d18a748d9c33
child 13234 0935ff767285
child 13251 a0fd2fdb1813
mq: record more data in patchheader class (no behavior changes) * parse branch and nodeid header lines * remember the line number where diffs started Combined, these make mq.patchheader() very useful for parsing and preserving a patch header through edits. TortoiseHg will use the nodeid and parent to display these header datums in the graph when patches are unapplied, and uses diffstartline to parse patch files using record.parsepatch().
hgext/mq.py
--- a/hgext/mq.py	Sat Jan 01 18:42:04 2011 -0600
+++ b/hgext/mq.py	Fri Dec 31 17:09:38 2010 -0600
@@ -86,6 +86,8 @@
         parent = None
         format = None
         subject = None
+        branch = None
+        nodeid = None
         diffstart = 0
 
         for line in file(pf):
@@ -106,6 +108,10 @@
                     date = line[7:]
                 elif line.startswith("# Parent "):
                     parent = line[9:]
+                elif line.startswith("# Branch "):
+                    branch = line[9:]
+                elif line.startswith("# Node ID "):
+                    nodeid = line[10:]
                 elif not line.startswith("# ") and line:
                     message.append(line)
                     format = None
@@ -134,6 +140,9 @@
 
         eatdiff(message)
         eatdiff(comments)
+        # Remember the exact starting line of the patch diffs before consuming
+        # empty lines, for external use by TortoiseHg and others
+        self.diffstartline = len(comments)
         eatempty(message)
         eatempty(comments)
 
@@ -147,6 +156,9 @@
         self.user = user
         self.date = date
         self.parent = parent
+        # nodeid and branch are for external use by TortoiseHg and others
+        self.nodeid = nodeid
+        self.branch = branch
         self.haspatch = diffstart > 1
         self.plainmode = plainmode