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().
--- 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