largefiles: restore R status of removed largefiles correctly at "hg rollback"
authorFUJIWARA Katsunori <foozy@lares.dti.ne.jp>
Mon, 11 Aug 2014 22:29:43 +0900
changeset 22096 61e526585b20
parent 22095 cb62d77c7a01
child 22097 7d1eac06ab2b
largefiles: restore R status of removed largefiles correctly at "hg rollback" Before this patch, removed or forgotten largefiles aren't treated as removed ("R") after "hg rollback". Removed ones are treated as missing ("!") and forgotten ones are treated as clean ("C") unexpectedly. "overriderollback" uses "normallookup" to restore status in lfdirstate for largefiles other than ones not added in rollback-ed revision, but this isn't correct for removed (or forgotten) largefiles. This patch uses "lfutil.synclfdirstate" to restore "R" status of removed (or forgotten) largefiles correctly 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.
hgext/largefiles/overrides.py
tests/test-largefiles-update.t
--- 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
@@ -1148,12 +1148,8 @@
 
         lfdirstate = lfutil.openlfdirstate(ui, repo)
         lfiles = lfutil.listlfiles(repo)
-        oldlfiles = lfutil.listlfiles(repo, repo[None].parents()[0].rev())
         for file in lfiles:
-            if file in oldlfiles:
-                lfdirstate.normallookup(file)
-            else:
-                lfdirstate.add(file)
+            lfutil.synclfdirstate(repo, lfdirstate, file, True)
         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
@@ -99,4 +99,28 @@
   $ cat .hglf/large1
   58e24f733a964da346e2407a2bee99d9001184f5
 
+Test that "hg rollback" restores status of largefiles correctly
+
+  $ hg update -C -q
+  $ hg remove large1
+  $ hg forget large2
+  $ echo largeX > largeX
+  $ hg add --large largeX
+  $ hg commit -m 'will be rollback-ed soon'
+  $ hg status -A large1
+  large1: No such file or directory
+  $ hg status -A large2
+  ? large2
+  $ hg status -A largeX
+  C largeX
+  $ hg rollback
+  repository tip rolled back to revision 3 (undo commit)
+  working directory now based on revision 3
+  $ hg status -A large1
+  R large1
+  $ hg status -A large2
+  R large2
+  $ hg status -A largeX
+  A largeX
+
   $ cd ..