comparison mercurial/manifest.py @ 22966:ff93aa006e6a

manifest: transpose pair of pairs from diff() It makes more sense for the file nodeids and returned from diff() to be ((n1,fl1),(n2,fl2)) than ((n1,n2),(fl1,fl2)), so change it to the former.
author Martin von Zweigbergk <martinvonz@gmail.com>
date Tue, 14 Oct 2014 23:18:07 -0700
parents b697fa74b475
children 0cc283f44655 6f53629ad273
comparison
equal deleted inserted replaced
22965:b697fa74b475 22966:ff93aa006e6a
40 return ret 40 return ret
41 41
42 def diff(self, m2): 42 def diff(self, m2):
43 '''Finds changes between the current manifest and m2. The result is 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 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 45 ((n1,fl1),(n2,fl2)), where n1/n2 is the nodeid in the current/other
46 manifest and fl1/fl2 is the flag in the current/other manifest. Where 46 manifest and fl1/fl2 is the flag in the current/other manifest. Where
47 the file does not exist, the nodeid will be None and the flags will be 47 the file does not exist, the nodeid will be None and the flags will be
48 the empty string.''' 48 the empty string.'''
49 diff = {} 49 diff = {}
50 50
53 n2 = m2.get(fn, None) 53 n2 = m2.get(fn, None)
54 fl2 = m2._flags.get(fn, '') 54 fl2 = m2._flags.get(fn, '')
55 if n2 is None: 55 if n2 is None:
56 fl2 = '' 56 fl2 = ''
57 if n1 != n2 or fl1 != fl2: 57 if n1 != n2 or fl1 != fl2:
58 diff[fn] = ((n1, n2), (fl1, fl2)) 58 diff[fn] = ((n1, fl1), (n2, fl2))
59 59
60 for fn, n2 in m2.iteritems(): 60 for fn, n2 in m2.iteritems():
61 if fn not in self: 61 if fn not in self:
62 fl2 = m2._flags.get(fn, '') 62 fl2 = m2._flags.get(fn, '')
63 diff[fn] = ((None, n2), ('', fl2)) 63 diff[fn] = ((None, ''), (n2, fl2))
64 64
65 return diff 65 return diff
66 66
67 def text(self): 67 def text(self):
68 """Get the full data of this manifest as a bytestring.""" 68 """Get the full data of this manifest as a bytestring."""