Patchwork [3,of,4] convert: use manifest.diff() instead of ctx.status()

login
register
mail settings
Submitter Martin von Zweigbergk
Date Jan. 11, 2016, 5:47 a.m.
Message ID <4ea59d0f00be7bc44f19.1452491239@waste.org>
Download mbox | patch
Permalink /patch/12654/
State Accepted
Headers show

Comments

Martin von Zweigbergk - Jan. 11, 2016, 5:47 a.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1452409090 28800
#      Sat Jan 09 22:58:10 2016 -0800
# Node ID 4ea59d0f00be7bc44f1968c073a44274d67fa4f3
# Parent  3d04b1f49c7b4b2b26288b7a6c6b1e91d70d7429
convert: use manifest.diff() instead of ctx.status()

mercurial_source.getchanges() seems to care about files whose nodeid
has changed even if their contents has not (i.e. it has been
reverted/backed out). The method uses ctx1.status(ctx2) to find
differencing files. However, that method is currently broken and
reports reverted changes as modified. In order to fix that method, we
first need to rewrite getchanges() using manifest.diff(), which does
report reverted files as modified (because it's about differences in
the manifest, so about nodeids).

Patch

diff --git a/hgext/convert/hg.py b/hgext/convert/hg.py
--- a/hgext/convert/hg.py
+++ b/hgext/convert/hg.py
@@ -508,8 +508,16 @@ 
             return None, None
 
     def _changedfiles(self, ctx1, ctx2):
-        m, a, r = ctx1.status(ctx2)[:3]
-        return (m + a, r)
+        ma, r = [], []
+        maappend = ma.append
+        rappend = r.append
+        d = ctx1.manifest().diff(ctx2.manifest())
+        for f, ((node1, flag1), (node2, flag2)) in d.iteritems():
+            if node2 is None:
+                rappend(f)
+            else:
+                maappend(f)
+        return ma, r
 
     def getchanges(self, rev, full):
         ctx = self._changectx(rev)
@@ -529,8 +537,10 @@ 
         copies = self._getcopies(ctx, parents, copyfiles)
         cleanp2 = set()
         if len(parents) == 2:
-            cleanp2.update(self.repo.status(parents[1].node(), ctx.node(),
-                                            clean=True).clean)
+            d = parents[1].manifest().diff(ctx.manifest(), clean=True)
+            for f, value in d.iteritems():
+                if value is None:
+                    cleanp2.add(f)
         changes = [(f, rev) for f in files if f not in self.ignored]
         changes.sort()
         return changes, copies, cleanp2