changeset 29819:2cec6eaf3610

cmdutil: extract samefile function from amend()
author Hannes Oldenburg <hannes.christian.oldenburg@gmail.com>
date Sun, 21 Aug 2016 08:00:18 +0000
parents 407879b0893b
children e1a4015f5e34
files mercurial/cmdutil.py
diffstat 1 files changed, 13 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Fri Apr 22 21:32:30 2016 +0900
+++ b/mercurial/cmdutil.py	Sun Aug 21 08:00:18 2016 +0000
@@ -2604,6 +2604,18 @@
 
     return commitfunc(ui, repo, message, matcher, opts)
 
+def samefile(f, ctx1, ctx2):
+    if f in ctx1.manifest():
+        a = ctx1.filectx(f)
+        if f in ctx2.manifest():
+            b = ctx2.filectx(f)
+            return (not a.cmp(b)
+                    and a.flags() == b.flags())
+        else:
+            return False
+    else:
+        return f not in ctx2.manifest()
+
 def amend(ui, repo, commitfunc, old, extra, pats, opts):
     # avoid cycle context -> subrepo -> cmdutil
     from . import context
@@ -2687,19 +2699,7 @@
                 # we can discard X from our list of files. Likewise if X
                 # was deleted, it's no longer relevant
                 files.update(ctx.files())
-
-                def samefile(f):
-                    if f in ctx.manifest():
-                        a = ctx.filectx(f)
-                        if f in base.manifest():
-                            b = base.filectx(f)
-                            return (not a.cmp(b)
-                                    and a.flags() == b.flags())
-                        else:
-                            return False
-                    else:
-                        return f not in base.manifest()
-                files = [f for f in files if not samefile(f)]
+                files = [f for f in files if not samefile(f, ctx, base)]
 
                 def filectxfn(repo, ctx_, path):
                     try: