Add ability to parse branch information to hg import
authorEric Hopper <hopper@omnifarious.org>
Thu, 17 May 2007 20:09:47 -0700
changeset 4443 eff2eefdb65a
parent 4442 871ff96a86cc
child 4444 32ea809e5bd1
Add ability to parse branch information to hg import
mercurial/commands.py
mercurial/patch.py
--- a/mercurial/commands.py	Thu May 17 20:09:44 2007 -0700
+++ b/mercurial/commands.py	Thu May 17 20:09:47 2007 -0700
@@ -1516,10 +1516,10 @@
 
         if pf == '-':
             ui.status(_("applying patch from stdin\n"))
-            tmpname, message, user, date, nodeid, p1, p2 = patch.extract(ui, sys.stdin)
+            tmpname, message, user, date, branch, nodeid, p1, p2 = patch.extract(ui, sys.stdin)
         else:
             ui.status(_("applying %s\n") % p)
-            tmpname, message, user, date, nodeid, p1, p2 = patch.extract(ui, file(pf))
+            tmpname, message, user, date, branch, nodeid, p1, p2 = patch.extract(ui, file(pf))
 
         if tmpname is None:
             raise util.Abort(_('no diffs found'))
--- a/mercurial/patch.py	Thu May 17 20:09:44 2007 -0700
+++ b/mercurial/patch.py	Thu May 17 20:09:47 2007 -0700
@@ -55,6 +55,7 @@
         # should try to parse msg['Date']
         date = None
         nodeid = None
+        branch = None
         parents = []
 
         if message:
@@ -99,6 +100,8 @@
                             ui.debug('From: %s\n' % user)
                         elif line.startswith("# Date "):
                             date = line[7:]
+                        elif line.startswith("# Branch "):
+                            branch = line[9:]
                         elif line.startswith("# Node ID "):
                             nodeid = line[10:]
                         elif line.startswith("# Parent "):
@@ -123,10 +126,10 @@
     tmpfp.close()
     if not diffs_seen:
         os.unlink(tmpname)
-        return None, message, user, date, None, None, None
+        return None, message, user, date, branch, None, None, None
     p1 = parents and parents.pop(0) or None
     p2 = parents and parents.pop(0) or None
-    return tmpname, message, user, date, nodeid, p1, p2
+    return tmpname, message, user, date, branch, nodeid, p1, p2
 
 GP_PATCH  = 1 << 0  # we have to run patch
 GP_FILTER = 1 << 1  # there's some copy/rename operation