[PATCH] mq: record more data in patchheader class

Steve Borho steve at borho.org
Fri Dec 31 17:13:34 CST 2010


# HG changeset patch
# User Steve Borho <steve at borho.org>
# Date 1293836978 21600
# Node ID a28115e8e6e8cf8a4e2751898ca3dde8cc351d10
# Parent  d85d8ad88de938f4a6a5a0e3818eab70fc0c2ec0
mq: record more data in patchheader class

* 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.

diff -r d85d8ad88de9 -r a28115e8e6e8 hgext/mq.py
--- a/hgext/mq.py	Wed Dec 29 15:31:25 2010 -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,7 @@
 
         eatdiff(message)
         eatdiff(comments)
+        self.diffstartline = len(comments)
         eatempty(message)
         eatempty(comments)
 
@@ -147,6 +154,8 @@
         self.user = user
         self.date = date
         self.parent = parent
+        self.nodeid = nodeid
+        self.branch = branch
         self.haspatch = diffstart > 1
         self.plainmode = plainmode
 


More information about the Mercurial-devel mailing list