Patchwork [4,of,8] largefiles: unlink standins not known to the restored dirstate at rollback

login
register
mail settings
Submitter Katsunori FUJIWARA
Date Aug. 24, 2014, 2:54 p.m.
Message ID <2f9387fc898416e7bb4c.1408892090@feefifofum>
Download mbox | patch
Permalink /patch/5570/
State Accepted
Headers show

Comments

Katsunori FUJIWARA - Aug. 24, 2014, 2:54 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1408891646 -32400
#      Sun Aug 24 23:47:26 2014 +0900
# Node ID 2f9387fc898416e7bb4ca2081233c0c85ee8f0cb
# Parent  8058bff50a4fe9a763317d9bb5c96bba11593783
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 orphan unexpectedly.

This patch unlinks standins not known to the restored dirstate.

This patch saves name of standinds 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.

Patch

diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -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)
diff --git a/tests/test-largefiles-update.t b/tests/test-largefiles-update.t
--- a/tests/test-largefiles-update.t
+++ b/tests/test-largefiles-update.t
@@ -140,6 +140,8 @@ 
   
   $ hg status -A largeY
   ? largeY
+  $ test -f .hglf/largeY
+  [1]
 
 Test that "hg rollback" restores standins correctly