mercurial/manifest.py
changeset 24525 e118f74d246f
parent 24524 63b6031384fc
child 24526 cd50f3717639
equal deleted inserted replaced
24524:63b6031384fc 24525:e118f74d246f
    29         if len(n) > 40:
    29         if len(n) > 40:
    30             yield f, revlog.bin(n[:40]), n[40:]
    30             yield f, revlog.bin(n[:40]), n[40:]
    31         else:
    31         else:
    32             yield f, revlog.bin(n), ''
    32             yield f, revlog.bin(n), ''
    33 
    33 
       
    34 def _text(it):
       
    35     """Given an iterator over (path, node, flags) tuples, returns a manifest
       
    36     text"""
       
    37     files = []
       
    38     lines = []
       
    39     _hex = revlog.hex
       
    40     for f, n, fl in it:
       
    41         files.append(f)
       
    42         # if this is changed to support newlines in filenames,
       
    43         # be sure to check the templates/ dir again (especially *-raw.tmpl)
       
    44         lines.append("%s\0%s%s\n" % (f, _hex(n), fl))
       
    45 
       
    46     _checkforbidden(files)
       
    47     return ''.join(lines)
       
    48 
    34 class _lazymanifest(dict):
    49 class _lazymanifest(dict):
    35     """This is the pure implementation of lazymanifest.
    50     """This is the pure implementation of lazymanifest.
    36 
    51 
    37     It has not been optimized *at all* and is not lazy.
    52     It has not been optimized *at all* and is not lazy.
    38     """
    53     """
    90                 c[f] = n, fl
   105                 c[f] = n, fl
    91         return c
   106         return c
    92 
   107 
    93     def text(self):
   108     def text(self):
    94         """Get the full data of this manifest as a bytestring."""
   109         """Get the full data of this manifest as a bytestring."""
    95         fl = self.iterentries()
   110         return _text(self.iterentries())
    96 
       
    97         _hex = revlog.hex
       
    98         # if this is changed to support newlines in filenames,
       
    99         # be sure to check the templates/ dir again (especially *-raw.tmpl)
       
   100         return ''.join("%s\0%s%s\n" % (
       
   101             f, _hex(n[:20]), flag) for f, n, flag in fl)
       
   102 
   111 
   103 try:
   112 try:
   104     _lazymanifest = parsers.lazymanifest
   113     _lazymanifest = parsers.lazymanifest
   105 except AttributeError:
   114 except AttributeError:
   106     pass
   115     pass
   576         _diff(self, m2)
   585         _diff(self, m2)
   577         return result
   586         return result
   578 
   587 
   579     def text(self):
   588     def text(self):
   580         """Get the full data of this manifest as a bytestring."""
   589         """Get the full data of this manifest as a bytestring."""
   581         fl = self.keys()
   590         flags = self.flags
   582         _checkforbidden(fl)
   591         return _text((f, self[f], flags(f)) for f in self.keys())
   583 
       
   584         hex, flags = revlog.hex, self.flags
       
   585         # if this is changed to support newlines in filenames,
       
   586         # be sure to check the templates/ dir again (especially *-raw.tmpl)
       
   587         return ''.join("%s\0%s%s\n" % (f, hex(self[f]), flags(f)) for f in fl)
       
   588 
   592 
   589 class manifest(revlog.revlog):
   593 class manifest(revlog.revlog):
   590     def __init__(self, opener):
   594     def __init__(self, opener):
   591         # During normal operations, we expect to deal with not more than four
   595         # During normal operations, we expect to deal with not more than four
   592         # revs at a time (such as during commit --amend). When rebasing large
   596         # revs at a time (such as during commit --amend). When rebasing large