test-addremove-similar: use treestate

Summary:
The test change is because internal details. In this case, set "mtime" to -1
is more "correct" than "0" (the fixed 1970 date).

As we're here, make treestate to normalize size and mtime at "remove" time.
This is similar to D8842389 which only affects internal representation, without
visible changes affecting users.

Reviewed By: DurhamG

Differential Revision: D8869841

fbshipit-source-id: 52fce7a230f87dbb41217f4fd2305ff2febe1fdb
This commit is contained in:
Jun Wu 2018-07-17 16:03:42 -07:00 committed by Facebook Github Bot
parent 39c3ffbbc5
commit 9ed6a30e66
2 changed files with 8 additions and 1 deletions

View File

@ -178,6 +178,12 @@ class treestatemap(object):
# preserve "copied" information
state, mode, size, mtime, copied = existing
mode = 0
mtime = -1
# note: do not reset "size" if it is a special value (ex. -2).
# some old code still depends on that. but do reset it since
# some tests expect size to be 0.
if size > 0:
size = 0
state ^= state & treestate.EXIST_NEXT
else:
state = 0

View File

@ -1,3 +1,4 @@
$ setconfig format.dirstate=2
$ hg init rep; cd rep
$ touch empty-file
@ -155,7 +156,7 @@ Issue1527: repeated addremove causes Abort
adding d/b
recording removal of d/a as rename to d/b (100% similar)
$ hg debugstate
r 0 0 1970-01-01 00:00:00 d/a
r 0 0 unset d/a
a 0 -1 unset d/b
copy: d/a -> d/b
$ mv d/b c