Mercurial > hg
annotate tests/test-convert-bzr-treeroot.t @ 33087:fcd1c483f5ea
strip: add a delayedstrip method that works in a transaction
For long, the fact that strip does not work inside a transaction and some
code has to work with both obsstore and fallback to strip lead to duplicated
code like:
with repo.transaction():
....
if obsstore:
obsstore.createmarkers(...)
if not obsstore:
repair.strip(...)
Things get more complex when you want to call something which may call strip
under the hood. Like you cannot simply write:
with repo.transaction():
....
rebasemod.rebase(...) # may call "strip", so this doesn't work
But you do want rebase to run inside a same transaction if possible, so the
code may look like:
with repo.transaction():
....
if obsstore:
rebasemod.rebase(...)
obsstore.createmarkers(...)
if not obsstore:
rebasemod.rebase(...)
repair.strip(...)
That's ugly and error-prone. Ideally it's possible to just write:
with repo.transaction():
rebasemod.rebase(...)
saferemovenodes(...)
This patch is the first step towards that. It adds a "delayedstrip" method
to repair.py which maintains a postclose callback in the transaction object.
author | Jun Wu <quark@fb.com> |
---|---|
date | Sun, 25 Jun 2017 10:38:45 -0700 |
parents | 75be14993fda |
children | 5abc47d4ca6b |
rev | line source |
---|---|
26066
89872688893f
tests: move '#require bzr' into .t files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
16913
diff
changeset
|
1 #require bzr |
7053 | 2 |
12517
cc8f1083e8be
tests: unify test-convert-bzr-treeroot
Matt Mackall <mpm@selenic.com>
parents:
7058
diff
changeset
|
3 $ . "$TESTDIR/bzr-definitions" |
cc8f1083e8be
tests: unify test-convert-bzr-treeroot
Matt Mackall <mpm@selenic.com>
parents:
7058
diff
changeset
|
4 $ cat > treeset.py <<EOF |
cc8f1083e8be
tests: unify test-convert-bzr-treeroot
Matt Mackall <mpm@selenic.com>
parents:
7058
diff
changeset
|
5 > import sys |
cc8f1083e8be
tests: unify test-convert-bzr-treeroot
Matt Mackall <mpm@selenic.com>
parents:
7058
diff
changeset
|
6 > from bzrlib import workingtree |
cc8f1083e8be
tests: unify test-convert-bzr-treeroot
Matt Mackall <mpm@selenic.com>
parents:
7058
diff
changeset
|
7 > wt = workingtree.WorkingTree.open('.') |
cc8f1083e8be
tests: unify test-convert-bzr-treeroot
Matt Mackall <mpm@selenic.com>
parents:
7058
diff
changeset
|
8 > |
cc8f1083e8be
tests: unify test-convert-bzr-treeroot
Matt Mackall <mpm@selenic.com>
parents:
7058
diff
changeset
|
9 > message, rootid = sys.argv[1:] |
cc8f1083e8be
tests: unify test-convert-bzr-treeroot
Matt Mackall <mpm@selenic.com>
parents:
7058
diff
changeset
|
10 > wt.set_root_id('tree_root-%s' % rootid) |
cc8f1083e8be
tests: unify test-convert-bzr-treeroot
Matt Mackall <mpm@selenic.com>
parents:
7058
diff
changeset
|
11 > wt.commit(message) |
cc8f1083e8be
tests: unify test-convert-bzr-treeroot
Matt Mackall <mpm@selenic.com>
parents:
7058
diff
changeset
|
12 > EOF |
cc8f1083e8be
tests: unify test-convert-bzr-treeroot
Matt Mackall <mpm@selenic.com>
parents:
7058
diff
changeset
|
13 |
cc8f1083e8be
tests: unify test-convert-bzr-treeroot
Matt Mackall <mpm@selenic.com>
parents:
7058
diff
changeset
|
14 change the id of the tree root |
7053 | 15 |
12517
cc8f1083e8be
tests: unify test-convert-bzr-treeroot
Matt Mackall <mpm@selenic.com>
parents:
7058
diff
changeset
|
16 $ mkdir test-change-treeroot-id |
cc8f1083e8be
tests: unify test-convert-bzr-treeroot
Matt Mackall <mpm@selenic.com>
parents:
7058
diff
changeset
|
17 $ cd test-change-treeroot-id |
cc8f1083e8be
tests: unify test-convert-bzr-treeroot
Matt Mackall <mpm@selenic.com>
parents:
7058
diff
changeset
|
18 $ bzr init -q source |
cc8f1083e8be
tests: unify test-convert-bzr-treeroot
Matt Mackall <mpm@selenic.com>
parents:
7058
diff
changeset
|
19 $ cd source |
cc8f1083e8be
tests: unify test-convert-bzr-treeroot
Matt Mackall <mpm@selenic.com>
parents:
7058
diff
changeset
|
20 $ echo content > file |
cc8f1083e8be
tests: unify test-convert-bzr-treeroot
Matt Mackall <mpm@selenic.com>
parents:
7058
diff
changeset
|
21 $ bzr add -q file |
cc8f1083e8be
tests: unify test-convert-bzr-treeroot
Matt Mackall <mpm@selenic.com>
parents:
7058
diff
changeset
|
22 $ bzr commit -q -m 'Initial add' |
32940
75be14993fda
cleanup: use $PYTHON to run python in many more tests
Augie Fackler <augie@google.com>
parents:
26066
diff
changeset
|
23 $ $PYTHON ../../treeset.py 'Changed root' new |
12517
cc8f1083e8be
tests: unify test-convert-bzr-treeroot
Matt Mackall <mpm@selenic.com>
parents:
7058
diff
changeset
|
24 $ cd .. |
cc8f1083e8be
tests: unify test-convert-bzr-treeroot
Matt Mackall <mpm@selenic.com>
parents:
7058
diff
changeset
|
25 $ hg convert source source-hg |
cc8f1083e8be
tests: unify test-convert-bzr-treeroot
Matt Mackall <mpm@selenic.com>
parents:
7058
diff
changeset
|
26 initializing destination source-hg repository |
cc8f1083e8be
tests: unify test-convert-bzr-treeroot
Matt Mackall <mpm@selenic.com>
parents:
7058
diff
changeset
|
27 scanning source... |
cc8f1083e8be
tests: unify test-convert-bzr-treeroot
Matt Mackall <mpm@selenic.com>
parents:
7058
diff
changeset
|
28 sorting... |
cc8f1083e8be
tests: unify test-convert-bzr-treeroot
Matt Mackall <mpm@selenic.com>
parents:
7058
diff
changeset
|
29 converting... |
cc8f1083e8be
tests: unify test-convert-bzr-treeroot
Matt Mackall <mpm@selenic.com>
parents:
7058
diff
changeset
|
30 1 Initial add |
cc8f1083e8be
tests: unify test-convert-bzr-treeroot
Matt Mackall <mpm@selenic.com>
parents:
7058
diff
changeset
|
31 0 Changed root |
cc8f1083e8be
tests: unify test-convert-bzr-treeroot
Matt Mackall <mpm@selenic.com>
parents:
7058
diff
changeset
|
32 $ manifest source-hg tip |
cc8f1083e8be
tests: unify test-convert-bzr-treeroot
Matt Mackall <mpm@selenic.com>
parents:
7058
diff
changeset
|
33 % manifest of tip |
cc8f1083e8be
tests: unify test-convert-bzr-treeroot
Matt Mackall <mpm@selenic.com>
parents:
7058
diff
changeset
|
34 644 file |
16913
f2719b387380
tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents:
12517
diff
changeset
|
35 |
f2719b387380
tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents:
12517
diff
changeset
|
36 $ cd .. |