largefiles: unlink standins not known to the restored dirstate at rollback
Before this patch, standinds not known to the restored dirstate at
rollback still exist after rollback of the parent of the working
directory, and they become orphans unexpectedly.
This patch unlinks standins not known to the restored dirstate.
This patch saves names of standins matched against not
"repo.dirstate[f] == 'a'" but "repo.dirstate[f] != 'r'" before
rollback, because branch merging marks files newly added to
dirstate as not "a" but "n".
Such standins will also become orphan after rollback, because they are
not known to the restored dirstate.
--- a/hgext/largefiles/overrides.py Sun Aug 24 23:47:25 2014 +0900
+++ b/hgext/largefiles/overrides.py Sun Aug 24 23:47:26 2014 +0900
@@ -1197,6 +1197,8 @@
wlock = repo.wlock()
try:
before = repo.dirstate.parents()
+ orphans = set(f for f in repo.dirstate
+ if lfutil.isstandin(f) and repo.dirstate[f] != 'r')
result = orig(ui, repo, **opts)
after = repo.dirstate.parents()
if before == after:
@@ -1205,6 +1207,7 @@
pctx = repo['.']
for f in repo.dirstate:
if lfutil.isstandin(f):
+ orphans.discard(f)
if repo.dirstate[f] == 'r':
repo.wvfs.unlinkpath(f, ignoremissing=True)
elif f in pctx:
@@ -1214,6 +1217,8 @@
# content of standin is not so important in 'a',
# 'm' or 'n' (coming from the 2nd parent) cases
lfutil.writestandin(repo, f, '', False)
+ for standin in orphans:
+ repo.wvfs.unlinkpath(standin, ignoremissing=True)
lfdirstate = lfutil.openlfdirstate(ui, repo)
orphans = set(lfdirstate)
--- a/tests/test-largefiles-update.t Sun Aug 24 23:47:25 2014 +0900
+++ b/tests/test-largefiles-update.t Sun Aug 24 23:47:26 2014 +0900
@@ -140,6 +140,8 @@
$ hg status -A largeY
? largeY
+ $ test -f .hglf/largeY
+ [1]
Test that "hg rollback" restores standins correctly