mercurial/manifest.py
changeset 22929 bf69cb09a6c9
parent 22788 160efd225b24
child 22930 1acb81d10eaf
equal deleted inserted replaced
22928:5e5d297ccbd0 22929:bf69cb09a6c9
    38                     ret._flags[fn] = flags
    38                     ret._flags[fn] = flags
    39         return ret
    39         return ret
    40     def flagsdiff(self, d2):
    40     def flagsdiff(self, d2):
    41         return dicthelpers.diff(self._flags, d2._flags, "")
    41         return dicthelpers.diff(self._flags, d2._flags, "")
    42 
    42 
       
    43     def text(self):
       
    44         fl = sorted(self)
       
    45         _checkforbidden(fl)
       
    46 
       
    47         hex, flags = revlog.hex, self.flags
       
    48         # if this is changed to support newlines in filenames,
       
    49         # be sure to check the templates/ dir again (especially *-raw.tmpl)
       
    50         return ''.join("%s\0%s%s\n" % (f, hex(self[f]), flags(f)) for f in fl)
    43 
    51 
    44 def _checkforbidden(l):
    52 def _checkforbidden(l):
    45     """Check filenames for illegal characters."""
    53     """Check filenames for illegal characters."""
    46     for f in l:
    54     for f in l:
    47         if '\n' in f or '\r' in f:
    55         if '\n' in f or '\r' in f:
   218         else:
   226         else:
   219             # The first parent manifest isn't already loaded, so we'll
   227             # The first parent manifest isn't already loaded, so we'll
   220             # just encode a fulltext of the manifest and pass that
   228             # just encode a fulltext of the manifest and pass that
   221             # through to the revlog layer, and let it handle the delta
   229             # through to the revlog layer, and let it handle the delta
   222             # process.
   230             # process.
   223             files = sorted(map)
   231             text = map.text()
   224             _checkforbidden(files)
       
   225 
       
   226             # if this is changed to support newlines in filenames,
       
   227             # be sure to check the templates/ dir again (especially *-raw.tmpl)
       
   228             hex, flags = revlog.hex, map.flags
       
   229             text = ''.join("%s\0%s%s\n" % (f, hex(map[f]), flags(f))
       
   230                            for f in files)
       
   231             arraytext = array.array('c', text)
   232             arraytext = array.array('c', text)
   232             cachedelta = None
   233             cachedelta = None
   233 
   234 
   234         n = self.addrevision(text, transaction, link, p1, p2, cachedelta)
   235         n = self.addrevision(text, transaction, link, p1, p2, cachedelta)
   235         self._mancache[n] = (map, arraytext)
   236         self._mancache[n] = (map, arraytext)