[PATCH 3 of 5] diff: convert all headers into add*meta functions

Guillermo Pérez bisho at fb.com
Wed Nov 21 11:28:15 CST 2012


# HG changeset patch
# User Guillermo Pérez <bisho at fb.com>
# Date 1353512630 28800
# Node ID aaa7c6adde0e3e42944cb8b5c0b55a6d9a086c95
# Parent  7f925309efeb8f58edba8f6bbf943c1791e0e685
diff: convert all headers into add*meta functions

We convert the remaining appended headers to the equivalent
add<sometype>meta functions.

diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -1659,6 +1659,16 @@
 
     gitmode = {'l': '120000', 'x': '100755', '': '100644'}
 
+    def addrenamemeta(meta, a, b):
+        if opts.git:
+            meta.append('rename from %s\n' % a)
+            meta.append('rename to %s\n' % b)
+
+    def addcopymeta(meta, a, b):
+        if opts.git:
+            meta.append('copy from %s\n' % a)
+            meta.append('copy to %s\n' % b)
+
     def addflagsmeta(meta, fa, fb):
         if opts.git:
             if fa is not None and fb is not None and fa != fb:
@@ -1731,12 +1741,10 @@
                             a = copyto[f]
                         oflag = man1.flags(a)
                         if a in removed and a not in gone:
-                            op = 'rename'
+                            addrenamemeta(header, join(a), join(f))
                             gone.add(a)
                         else:
-                            op = 'copy'
-                        header.append('%s from %s\n' % (op, join(a)))
-                        header.append('%s to %s\n' % (op, join(f)))
+                            addcopymeta(header, join(a), join(f))
                         to = getfilectx(a, ctx1).data()
                     else:
                         losedatafn(f)


More information about the Mercurial-devel mailing list