# HG changeset patch # User Matt Mackall # Date 1270507680 18000 # Node ID 36cec318461233119e4543ed6e542936ddf3c40c # Parent 2200d8464fbb6fbc0f9339b3f542154cf47d5728# Parent 07dbafd3a0e2e2e9eac417891238c57026f4d711 Merge with i18n diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py --- a/mercurial/dirstate.py +++ b/mercurial/dirstate.py @@ -391,16 +391,8 @@ # use the modification time of the newly created temporary file as the # filesystem's notion of 'now' now = int(util.fstat(st).st_mtime) - - cs = cStringIO.StringIO() - copymap = self._copymap - pack = struct.pack - write = cs.write - write("".join(self._pl)) - for f, e in self._map.iteritems(): - if f in copymap: - f = "%s\0%s" % (f, copymap[f]) - + for f in self._map.keys(): + e = self._map[f] if e[0] == 'n' and e[3] == now: # The file was last modified "simultaneously" with the current # write to dirstate (i.e. within the same second for file- @@ -411,8 +403,16 @@ # dirstate, forcing future 'status' calls to compare the # contents of the file. This prevents mistakenly treating such # files as clean. - e = (e[0], 0, -1, -1) # mark entry as 'unset' + self._map[f] = (e[0], 0, -1, -1) # mark entry as 'unset' + cs = cStringIO.StringIO() + copymap = self._copymap + pack = struct.pack + write = cs.write + write("".join(self._pl)) + for f, e in self._map.iteritems(): + if f in copymap: + f = "%s\0%s" % (f, copymap[f]) e = pack(_format, e[0], e[1], e[2], e[3], len(f)) write(e) write(f) diff --git a/tests/test-status-inprocess.py b/tests/test-status-inprocess.py new file mode 100755 --- /dev/null +++ b/tests/test-status-inprocess.py @@ -0,0 +1,32 @@ +#!/usr/bin/python +import os +from mercurial.ui import ui +from mercurial.localrepo import localrepository +from mercurial.commands import add, commit, status + +u = ui() + +print '% creating repo' +repo = localrepository(u, '.', create=True) + +f = open('test.py', 'w') +try: + f.write('foo\n') +finally: + f.close + +print '% add and commit' +add(u, repo, 'test.py') +commit(u, repo, message='*') +status(u, repo, clean=True) + + +print '% change' +f = open('test.py', 'w') +try: + f.write('bar\n') +finally: + f.close() + +# this would return clean instead of changed before the fix +status(u, repo, clean=True, modified=True) diff --git a/tests/test-status-inprocess.py.out b/tests/test-status-inprocess.py.out new file mode 100644 --- /dev/null +++ b/tests/test-status-inprocess.py.out @@ -0,0 +1,5 @@ +% creating repo +% add and commit +C test.py +% change +M test.py