comparison 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
comparison
equal deleted inserted replaced
22963:56e04741bbf1 22964:2793ecb1522d
36 ret[fn] = self[fn] 36 ret[fn] = self[fn]
37 flags = self._flags.get(fn, None) 37 flags = self._flags.get(fn, None)
38 if flags: 38 if flags:
39 ret._flags[fn] = flags 39 ret._flags[fn] = flags
40 return ret 40 return ret
41 def flagsdiff(self, d2): 41
42 return dicthelpers.diff(self._flags, d2._flags, "") 42 def diff(self, m2):
43 '''Finds changes between the current manifest and m2. The result is
44 returned as a dict with filename as key and values of the form
45 ((n1,n2),(fl1,fl2)), where n1/n2 is the nodeid in the current/other
46 manifest and fl1/fl2 is the flag in the current/other manifest.'''
47 flagsdiff = dicthelpers.diff(self._flags, m2._flags, "")
48 fdiff = dicthelpers.diff(self, m2)
49 return dicthelpers.join(fdiff, flagsdiff)
43 50
44 def text(self): 51 def text(self):
45 """Get the full data of this manifest as a bytestring.""" 52 """Get the full data of this manifest as a bytestring."""
46 fl = sorted(self) 53 fl = sorted(self)
47 _checkforbidden(fl) 54 _checkforbidden(fl)