convert: use manifest.diff() instead of ctx.status()
authorMartin von Zweigbergk <martinvonz@google.com>
Sat, 09 Jan 2016 22:58:10 -0800
changeset 27719 7ce8a13b8d77
parent 27718 6e1fba0fe453
child 27720 89f49813526c
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).
hgext/convert/hg.py
--- a/hgext/convert/hg.py	Sun Jan 10 21:07:34 2016 -0800
+++ b/hgext/convert/hg.py	Sat Jan 09 22:58:10 2016 -0800
@@ -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