changeset 497:cad864ed29de

util: make aresamefiles take one file and just be issamefile instead.
author Augie Fackler <durin42@gmail.com>
date Fri, 16 Oct 2009 19:09:53 -0400
parents 5e0dfe59d4c3
children 990e07054f29
files hgsubversion/editor.py hgsubversion/stupid.py hgsubversion/util.py
diffstat 3 files changed, 7 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/hgsubversion/editor.py
+++ b/hgsubversion/editor.py
@@ -218,7 +218,7 @@ class HgEditor(delta.Editor):
                                                      branch)
             if parentid != revlog.nullid:
                 parentctx = self.repo.changectx(parentid)
-                if util.aresamefiles(parentctx, ctx, [from_file]):
+                if util.issamefile(parentctx, ctx, from_file):
                     self.current.copies[path] = from_file
 
     @ieditor
@@ -279,7 +279,7 @@ class HgEditor(delta.Editor):
             if parentid != revlog.nullid:
                 parentctx = self.repo.changectx(parentid)
                 for k, v in copies.iteritems():
-                    if util.aresamefiles(parentctx, cp_f_ctx, [v]):
+                    if util.issamefile(parentctx, cp_f_ctx, v):
                         self.current.copies.update({k: v})
         return path
 
--- a/hgsubversion/stupid.py
+++ b/hgsubversion/stupid.py
@@ -323,7 +323,7 @@ def getcopies(svn, meta, branch, branchp
         if sourcectx is None:
             continue
         for k, v in copies:
-            if not util.aresamefiles(sourcectx, parentctx, [v]):
+            if not util.issamefile(sourcectx, parentctx, v):
                 continue
             hgcopies.update({k: v})
     return hgcopies
--- a/hgsubversion/util.py
+++ b/hgsubversion/util.py
@@ -121,10 +121,8 @@ def swap_out_encoding(new_encoding="UTF-
     return old
 
 
-def aresamefiles(parentctx, childctx, files):
-    """Assuming all files exist in childctx and parentctx, return True
-    if none of them was changed in-between.
-    """
+def issamefile(parentctx, childctx, f):
+    """Assuming f exists and is the same in childctx and parentctx, return True."""
     if parentctx == childctx:
         return True
     if parentctx.rev() > childctx.rev():
@@ -135,12 +133,10 @@ def aresamefiles(parentctx, childctx, fi
         for ctx in selfctx.ancestors():
             yield ctx
 
-    files = dict.fromkeys(files)
     for pctx in selfandancestors(childctx):
         if pctx.rev() <= parentctx.rev():
             return True
-        for f in pctx.files():
-            if f in files:
-                return False
+        if f in pctx.files():
+            return False
     # parentctx is not an ancestor of childctx, files are unrelated
     return False