changeset 22097:7d1eac06ab2b

largefiles: drop orphan entries from lfdristat at "hg rollback" Before this patch, newly added (but not yet committed) largefiles aren't treated as unknown ("?") after "hg rollback". After "hg rollback", lfdirstate still contains "A" status entries for such largefiles, even though corresponding entries for standins are already dropped from dirstate. Such "orphan" entries in lfdirstate prevent unknown (large)files in the working directory from being listed up in "unknown" list. The code path in "if working" route of "lfilesrepo.status" below drops largefiles tracked in lfdirstate from "unknown" list: lfiles = set(lfdirstate._map) # Unknown files result[4] = set(result[4]).difference(lfiles) This patch drops orphan entries from lfdristate at "hg rollback". This is a temporary way to fix with less changes. For fundamental resolution of this kind of problems in the future, lfdirstate should be rollback-ed as a part of transaction, as same as dirstate.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Mon, 11 Aug 2014 22:29:43 +0900
parents 61e526585b20
children 2fb3c1c0b4ef
files hgext/largefiles/overrides.py tests/test-largefiles-update.t
diffstat 2 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/largefiles/overrides.py	Mon Aug 11 22:29:43 2014 +0900
+++ b/hgext/largefiles/overrides.py	Mon Aug 11 22:29:43 2014 +0900
@@ -1147,9 +1147,13 @@
                      partial=lfutil.isstandin)
 
         lfdirstate = lfutil.openlfdirstate(ui, repo)
+        orphans = set(lfdirstate)
         lfiles = lfutil.listlfiles(repo)
         for file in lfiles:
             lfutil.synclfdirstate(repo, lfdirstate, file, True)
+            orphans.discard(file)
+        for lfile in orphans:
+            lfdirstate.drop(lfile)
         lfdirstate.write()
     finally:
         wlock.release()
--- a/tests/test-largefiles-update.t	Mon Aug 11 22:29:43 2014 +0900
+++ b/tests/test-largefiles-update.t	Mon Aug 11 22:29:43 2014 +0900
@@ -107,12 +107,16 @@
   $ echo largeX > largeX
   $ hg add --large largeX
   $ hg commit -m 'will be rollback-ed soon'
+  $ echo largeY > largeY
+  $ hg add --large largeY
   $ hg status -A large1
   large1: No such file or directory
   $ hg status -A large2
   ? large2
   $ hg status -A largeX
   C largeX
+  $ hg status -A largeY
+  A largeY
   $ hg rollback
   repository tip rolled back to revision 3 (undo commit)
   working directory now based on revision 3
@@ -122,5 +126,7 @@
   R large2
   $ hg status -A largeX
   A largeX
+  $ hg status -A largeY
+  ? largeY
 
   $ cd ..