# HG changeset patch # User Boris Feld # Date 1499891988 -7200 # Node ID 67a3204c83c172a4ca8993b9291a76789fd80533 # Parent cf694e6422f0ceb572d05f1d118c010a6028444f phases: test phases tracking at the transaction level Now that we have all tracking in place, the data in `tr.changes['phases']` dictionary should be correct and we should test it. It is a bit late in the cycle to discuss to add any public API (eg: hooks) that expose the data to the user, so we just add a small test extension displaying the data. It is enabled for the phases tests. New output have been manually checked for consistency. diff -r cf694e6422f0 -r 67a3204c83c1 tests/test-phases-exchange.t --- a/tests/test-phases-exchange.t Wed Jul 12 20:11:00 2017 +0200 +++ b/tests/test-phases-exchange.t Wed Jul 12 22:39:48 2017 +0200 @@ -1,5 +1,10 @@ #require killdaemons + $ cat >> $HGRCPATH << EOF + > [extensions] + > phasereport=$TESTDIR/testlib/ext-phase-report.py + > EOF + $ hgph() { hg log -G --template "{rev} {phase} {desc} - {node|short}\n" $*; } $ mkcommit() { @@ -13,9 +18,13 @@ $ hg init alpha $ cd alpha $ mkcommit a-A + test-debug-phase: new rev 0: x -> 1 $ mkcommit a-B + test-debug-phase: new rev 1: x -> 1 $ mkcommit a-C + test-debug-phase: new rev 2: x -> 1 $ mkcommit a-D + test-debug-phase: new rev 3: x -> 1 $ hgph @ 3 draft a-D - b555f63b6063 | @@ -34,6 +43,10 @@ adding manifests adding file changes added 2 changesets with 2 changes to 2 files + test-debug-phase: new rev 0: x -> 0 + test-debug-phase: new rev 1: x -> 0 + test-debug-phase: move rev 0: 1 -> 0 + test-debug-phase: move rev 1: 1 -> 0 $ hgph @ 3 draft a-D - b555f63b6063 | @@ -52,6 +65,7 @@ $ hg up -q $ mkcommit b-A + test-debug-phase: new rev 2: x -> 1 $ hgph @ 2 draft b-A - f54f1bb90ff3 | @@ -66,6 +80,8 @@ adding manifests adding file changes added 2 changesets with 2 changes to 2 files (+1 heads) + test-debug-phase: new rev 3: x -> 0 + test-debug-phase: new rev 4: x -> 0 (run 'hg heads' to see heads, 'hg merge' to merge) $ hgph o 4 public a-D - b555f63b6063 @@ -96,6 +112,7 @@ pushing to ../beta searching for changes no changes found + test-debug-phase: move rev 2: 1 -> 0 [1] $ hgph @ 3 draft a-D - b555f63b6063 @@ -110,6 +127,7 @@ pushing to ../beta searching for changes no changes found + test-debug-phase: move rev 3: 1 -> 0 [1] $ hgph @ 3 public a-D - b555f63b6063 @@ -130,6 +148,7 @@ adding manifests adding file changes added 1 changesets with 1 changes to 1 files (+1 heads) + test-debug-phase: new rev 4: x -> 0 (run 'hg heads' to see heads, 'hg merge' to merge) $ cd ../beta @@ -148,6 +167,7 @@ pulling from ../alpha searching for changes no changes found + test-debug-phase: move rev 2: 1 -> 0 $ hgph o 4 public a-D - b555f63b6063 | @@ -182,6 +202,11 @@ adding manifests adding file changes added 5 changesets with 5 changes to 5 files (+1 heads) + test-debug-phase: new rev 0: x -> 1 + test-debug-phase: new rev 1: x -> 1 + test-debug-phase: new rev 2: x -> 1 + test-debug-phase: new rev 3: x -> 1 + test-debug-phase: new rev 4: x -> 1 (run 'hg heads' to see heads, 'hg merge' to merge) $ hgph o 4 draft a-D - b555f63b6063 @@ -210,6 +235,9 @@ adding manifests adding file changes added 3 changesets with 3 changes to 3 files + test-debug-phase: new rev 0: x -> 1 + test-debug-phase: new rev 1: x -> 1 + test-debug-phase: new rev 2: x -> 1 (run 'hg update' to get a working copy) $ hgph o 2 draft a-C - 54acac6f23ab @@ -228,6 +256,7 @@ adding manifests adding file changes added 1 changesets with 1 changes to 1 files (+1 heads) + test-debug-phase: new rev 3: x -> 1 (run 'hg heads' to see heads, 'hg merge' to merge) $ hgph o 3 draft b-A - f54f1bb90ff3 @@ -250,6 +279,10 @@ adding manifests adding file changes added 1 changesets with 1 changes to 1 files + test-debug-phase: move rev 0: 1 -> 0 + test-debug-phase: move rev 1: 1 -> 0 + test-debug-phase: move rev 2: 1 -> 0 + test-debug-phase: new rev 4: x -> 0 (run 'hg update' to get a working copy) $ hgph # f54f1bb90ff3 stay draft, not ancestor of -r o 4 public a-D - b555f63b6063 @@ -267,7 +300,9 @@ $ hg up -q f54f1bb90ff3 $ mkcommit n-A + test-debug-phase: new rev 5: x -> 1 $ mkcommit n-B + test-debug-phase: new rev 6: x -> 1 $ hgph @ 6 draft n-B - 145e75495359 | @@ -291,6 +326,12 @@ adding manifests adding file changes added 2 changesets with 2 changes to 2 files + test-debug-phase: move rev 0: 1 -> 0 + test-debug-phase: move rev 1: 1 -> 0 + test-debug-phase: move rev 3: 1 -> 0 + test-debug-phase: move rev 4: 1 -> 0 + test-debug-phase: new rev 5: x -> 1 + test-debug-phase: new rev 6: x -> 1 (run 'hg update' to get a working copy) $ hgph o 6 draft n-B - 145e75495359 @@ -330,6 +371,8 @@ adding manifests adding file changes added 2 changesets with 2 changes to 2 files + test-debug-phase: new rev 5: x -> 1 + test-debug-phase: new rev 6: x -> 1 (run 'hg update' to get a working copy) $ hgph o 6 draft n-B - 145e75495359 @@ -355,6 +398,9 @@ pulling from ../alpha searching for changes no changes found + test-debug-phase: move rev 3: 1 -> 0 + test-debug-phase: move rev 5: 1 -> 0 + test-debug-phase: move rev 6: 1 -> 0 $ hgph @ 6 public n-B - 145e75495359 | @@ -385,6 +431,8 @@ pushing to ../alpha searching for changes no changes found + test-debug-phase: move rev 5: 1 -> 0 + test-debug-phase: move rev 6: 1 -> 0 [1] $ cd .. $ cd alpha @@ -448,10 +496,14 @@ summary: a-A $ mkcommit a-E + test-debug-phase: new rev 7: x -> 1 $ mkcommit a-F + test-debug-phase: new rev 8: x -> 1 $ mkcommit a-G + test-debug-phase: new rev 9: x -> 1 $ hg up d6bcb4f74035 -q $ mkcommit a-H + test-debug-phase: new rev 10: x -> 1 created new head $ hgph @ 10 draft a-H - 967b449fbc94 @@ -518,6 +570,8 @@ adding manifests adding file changes added 2 changesets with 2 changes to 2 files + test-debug-phase: new rev 7: x -> 1 + test-debug-phase: new rev 8: x -> 1 $ hgph @ 10 draft a-H - 967b449fbc94 | @@ -573,6 +627,10 @@ adding manifests adding file changes added 2 changesets with 2 changes to 2 files + test-debug-phase: new rev 5: x -> 0 + test-debug-phase: new rev 6: x -> 0 + test-debug-phase: move rev 7: 1 -> 0 + test-debug-phase: move rev 8: 1 -> 0 $ hgph # again f54f1bb90ff3, d6bcb4f74035 and 145e75495359 stay draft, > # not ancestor of -r o 8 public a-F - b740e3e5c05d @@ -601,6 +659,8 @@ pushing to ../alpha searching for changes no changes found + test-debug-phase: move rev 7: 1 -> 0 + test-debug-phase: move rev 8: 1 -> 0 [1] $ hgph o 6 public a-F - b740e3e5c05d @@ -651,6 +711,9 @@ adding manifests adding file changes added 1 changesets with 1 changes to 1 files (+1 heads) + test-debug-phase: move rev 2: 1 -> 0 + test-debug-phase: move rev 5: 1 -> 0 + test-debug-phase: new rev 9: x -> 1 $ hgph @ 10 draft a-H - 967b449fbc94 | @@ -706,6 +769,9 @@ pushing to ../alpha searching for changes no changes found + test-debug-phase: move rev 10: 1 -> 0 + test-debug-phase: move rev 6: 1 -> 0 + test-debug-phase: move rev 9: 1 -> 0 [1] $ hgph o 9 public a-H - 967b449fbc94 @@ -760,6 +826,8 @@ $ hg -R ../alpha --config extensions.strip= strip --no-backup 967b449fbc94 0 files updated, 0 files merged, 1 files removed, 0 files unresolved $ hg phase --force --draft b740e3e5c05d 967b449fbc94 + test-debug-phase: move rev 8: 0 -> 1 + test-debug-phase: move rev 9: 0 -> 1 $ hg push -fv ../alpha pushing to ../alpha searching for changes @@ -772,6 +840,9 @@ adding manifests adding file changes added 1 changesets with 1 changes to 1 files (+1 heads) + test-debug-phase: new rev 10: x -> 0 + test-debug-phase: move rev 8: 1 -> 0 + test-debug-phase: move rev 9: 1 -> 0 $ hgph o 9 public a-H - 967b449fbc94 | @@ -826,6 +897,7 @@ $ cd ../alpha $ mkcommit A-secret --config phases.new-commit=2 + test-debug-phase: new rev 11: x -> 2 $ hgph @ 11 secret A-secret - 435b5d83910c | @@ -858,6 +930,7 @@ adding manifests adding file changes added 1 changesets with 1 changes to 1 files + test-debug-phase: new rev 10: x -> 1 (run 'hg update' to get a working copy) $ hgph -R ../mu o 10 draft A-secret - 435b5d83910c @@ -886,6 +959,7 @@ pulling from ../mu searching for changes no changes found + test-debug-phase: move rev 11: 2 -> 1 $ hgph @ 11 draft A-secret - 435b5d83910c | @@ -916,6 +990,8 @@ appear on the remote side. $ hg -R ../mu phase --secret --force 967b449fbc94 + test-debug-phase: move rev 9: 0 -> 2 + test-debug-phase: move rev 10: 1 -> 2 $ hg push -r 435b5d83910c ../mu pushing to ../mu searching for changes @@ -929,6 +1005,8 @@ adding manifests adding file changes added 0 changesets with 0 changes to 2 files + test-debug-phase: move rev 9: 2 -> 0 + test-debug-phase: move rev 10: 2 -> 1 $ hgph -R ../mu o 10 draft A-secret - 435b5d83910c | @@ -957,6 +1035,7 @@ $ hg up -q 967b449fbc94 # create a new root for draft $ mkcommit 'alpha-more' + test-debug-phase: new rev 12: x -> 1 created new head $ hg push -fr . ../mu pushing to ../mu @@ -965,10 +1044,13 @@ adding manifests adding file changes added 1 changesets with 1 changes to 1 files (+1 heads) + test-debug-phase: new rev 11: x -> 1 $ cd ../mu $ hg phase --secret --force 1c5cfd894796 + test-debug-phase: move rev 11: 1 -> 2 $ hg up -q 435b5d83910c $ mkcommit 'mu-more' + test-debug-phase: new rev 12: x -> 1 $ cd ../alpha $ hg pull ../mu pulling from ../mu @@ -977,6 +1059,7 @@ adding manifests adding file changes added 1 changesets with 1 changes to 1 files + test-debug-phase: new rev 13: x -> 1 (run 'hg update' to get a working copy) $ hgph o 13 draft mu-more - 5237fb433fc8 @@ -1012,6 +1095,11 @@ $ cd .. $ hg clone -qU -r b555f63b6063 -r f54f1bb90ff3 beta gamma + test-debug-phase: new rev 0: x -> 0 + test-debug-phase: new rev 1: x -> 0 + test-debug-phase: new rev 2: x -> 0 + test-debug-phase: new rev 3: x -> 0 + test-debug-phase: new rev 4: x -> 0 # pathological case are # @@ -1020,7 +1108,9 @@ # * repo have uncommon changeset $ hg -R beta phase --secret --force f54f1bb90ff3 + test-debug-phase: move rev 2: 0 -> 2 $ hg -R gamma phase --draft --force f54f1bb90ff3 + test-debug-phase: move rev 2: 0 -> 1 $ cd gamma $ hg pull ../beta @@ -1030,6 +1120,8 @@ adding manifests adding file changes added 2 changesets with 2 changes to 2 files + test-debug-phase: new rev 5: x -> 0 + test-debug-phase: new rev 6: x -> 0 (run 'hg update' to get a working copy) $ hg phase f54f1bb90ff3 2: draft @@ -1083,6 +1175,7 @@ # make sure there is no secret so we can use a copy clone $ hg -R mu phase --draft 'secret()' + test-debug-phase: move rev 11: 2 -> 1 $ hg clone -U mu Tau $ hgph -R Tau @@ -1169,11 +1262,29 @@ adding manifests adding file changes added 14 changesets with 14 changes to 14 files (+3 heads) + test-debug-phase: new rev 0: x -> 0 + test-debug-phase: new rev 1: x -> 0 + test-debug-phase: new rev 2: x -> 0 + test-debug-phase: new rev 3: x -> 0 + test-debug-phase: new rev 4: x -> 0 + test-debug-phase: new rev 5: x -> 0 + test-debug-phase: new rev 6: x -> 0 + test-debug-phase: new rev 7: x -> 0 + test-debug-phase: new rev 8: x -> 0 + test-debug-phase: new rev 9: x -> 0 + test-debug-phase: new rev 10: x -> 0 + test-debug-phase: new rev 11: x -> 0 + test-debug-phase: new rev 12: x -> 0 + test-debug-phase: new rev 13: x -> 0 $ chmod -R +w .hg 2. Test that failed phases movement are reported $ hg phase --force --draft 3 + test-debug-phase: move rev 3: 0 -> 1 + test-debug-phase: move rev 7: 0 -> 1 + test-debug-phase: move rev 8: 0 -> 1 + test-debug-phase: move rev 9: 0 -> 1 $ chmod -R -w .hg $ hg push ../Phi pushing to ../Phi @@ -1191,7 +1302,13 @@ publish changesets as plain push does $ hg -R Upsilon phase -q --force --draft 2 + test-debug-phase: move rev 2: 0 -> 1 $ hg clone -q Upsilon Pi -r 7 + test-debug-phase: new rev 0: x -> 0 + test-debug-phase: new rev 1: x -> 0 + test-debug-phase: new rev 2: x -> 0 + test-debug-phase: new rev 3: x -> 0 + test-debug-phase: new rev 4: x -> 0 $ hgph Upsilon -r 'min(draft())' o 2 draft a-C - 54acac6f23ab | @@ -1201,6 +1318,9 @@ pushing to Pi searching for changes no changes found + test-debug-phase: move rev 2: 1 -> 0 + test-debug-phase: move rev 3: 1 -> 0 + test-debug-phase: move rev 7: 1 -> 0 [1] $ hgph Upsilon -r 'min(draft())' o 8 draft a-F - b740e3e5c05d @@ -1214,6 +1334,8 @@ adding manifests adding file changes added 1 changesets with 1 changes to 1 files + test-debug-phase: new rev 5: x -> 0 + test-debug-phase: move rev 8: 1 -> 0 $ hgph Upsilon -r 'min(draft())' o 9 draft a-G - 3e27b6f1eee1 diff -r cf694e6422f0 -r 67a3204c83c1 tests/test-phases.t --- a/tests/test-phases.t Wed Jul 12 20:11:00 2017 +0200 +++ b/tests/test-phases.t Wed Jul 12 22:39:48 2017 +0200 @@ -1,3 +1,9 @@ + + $ cat >> $HGRCPATH << EOF + > [extensions] + > phasereport=$TESTDIR/testlib/ext-phase-report.py + > EOF + $ hglog() { hg log --template "{rev} {phaseidx} {desc}\n" $*; } $ mkcommit() { > echo "$1" > "$1" @@ -19,6 +25,7 @@ -1: public $ mkcommit A + test-debug-phase: new rev 0: x -> 1 New commit are draft by default @@ -28,6 +35,7 @@ Following commit are draft too $ mkcommit B + test-debug-phase: new rev 1: x -> 1 $ hglog 1 1 B @@ -36,6 +44,8 @@ Draft commit are properly created over public one: $ hg phase --public . + test-debug-phase: move rev 0: 1 -> 0 + test-debug-phase: move rev 1: 1 -> 0 $ hg phase 1: public $ hglog @@ -43,7 +53,9 @@ 0 0 A $ mkcommit C + test-debug-phase: new rev 2: x -> 1 $ mkcommit D + test-debug-phase: new rev 3: x -> 1 $ hglog 3 1 D @@ -54,6 +66,7 @@ Test creating changeset as secret $ mkcommit E --config phases.new-commit='secret' + test-debug-phase: new rev 4: x -> 2 $ hglog 4 2 E 3 1 D @@ -64,6 +77,7 @@ Test the secret property is inherited $ mkcommit H + test-debug-phase: new rev 5: x -> 2 $ hglog 5 2 H 4 2 E @@ -76,6 +90,7 @@ $ hg up -q 1 $ mkcommit "B'" + test-debug-phase: new rev 6: x -> 1 created new head $ hglog 6 1 B' @@ -92,6 +107,8 @@ 6: draft 4: secret $ hg ci -m "merge B' and E" + test-debug-phase: new rev 7: x -> 2 + $ hglog 7 2 merge B' and E 6 1 B' @@ -133,6 +150,11 @@ adding manifests adding file changes added 5 changesets with 5 changes to 5 files (+1 heads) + test-debug-phase: new rev 0: x -> 0 + test-debug-phase: new rev 1: x -> 0 + test-debug-phase: new rev 2: x -> 1 + test-debug-phase: new rev 3: x -> 1 + test-debug-phase: new rev 4: x -> 1 $ hglog 7 2 merge B' and E 6 1 B' @@ -158,6 +180,7 @@ $ hg up -q 4 # B' $ mkcommit Z --config phases.new-commit=secret + test-debug-phase: new rev 5: x -> 2 $ hg phase . 5: secret @@ -167,6 +190,7 @@ $ cd ../initialrepo $ hg up -q 6 #B' $ mkcommit I + test-debug-phase: new rev 8: x -> 1 created new head $ hg push ../push-dest pushing to ../push-dest @@ -175,6 +199,7 @@ adding manifests adding file changes added 1 changesets with 1 changes to 1 files (+1 heads) + test-debug-phase: new rev 6: x -> 1 :note: The "(+1 heads)" is wrong as we do not had any visible head @@ -222,6 +247,11 @@ adding manifests adding file changes added 5 changesets with 5 changes to 5 files (+1 heads) + test-debug-phase: new rev 0: x -> 0 + test-debug-phase: new rev 1: x -> 0 + test-debug-phase: new rev 2: x -> 0 + test-debug-phase: new rev 3: x -> 0 + test-debug-phase: new rev 4: x -> 0 (run 'hg heads' to see heads, 'hg merge' to merge) $ hglog 4 0 B' @@ -242,6 +272,11 @@ (during local clone) $ hg clone -qU initialrepo clone-dest + test-debug-phase: new rev 0: x -> 0 + test-debug-phase: new rev 1: x -> 0 + test-debug-phase: new rev 2: x -> 0 + test-debug-phase: new rev 3: x -> 0 + test-debug-phase: new rev 4: x -> 0 $ hglog -R clone-dest 4 0 B' 3 0 D @@ -440,6 +475,7 @@ (with -r option) $ hg phase --public -r 2 + test-debug-phase: move rev 2: 1 -> 0 $ hg log -G --template "{rev} {phase} {desc}\n" @ 7 secret merge B' and E |\ @@ -463,6 +499,7 @@ (without -r option) $ hg phase --draft --force 2 + test-debug-phase: move rev 2: 0 -> 1 $ hg log -G --template "{rev} {phase} {desc}\n" @ 7 secret merge B' and E |\ @@ -484,6 +521,8 @@ move changeset forward and backward $ hg phase --draft --force 1::4 + test-debug-phase: move rev 1: 0 -> 1 + test-debug-phase: move rev 4: 2 -> 1 $ hg log -G --template "{rev} {phase} {desc}\n" @ 7 secret merge B' and E |\ @@ -504,7 +543,14 @@ test partial failure $ hg phase --public 7 + test-debug-phase: move rev 1: 1 -> 0 + test-debug-phase: move rev 2: 1 -> 0 + test-debug-phase: move rev 3: 1 -> 0 + test-debug-phase: move rev 4: 1 -> 0 + test-debug-phase: move rev 6: 1 -> 0 + test-debug-phase: move rev 7: 2 -> 0 $ hg phase --draft '5 or 7' + test-debug-phase: move rev 5: 2 -> 1 cannot move 1 changesets to a higher phase, use --force phase changed for 1 changesets [1] @@ -555,6 +601,13 @@ adding manifests adding file changes added 7 changesets with 6 changes to 6 files + test-debug-phase: new rev 0: x -> 0 + test-debug-phase: new rev 1: x -> 0 + test-debug-phase: new rev 2: x -> 0 + test-debug-phase: new rev 3: x -> 0 + test-debug-phase: new rev 4: x -> 0 + test-debug-phase: new rev 5: x -> 0 + test-debug-phase: new rev 6: x -> 0 updating to branch default 6 files updated, 0 files merged, 0 files removed, 0 files unresolved $ cd clonewithobs diff -r cf694e6422f0 -r 67a3204c83c1 tests/testlib/ext-phase-report.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/testlib/ext-phase-report.py Wed Jul 12 22:39:48 2017 +0200 @@ -0,0 +1,22 @@ +# tiny extension to report phase changes during transaction + +from __future__ import absolute_import + +def reposetup(ui, repo): + + def reportphasemove(tr): + for rev, move in sorted(tr.changes['phases'].iteritems()): + if move[0] is None: + ui.write(('test-debug-phase: new rev %d: x -> %d\n' + % (rev, move[1]))) + else: + ui.write(('test-debug-phase: move rev %d: %s -> %d\n' + % (rev, move[0], move[1]))) + + class reportphaserepo(repo.__class__): + def transaction(self, *args, **kwargs): + tr = super(reportphaserepo, self).transaction(*args, **kwargs) + tr.addpostclose('report-phase', reportphasemove) + return tr + + repo.__class__ = reportphaserepo