mercurial/pure/parsers.py
changeset 18567 194e63c1ccb9
parent 17425 e95ec38f86b0
child 19652 187bf2dde7c1
equal deleted inserted replaced
18566:341868ef0cf6 18567:194e63c1ccb9
     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 mercurial.node import bin, nullid
     8 from mercurial.node import bin, nullid
     9 from mercurial import util
     9 from mercurial import util
    10 import struct, zlib
    10 import struct, zlib, cStringIO
    11 
    11 
    12 _pack = struct.pack
    12 _pack = struct.pack
    13 _unpack = struct.unpack
    13 _unpack = struct.unpack
    14 _compress = zlib.compress
    14 _compress = zlib.compress
    15 _decompress = zlib.decompress
    15 _decompress = zlib.decompress
    85         if '\0' in f:
    85         if '\0' in f:
    86             f, c = f.split('\0')
    86             f, c = f.split('\0')
    87             copymap[f] = c
    87             copymap[f] = c
    88         dmap[f] = e[:4]
    88         dmap[f] = e[:4]
    89     return parents
    89     return parents
       
    90 
       
    91 def pack_dirstate(dmap, copymap, pl, now):
       
    92     now = int(now)
       
    93     cs = cStringIO.StringIO()
       
    94     write = cs.write
       
    95     write("".join(pl))
       
    96     for f, e in dmap.iteritems():
       
    97         if e[0] == 'n' and e[3] == now:
       
    98             # The file was last modified "simultaneously" with the current
       
    99             # write to dirstate (i.e. within the same second for file-
       
   100             # systems with a granularity of 1 sec). This commonly happens
       
   101             # for at least a couple of files on 'update'.
       
   102             # The user could change the file without changing its size
       
   103             # within the same second. Invalidate the file's stat data in
       
   104             # dirstate, forcing future 'status' calls to compare the
       
   105             # contents of the file. This prevents mistakenly treating such
       
   106             # files as clean.
       
   107             e = (e[0], 0, -1, -1)   # mark entry as 'unset'
       
   108             dmap[f] = e
       
   109 
       
   110         if f in copymap:
       
   111             f = "%s\0%s" % (f, copymap[f])
       
   112         e = _pack(">cllll", e[0], e[1], e[2], e[3], len(f))
       
   113         write(e)
       
   114         write(f)
       
   115     return cs.getvalue()