diff mercurial/manifest.py @ 22964:2793ecb1522d

manifest: repurpose flagsdiff() into (node-and-flag)diff() The manifestdict class already has a method for diff flags between two manifests (presumably because there is no full access to the private _flags field). The only caller is merge.manifestmerge(), which also wants a diff of files between the same manifests. Let's combine the code for diffing files and flags into a single method on manifestdict. This puts all the manifest diffing in one place and will allow for further simplification. It might also be useful for it to be encapsulated in manifestdict if we later decide to to shard manifests. The docstring is intentionally unclear about missing entries for now.
author Martin von Zweigbergk <martinvonz@gmail.com>
date Tue, 14 Oct 2014 17:09:16 -0700
parents 117e81871113
children b697fa74b475
line wrap: on
line diff
--- a/mercurial/manifest.py	Thu Oct 16 17:03:21 2014 +0900
+++ b/mercurial/manifest.py	Tue Oct 14 17:09:16 2014 -0700
@@ -38,8 +38,15 @@
                 if flags:
                     ret._flags[fn] = flags
         return ret
-    def flagsdiff(self, d2):
-        return dicthelpers.diff(self._flags, d2._flags, "")
+
+    def diff(self, m2):
+        '''Finds changes between the current manifest and m2. The result is
+        returned as a dict with filename as key and values of the form
+        ((n1,n2),(fl1,fl2)), where n1/n2 is the nodeid in the current/other
+        manifest and fl1/fl2 is the flag in the current/other manifest.'''
+        flagsdiff = dicthelpers.diff(self._flags, m2._flags, "")
+        fdiff = dicthelpers.diff(self, m2)
+        return dicthelpers.join(fdiff, flagsdiff)
 
     def text(self):
         """Get the full data of this manifest as a bytestring."""