Patchwork [3,of,4,V2] dirstate: add test for exceptions during updates

login
register
mail settings
Submitter Durham Goode
Date Sept. 5, 2014, 10:47 p.m.
Message ID <5d236cbefff41e9c80de.1409957235@dev2000.prn2.facebook.com>
Download mbox | patch
Permalink /patch/5707/
State Superseded
Headers show

Comments

Durham Goode - Sept. 5, 2014, 10:47 p.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1409956616 25200
#      Fri Sep 05 15:36:56 2014 -0700
# Node ID 5d236cbefff41e9c80de2965dc6e42a913428738
# Parent  f28f0cf7a676d72449aab0a50d469ebb9997600d
dirstate: add test for exceptions during updates

Adds a test that checks if the working copy parent and the working copy are in a
good state if an exception happens between the time the working copy parent is
set and the time the actual updates are recorded in the dirstate.

Patch

diff --git a/tests/test-dirstate.t b/tests/test-dirstate.t
--- a/tests/test-dirstate.t
+++ b/tests/test-dirstate.t
@@ -61,3 +61,28 @@ 
   $ hg debugstate
   n 644          2 2018-01-19 15:14:08 a
 #endif
+
+Verify that exceptions during a dirstate change leave the dirstate
+coherent (issue4353)
+
+  $ cat > ../dirstateexception.py <<EOF
+  > from mercurial import merge, extensions, util
+  > 
+  > def wraprecordupdates(orig, repo, actions, branchmerge):
+  >     raise util.Abort("simulated error while recording dirstateupdates")
+  > 
+  > def reposetup(ui, repo):
+  >     extensions.wrapfunction(merge, 'recordupdates', wraprecordupdates)
+  > EOF
+
+  $ hg rm a
+  $ hg commit -m 'rm a'
+  $ echo "[extensions]" >> .hg/hgrc
+  $ echo "dirstateex=../dirstateexception.py" >> .hg/hgrc
+  $ hg up 0
+  abort: simulated error while recording dirstateupdates
+  [255]
+  $ hg log -r . -T '{rev}\n'
+  1
+  $ hg status
+  ? a