Patchwork [2,of,3] import: enable 'Amends' line to be utilized in patch import

login
register
mail settings
Submitter Matthew Turk
Date Nov. 21, 2013, 10:33 p.m.
Message ID <feb80ffcab5811806c89.1385073209@ridcully>
Download mbox | patch
Permalink /patch/3078/
State Superseded
Headers show

Comments

Matthew Turk - Nov. 21, 2013, 10:33 p.m.
# HG changeset patch
# User Matthew Turk <matthewturk@gmail.com>
# Date 1385070431 18000
#      Thu Nov 21 16:47:11 2013 -0500
# Node ID feb80ffcab5811806c891b2a1e8a1e67f5915590
# Parent  4c14c3925a004ef7036715ec954c9695cdb05783
import: enable 'Amends' line to be utilized in patch import.

This adds a return argument, currently not used, for patch.extract to identify
the amended changeset ID.  Future patches will enable this to be utilized
during the commit procedure to mark as obsolete amended changesets.

Patch

diff -r 4c14c3925a00 -r feb80ffcab58 mercurial/commands.py
--- a/mercurial/commands.py	Thu Nov 21 16:28:56 2013 -0500
+++ b/mercurial/commands.py	Thu Nov 21 16:47:11 2013 -0500
@@ -3678,7 +3678,7 @@ 
     msgs = []
 
     def tryone(ui, hunk, parents):
-        tmpname, message, user, date, branch, nodeid, p1, p2 = \
+        tmpname, message, user, date, branch, nodeid, p1, p2, amends = \
             patch.extract(ui, hunk)
 
         if not tmpname:
diff -r 4c14c3925a00 -r feb80ffcab58 mercurial/patch.py
--- a/mercurial/patch.py	Thu Nov 21 16:28:56 2013 -0500
+++ b/mercurial/patch.py	Thu Nov 21 16:47:11 2013 -0500
@@ -157,7 +157,7 @@ 
 
     patch can be a normal patch or contained in an email message.
 
-    return tuple (filename, message, user, date, branch, node, p1, p2).
+    return tuple (filename, message, user, date, branch, node, p1, p2, amends).
     Any item in the returned tuple can be None. If filename is None,
     fileobj did not contain a patch. Caller must unlink filename when done.'''
 
@@ -183,6 +183,7 @@ 
         date = None
         nodeid = None
         branch = None
+        amends = None
         parents = []
 
         if subject:
@@ -233,6 +234,8 @@ 
                             nodeid = line[10:]
                         elif line.startswith("# Parent "):
                             parents.append(line[9:].lstrip())
+                        elif line.startswith("# Amends "):
+                            amends = line[9:].lstrip()
                         elif not line.startswith("# "):
                             hgpatchheader = False
                     elif line == '---':
@@ -257,10 +260,10 @@ 
     tmpfp.close()
     if not diffs_seen:
         os.unlink(tmpname)
-        return None, message, user, date, branch, None, None, None
+        return None, message, user, date, branch, None, None, None, None
     p1 = parents and parents.pop(0) or None
     p2 = parents and parents.pop(0) or None
-    return tmpname, message, user, date, branch, nodeid, p1, p2
+    return tmpname, message, user, date, branch, nodeid, p1, p2, amends
 
 class patchmeta(object):
     """Patched file metadata