mercurial/manifest.py
changeset 22965 b697fa74b475
parent 22964 2793ecb1522d
child 22966 ff93aa006e6a
equal deleted inserted replaced
22964:2793ecb1522d 22965:b697fa74b475
     4 #
     4 #
     5 # This software may be used and distributed according to the terms of the
     5 # This software may be used and distributed according to the terms of the
     6 # GNU General Public License version 2 or any later version.
     6 # GNU General Public License version 2 or any later version.
     7 
     7 
     8 from i18n import _
     8 from i18n import _
     9 import mdiff, parsers, error, revlog, util, dicthelpers
     9 import mdiff, parsers, error, revlog, util
    10 import array, struct
    10 import array, struct
    11 
    11 
    12 class manifestdict(dict):
    12 class manifestdict(dict):
    13     def __init__(self, mapping=None, flags=None):
    13     def __init__(self, mapping=None, flags=None):
    14         if mapping is None:
    14         if mapping is None:
    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,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.'''
    46         manifest and fl1/fl2 is the flag in the current/other manifest. Where
    47         flagsdiff = dicthelpers.diff(self._flags, m2._flags, "")
    47         the file does not exist, the nodeid will be None and the flags will be
    48         fdiff = dicthelpers.diff(self, m2)
    48         the empty string.'''
    49         return dicthelpers.join(fdiff, flagsdiff)
    49         diff = {}
       
    50 
       
    51         for fn, n1 in self.iteritems():
       
    52             fl1 = self._flags.get(fn, '')
       
    53             n2 = m2.get(fn, None)
       
    54             fl2 = m2._flags.get(fn, '')
       
    55             if n2 is None:
       
    56                 fl2 = ''
       
    57             if n1 != n2 or fl1 != fl2:
       
    58                 diff[fn] = ((n1, n2), (fl1, fl2))
       
    59 
       
    60         for fn, n2 in m2.iteritems():
       
    61             if fn not in self:
       
    62                 fl2 = m2._flags.get(fn, '')
       
    63                 diff[fn] = ((None, n2), ('', fl2))
       
    64 
       
    65         return diff
    50 
    66 
    51     def text(self):
    67     def text(self):
    52         """Get the full data of this manifest as a bytestring."""
    68         """Get the full data of this manifest as a bytestring."""
    53         fl = sorted(self)
    69         fl = sorted(self)
    54         _checkforbidden(fl)
    70         _checkforbidden(fl)