Patchwork [1,of,2] test-rebase: add a test showing rebasestate left behind

login
register
mail settings
Submitter Jun Wu
Date June 25, 2017, 4:14 a.m.
Message ID <244ca1b15233614b2de9.1498364065@x1c>
Download mbox | patch
Permalink /patch/21692/
State Accepted
Headers show

Comments

Jun Wu - June 25, 2017, 4:14 a.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1498363288 25200
#      Sat Jun 24 21:01:28 2017 -0700
# Node ID 244ca1b15233614b2de9aa6e6c0ed12670150777
# Parent  bec821f3bb744a7d13e33436433005654a263bc3
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 244ca1b15233
test-rebase: add a test showing rebasestate left behind

The test demonstrates that .hg/rebasestate is left behind if "rebase" was
called inside an existing transaction.

Patch

diff --git a/tests/test-rebase-scenario-global.t b/tests/test-rebase-scenario-global.t
--- a/tests/test-rebase-scenario-global.t
+++ b/tests/test-rebase-scenario-global.t
@@ -2,4 +2,5 @@ 
   > [extensions]
   > rebase=
+  > drawdag=$TESTDIR/drawdag.py
   > 
   > [phases]
@@ -916,2 +917,41 @@  Testing from upper head
   summary:     second source with subdir
   
+Testing rebase being called inside another transaction
+
+  $ cd $TESTTMP
+  $ hg init tr-state
+  $ cd tr-state
+  $ cat > $TESTTMP/wraprebase.py <<EOF
+  > from __future__ import absolute_import
+  > from mercurial import extensions
+  > def _rebase(orig, ui, repo, *args, **kwargs):
+  >     with repo.wlock():
+  >         with repo.lock():
+  >             with repo.transaction('wrappedrebase'):
+  >                 return orig(ui, repo, *args, **kwargs)
+  > def wraprebase(loaded):
+  >     assert loaded
+  >     rebasemod = extensions.find('rebase')
+  >     extensions.wrapcommand(rebasemod.cmdtable, 'rebase', _rebase)
+  > def extsetup(ui):
+  >     extensions.afterloaded('rebase', wraprebase)
+  > EOF
+
+  $ cat >> .hg/hgrc <<EOF
+  > [extensions]
+  > wraprebase=$TESTTMP/wraprebase.py
+  > [experimental]
+  > evolution=all
+  > EOF
+
+  $ hg debugdrawdag <<'EOS'
+  > B C
+  > |/
+  > A
+  > EOS
+
+  $ hg rebase -s C -d B
+  rebasing 2:dc0947a82db8 "C" (C tip)
+
+  $ [ -f .hg/rebasestate ] && echo 'WRONG: rebasestate should not exist'
+  WRONG: rebasestate should not exist