largefiles: test coverage of fatal interruption of update stable
authorMads Kiilerich <madski@unity3d.com>
Sun, 16 Oct 2016 02:26:38 +0200
branchstable
changeset 30189 4999c12c526b
parent 30031 8d74027bd4e7
child 30190 56b930238036
largefiles: test coverage of fatal interruption of update Test using existing changesets in a clean working directory, revealing problems with files that don't show up as modified or do show up as removed when they just not have been written yet.
tests/test-largefiles-update.t
--- a/tests/test-largefiles-update.t	Sat Oct 01 15:00:23 2016 -0400
+++ b/tests/test-largefiles-update.t	Sun Oct 16 02:26:38 2016 +0200
@@ -144,6 +144,7 @@
   large1 in #1
   $ cat .hglf/large1
   58e24f733a964da346e2407a2bee99d9001184f5
+  $ rm normal1.orig
 
 (merge non-existing largefiles from "other" via conflict prompt -
 make sure the following commit doesn't abort in a confusing way when trying to
@@ -243,6 +244,7 @@
   ? largeY
   $ test -f .hglf/largeY
   [1]
+  $ rm largeY
 
 Test that "hg rollback" restores standins correctly
 
@@ -285,6 +287,7 @@
   58e24f733a964da346e2407a2bee99d9001184f5
   $ cat .hglf/large2
   1deebade43c8c498a3c8daddac0244dc55d1331d
+  $ rm normalX
 
 Test that "hg status" shows status of largefiles correctly just after
 automated commit like rebase/transplant
@@ -598,6 +601,7 @@
   58e24f733a964da346e2407a2bee99d9001184f5
   $ cat large1
   large1 in #1
+  $ rm normal1.orig
 
 Test that rebase updates standins for manually modified largefiles at
 the 1st commit of resuming.
@@ -728,6 +732,48 @@
 
 #endif
 
+Test a fatal error interrupting an update. lfdirstate doesn't realize that
+.hglf has been updated while the largefile hasn't. Status thus shows a clean
+state ... but rebuilding lfdirstate and checking all hashes reveals it isn't
+clean.
+
+Start with clean dirstates:
+  $ hg up -qcr "8^"
+  $ sleep 1
+  $ hg st
+Update standins without updating largefiles:
+  $ cat << EOF > ../crashupdatelfiles.py
+  > import hgext.largefiles.lfutil
+  > def getlfilestoupdate(oldstandins, newstandins):
+  >      raise SystemExit(7)
+  > hgext.largefiles.lfutil.getlfilestoupdate = getlfilestoupdate
+  > EOF
+  $ hg up -Cr "8" --config extensions.crashupdatelfiles=../crashupdatelfiles.py
+  [7]
+Check large1 content and status:
+BUG: largeX is R and large1 is not M and update does nothing
+  $ cat large1
+  large1 in #3
+  $ hg st
+  R largeX
+  $ hg up -Cr .
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ hg st
+  R largeX
+Force largefiles rehashing and check again - revealing modifications that
+update now can remove:
+  $ rm .hg/largefiles/dirstate
+  $ hg st
+  M large1
+  ! largeX
+  $ hg up -Cr .
+  getting changed largefiles
+  2 largefiles updated, 0 removed
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ hg st
+  $ cat large1
+  manually modified before 'hg transplant --continue'
+
   $ cd ..
 
 Test that "hg convert" avoids copying largefiles from the working