Mercurial > evolve
changeset 2289:61d073590fb7
ui: add better messages when the working copy become obsolete.
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Fri, 28 Apr 2017 16:57:41 +0200 |
parents | b6ea9049693d |
children | a36a8c6a09ac |
files | README hgext3rd/evolve/__init__.py tests/test-evolve-obshistory.t tests/test-inhibit.t tests/test-obsolete.t tests/test-stabilize-result.t tests/test-touch.t tests/test-tutorial.t tests/test-uncommit.t |
diffstat | 9 files changed, 573 insertions(+), 29 deletions(-) [+] |
line wrap: on
line diff
--- a/README Fri Apr 28 15:29:32 2017 +0200 +++ b/README Fri Apr 28 16:57:41 2017 +0200 @@ -115,7 +115,8 @@ 6.1.0 - in progress ------------------- - * add a 'experimental.auto-publish' config. Set it so 'warn' to get a warning + - improve messages about obsolete working copy parent, + - add a 'experimental.auto-publish' config. Set it so 'warn' to get a warning when a push is publishing some draft changesets and 'abort' to prevent that to happen at all.
--- a/hgext3rd/evolve/__init__.py Fri Apr 28 15:29:32 2017 +0200 +++ b/hgext3rd/evolve/__init__.py Fri Apr 28 16:57:41 2017 +0200 @@ -104,6 +104,7 @@ revset, scmutil, templatekw, + obsolete ) from mercurial.commands import walkopts, commitopts, commitopts2, mergetoolopts @@ -451,11 +452,69 @@ # This section take care of issue warning to the user when troubles appear +def _getobsoletereason(repo, revnode): + """ Return a tuple containing: + - the reason a revision is obsolete (diverged, pruned or superseed) + - the list of successors short node if the revision is neither pruned + or has diverged + """ + successorssets = obsolete.successorssets(repo, revnode) + + if len(successorssets) == 0: + # The commit has been pruned + return ('pruned', []) + elif len(successorssets) > 1: + return ('diverged', []) + else: + # No divergence, only one set of successors + successors = [node.short(node_id) for node_id in successorssets[0]] + + if len(successors) == 1: + return ('superseed', successors) + else: + return ('superseed_split', successors) + def _warnobsoletewc(ui, repo): - if repo['.'].obsolete(): - ui.warn(_('working directory parent is obsolete!\n')) - if (not ui.quiet) and obsolete.isenabled(repo, commandopt): - ui.warn(_("(use 'hg evolve' to update to its successor)\n")) + rev = repo['.'] + + if not rev.obsolete(): + return + + msg = _("working directory parent is obsolete! (%s)\n") + shortnode = node.short(rev.node()) + + ui.warn(msg % shortnode) + + # Check that evolve is activated for performance reasons + if ui.quiet or not obsolete.isenabled(repo, commandopt): + return + + # Show a warning for helping the user to solve the issue + reason, successors = _getobsoletereason(repo, rev.node()) + + if reason == 'pruned': + solvemsg = _("use 'hg evolve' to update to its parent successor") + elif reason == 'diverged': + debugcommand = "hg evolve -list --divergent" + basemsg = _("%s has diverged, use '%s' to resolve the issue") + solvemsg = basemsg % (shortnode, debugcommand) + elif reason == 'superseed': + msg = _("use 'hg evolve' to update to its successor: %s") + solvemsg = msg % successors[0] + elif reason == 'superseed_split': + msg = _("use 'hg evolve' to update to its tipmost successor: %s") + + if len(successors) <= 2: + solvemsg = msg % ", ".join(successors) + else: + firstsuccessors = ", ".join(successors[:2]) + remainingnumber = len(successors) - 2 + successorsmsg = _("%s and %d more") % (firstsuccessors, remainingnumber) + solvemsg = msg % successorsmsg + else: + raise ValueError(reason) + + ui.warn("(%s)\n" % solvemsg) @eh.wrapcommand("update") @eh.wrapcommand("pull")
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-evolve-obshistory.t Fri Apr 28 16:57:41 2017 +0200 @@ -0,0 +1,484 @@ +This test file test the various messages when accessing obsolete +revisions. + +Global setup +============ + + $ . $TESTDIR/testlib/common.sh + $ cat >> $HGRCPATH <<EOF + > [ui] + > interactive = true + > [phases] + > publish=False + > [extensions] + > evolve = + > EOF + +Test output on amended commit +============================= + +Test setup +---------- + + $ hg init $TESTTMP/local-amend + $ cd $TESTTMP/local-amend + $ mkcommit ROOT + $ mkcommit A0 + $ echo 42 >> A0 + $ hg amend -m "A1" + $ hg log --hidden -G + @ changeset: 3:a468dc9b3633 + | tag: tip + | parent: 0:ea207398892e + | user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: A1 + | + | x changeset: 2:f137d23bb3e1 + | | user: test + | | date: Thu Jan 01 00:00:00 1970 +0000 + | | summary: temporary amend commit for 471f378eab4c + | | + | x changeset: 1:471f378eab4c + |/ user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: A0 + | + o changeset: 0:ea207398892e + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: ROOT + +Actual test +----------- + + $ hg update --hidden "desc(A0)" + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + working directory parent is obsolete! (471f378eab4c) + (use 'hg evolve' to update to its successor: a468dc9b3633) + +Test output with pruned commit +============================== + +Test setup +---------- + + $ hg init $TESTTMP/local-prune + $ cd $TESTTMP/local-prune + $ mkcommit ROOT + $ mkcommit A0 # 0 + $ mkcommit B0 # 1 + $ hg log --hidden -G + @ changeset: 2:0dec01379d3b + | tag: tip + | user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: B0 + | + o changeset: 1:471f378eab4c + | user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: A0 + | + o changeset: 0:ea207398892e + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: ROOT + + $ hg prune -r 'desc(B0)' + 0 files updated, 0 files merged, 1 files removed, 0 files unresolved + working directory now at 471f378eab4c + 1 changesets pruned + +Actual test +----------- + + $ hg up --hidden -r 'desc(B0)' + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + working directory parent is obsolete! (0dec01379d3b) + (use 'hg evolve' to update to its parent successor) + +Test output with splitted commit +================================ + +Test setup +---------- + + $ hg init $TESTTMP/local-split + $ cd $TESTTMP/local-split + $ mkcommit ROOT + $ echo 42 >> a + $ echo 43 >> b + $ hg commit -A -m "A0" + adding a + adding b + $ hg log --hidden -G + @ changeset: 1:471597cad322 + | tag: tip + | user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: A0 + | + o changeset: 0:ea207398892e + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: ROOT + + $ hg split -r 'desc(A0)' -d "0 0" << EOF + > y + > y + > n + > n + > y + > y + > EOF + 0 files updated, 0 files merged, 2 files removed, 0 files unresolved + adding a + adding b + diff --git a/a b/a + new file mode 100644 + examine changes to 'a'? [Ynesfdaq?] y + + @@ -0,0 +1,1 @@ + +42 + record change 1/2 to 'a'? [Ynesfdaq?] y + + diff --git a/b b/b + new file mode 100644 + examine changes to 'b'? [Ynesfdaq?] n + + created new head + Done splitting? [yN] n + diff --git a/b b/b + new file mode 100644 + examine changes to 'b'? [Ynesfdaq?] y + + @@ -0,0 +1,1 @@ + +43 + record this change to 'b'? [Ynesfdaq?] y + + no more change to split + + $ hg log --hidden -G + @ changeset: 3:f257fde29c7a + | tag: tip + | user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: A0 + | + o changeset: 2:337fec4d2edc + | parent: 0:ea207398892e + | user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: A0 + | + | x changeset: 1:471597cad322 + |/ user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: A0 + | + o changeset: 0:ea207398892e + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: ROOT + +Actual test +----------- + + $ hg update --hidden 'min(desc(A0))' + 0 files updated, 0 files merged, 0 files removed, 0 files unresolved + working directory parent is obsolete! (471597cad322) + (use 'hg evolve' to update to its tipmost successor: 337fec4d2edc, f257fde29c7a) + +Test output with lots of splitted commit +======================================== + +Test setup +---------- + + $ hg init $TESTTMP/local-lots-split + $ cd $TESTTMP/local-lots-split + $ mkcommit ROOT + $ echo 42 >> a + $ echo 43 >> b + $ echo 44 >> c + $ echo 45 >> d + $ hg commit -A -m "A0" + adding a + adding b + adding c + adding d + $ hg log --hidden -G + @ changeset: 1:de7290d8b885 + | tag: tip + | user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: A0 + | + o changeset: 0:ea207398892e + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: ROOT + + + $ hg split -r 'desc(A0)' -d "0 0" << EOF + > y + > y + > n + > n + > n + > n + > y + > y + > n + > n + > n + > y + > y + > n + > n + > y + > y + > EOF + 0 files updated, 0 files merged, 4 files removed, 0 files unresolved + adding a + adding b + adding c + adding d + diff --git a/a b/a + new file mode 100644 + examine changes to 'a'? [Ynesfdaq?] y + + @@ -0,0 +1,1 @@ + +42 + record change 1/4 to 'a'? [Ynesfdaq?] y + + diff --git a/b b/b + new file mode 100644 + examine changes to 'b'? [Ynesfdaq?] n + + diff --git a/c b/c + new file mode 100644 + examine changes to 'c'? [Ynesfdaq?] n + + diff --git a/d b/d + new file mode 100644 + examine changes to 'd'? [Ynesfdaq?] n + + created new head + Done splitting? [yN] n + diff --git a/b b/b + new file mode 100644 + examine changes to 'b'? [Ynesfdaq?] y + + @@ -0,0 +1,1 @@ + +43 + record change 1/3 to 'b'? [Ynesfdaq?] y + + diff --git a/c b/c + new file mode 100644 + examine changes to 'c'? [Ynesfdaq?] n + + diff --git a/d b/d + new file mode 100644 + examine changes to 'd'? [Ynesfdaq?] n + + Done splitting? [yN] n + diff --git a/c b/c + new file mode 100644 + examine changes to 'c'? [Ynesfdaq?] y + + @@ -0,0 +1,1 @@ + +44 + record change 1/2 to 'c'? [Ynesfdaq?] y + + diff --git a/d b/d + new file mode 100644 + examine changes to 'd'? [Ynesfdaq?] n + + Done splitting? [yN] n + diff --git a/d b/d + new file mode 100644 + examine changes to 'd'? [Ynesfdaq?] y + + @@ -0,0 +1,1 @@ + +45 + record this change to 'd'? [Ynesfdaq?] y + + no more change to split + + $ hg log --hidden -G + @ changeset: 5:c7f044602e9b + | tag: tip + | user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: A0 + | + o changeset: 4:1ae8bc733a14 + | user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: A0 + | + o changeset: 3:f257fde29c7a + | user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: A0 + | + o changeset: 2:337fec4d2edc + | parent: 0:ea207398892e + | user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: A0 + | + | x changeset: 1:de7290d8b885 + |/ user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: A0 + | + o changeset: 0:ea207398892e + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: ROOT + +Actual test +----------- + + $ hg update --hidden 'min(desc(A0))' + 0 files updated, 0 files merged, 0 files removed, 0 files unresolved + working directory parent is obsolete! (de7290d8b885) + (use 'hg evolve' to update to its tipmost successor: 337fec4d2edc, f257fde29c7a and 2 more) + +Test output with folded commit +============================== + +Test setup +---------- + + $ hg init $TESTTMP/local-fold + $ cd $TESTTMP/local-fold + $ mkcommit ROOT + $ mkcommit A0 + $ mkcommit B0 + $ hg log --hidden -G + @ changeset: 2:0dec01379d3b + | tag: tip + | user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: B0 + | + o changeset: 1:471f378eab4c + | user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: A0 + | + o changeset: 0:ea207398892e + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: ROOT + + $ hg fold --exact -r 'desc(A0) + desc(B0)' --date "0 0" -m "C0" + 2 changesets folded + 0 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ hg log --hidden -G + @ changeset: 3:eb5a0daa2192 + | tag: tip + | parent: 0:ea207398892e + | user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: C0 + | + | x changeset: 2:0dec01379d3b + | | user: test + | | date: Thu Jan 01 00:00:00 1970 +0000 + | | summary: B0 + | | + | x changeset: 1:471f378eab4c + |/ user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: A0 + | + o changeset: 0:ea207398892e + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: ROOT + + Actual test + ----------- + + $ hg update --hidden 'desc(A0)' + 0 files updated, 0 files merged, 1 files removed, 0 files unresolved + working directory parent is obsolete! (471f378eab4c) + (use 'hg evolve' to update to its successor: eb5a0daa2192) + $ hg update --hidden 'desc(B0)' + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + working directory parent is obsolete! (0dec01379d3b) + (use 'hg evolve' to update to its successor: eb5a0daa2192) + +Test output with divergence +=========================== + +Test setup +---------- + + $ hg init $TESTTMP/local-divergence + $ cd $TESTTMP/local-divergence + $ mkcommit ROOT + $ mkcommit A0 + $ hg amend -m "A1" + $ hg log --hidden -G + @ changeset: 2:fdf9bde5129a + | tag: tip + | parent: 0:ea207398892e + | user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: A1 + | + | x changeset: 1:471f378eab4c + |/ user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: A0 + | + o changeset: 0:ea207398892e + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: ROOT + + $ hg update --hidden 'desc(A0)' + 0 files updated, 0 files merged, 0 files removed, 0 files unresolved + working directory parent is obsolete! (471f378eab4c) + (use 'hg evolve' to update to its successor: fdf9bde5129a) + $ hg amend -m "A2" + 2 new divergent changesets + $ hg log --hidden -G + @ changeset: 3:65b757b745b9 + | tag: tip + | parent: 0:ea207398892e + | user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | trouble: divergent + | summary: A2 + | + | o changeset: 2:fdf9bde5129a + |/ parent: 0:ea207398892e + | user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | trouble: divergent + | summary: A1 + | + | x changeset: 1:471f378eab4c + |/ user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: A0 + | + o changeset: 0:ea207398892e + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: ROOT + +Actual test +----------- + + $ hg update --hidden 'desc(A0)' + 0 files updated, 0 files merged, 0 files removed, 0 files unresolved + working directory parent is obsolete! (471f378eab4c) + (471f378eab4c has diverged, use 'hg evolve -list --divergent' to resolve the issue)
--- a/tests/test-inhibit.t Fri Apr 28 15:29:32 2017 +0200 +++ b/tests/test-inhibit.t Fri Apr 28 16:57:41 2017 +0200 @@ -699,7 +699,7 @@ $ hg up 15 1 files updated, 0 files merged, 0 files removed, 0 files unresolved - working directory parent is obsolete! + working directory parent is obsolete! (2d66e189f5b5) $ cat >> $HGRCPATH <<EOF > [experimental] > evolution=all
--- a/tests/test-obsolete.t Fri Apr 28 15:29:32 2017 +0200 +++ b/tests/test-obsolete.t Fri Apr 28 16:57:41 2017 +0200 @@ -121,7 +121,7 @@ 4 - 725c380fe99b $ hg up --hidden 3 -q - working directory parent is obsolete! + working directory parent is obsolete! (0d3f46688ccc) (reported by parents too) $ hg parents changeset: 3:0d3f46688ccc @@ -130,8 +130,8 @@ date: Thu Jan 01 00:00:00 1970 +0000 summary: add obsol_c - working directory parent is obsolete! - (use 'hg evolve' to update to its successor) + working directory parent is obsolete! (0d3f46688ccc) + (use 'hg evolve' to update to its successor: 725c380fe99b) $ mkcommit d # 5 (on 3) 1 new unstable changesets $ qlog -r 'obsolete()' @@ -206,7 +206,7 @@ 0 - 1f0dee641bb7 $ hg up --hidden 3 -q - working directory parent is obsolete! + working directory parent is obsolete! (0d3f46688ccc) $ mkcommit obsol_d # 6 created new head 1 new unstable changesets @@ -263,7 +263,7 @@ [1] $ hg up --hidden -q .^ # 3 - working directory parent is obsolete! + working directory parent is obsolete! (0d3f46688ccc) $ mkcommit "obsol_d'" # 7 created new head 1 new unstable changesets @@ -351,7 +351,7 @@ Test rollback support $ hg up --hidden .^ -q # 3 - working directory parent is obsolete! + working directory parent is obsolete! (0d3f46688ccc) $ mkcommit "obsol_d''" created new head 1 new unstable changesets @@ -687,7 +687,7 @@ $ hg up --hidden 3 -q - working directory parent is obsolete! + working directory parent is obsolete! (0d3f46688ccc) $ hg evolve parent is obsolete with multiple successors: [4] add obsol_c' @@ -704,8 +704,8 @@ $ hg up --hidden 2 1 files updated, 0 files merged, 1 files removed, 0 files unresolved - working directory parent is obsolete! - (use 'hg evolve' to update to its successor) + working directory parent is obsolete! (4538525df7e2) + (4538525df7e2 has diverged, use 'hg evolve -list --divergent' to resolve the issue) $ hg export 9468a5f5d8b2 | hg import - applying patch from stdin 1 new unstable changesets
--- a/tests/test-stabilize-result.t Fri Apr 28 15:29:32 2017 +0200 +++ b/tests/test-stabilize-result.t Fri Apr 28 16:57:41 2017 +0200 @@ -222,8 +222,8 @@ $ hg amend $ hg up --hidden 15 1 files updated, 0 files merged, 0 files removed, 0 files unresolved - working directory parent is obsolete! - (use 'hg evolve' to update to its successor) + working directory parent is obsolete! (3932c176bbaa) + (use 'hg evolve' to update to its successor: d2f173e25686) $ mv a a.old $ echo 'jungle' > a $ cat a.old >> a @@ -335,8 +335,8 @@ $ hg up --hidden 15 1 files updated, 0 files merged, 0 files removed, 0 files unresolved - working directory parent is obsolete! - (use 'hg evolve' to update to its successor) + working directory parent is obsolete! (3932c176bbaa) + (use 'hg evolve' to update to its successor: f344982e63c4) $ echo 'gotta break' >> a $ hg amend 2 new divergent changesets
--- a/tests/test-touch.t Fri Apr 28 15:29:32 2017 +0200 +++ b/tests/test-touch.t Fri Apr 28 16:57:41 2017 +0200 @@ -33,8 +33,8 @@ $ hg commit -m ab --amend $ hg up --hidden 1 0 files updated, 0 files merged, 1 files removed, 0 files unresolved - working directory parent is obsolete! - (use 'hg evolve' to update to its successor) + working directory parent is obsolete! (*) (glob) + (use 'hg evolve' to update to its successor: *) (glob) $ hg log -G o 3:[0-9a-f]{12} ab (re)
--- a/tests/test-tutorial.t Fri Apr 28 15:29:32 2017 +0200 +++ b/tests/test-tutorial.t Fri Apr 28 16:57:41 2017 +0200 @@ -741,15 +741,15 @@ pulling from $TESTTMP/local (glob) searching for changes no changes found - working directory parent is obsolete! - (use 'hg evolve' to update to its successor) + working directory parent is obsolete! (bf1b0d202029) + (use 'hg evolve' to update to its successor: ee942144f952) now let's see where we are, and update to the successor $ hg parents bf1b0d202029 (draft): animals - working directory parent is obsolete! - (use 'hg evolve' to update to its successor) + working directory parent is obsolete! (bf1b0d202029) + (use 'hg evolve' to update to its successor: ee942144f952) $ hg evolve update:[8] animals 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
--- a/tests/test-uncommit.t Fri Apr 28 15:29:32 2017 +0200 +++ b/tests/test-uncommit.t Fri Apr 28 16:57:41 2017 +0200 @@ -239,8 +239,8 @@ $ hg up -C 3 --hidden 8 files updated, 0 files merged, 1 files removed, 0 files unresolved (leaving bookmark touncommit-bm) - working directory parent is obsolete! - (use 'hg evolve' to update to its successor) + working directory parent is obsolete! (5eb72dbe0cb4) + (use 'hg evolve' to update to its successor: e8db4aa611f6) $ hg --config extensions.purge= purge $ hg uncommit -I 'set:added() and e' 2 new divergent changesets @@ -285,8 +285,8 @@ $ hg up -C 3 --hidden 1 files updated, 0 files merged, 0 files removed, 0 files unresolved - working directory parent is obsolete! - (use 'hg evolve' to update to its successor) + working directory parent is obsolete! (5eb72dbe0cb4) + (5eb72dbe0cb4 has diverged, use 'hg evolve -list --divergent' to resolve the issue) $ hg --config extensions.purge= purge $ hg uncommit --all -X e 1 new divergent changesets