changeset 37964:ea63a2004d09

update: print warning about hidden changeset after update When an attempt to update to a hidden changeset fails because the working copy is dirty, you may get a message like this: updating to a hidden changeset 343f6de32686 (hidden revision '343f6de32686' was rewritten as: 4ab941244072) abort: conflicting changes (commit or update --clean to discard changes) It's easy to miss the real error here. This patch moves the warning about the hidden changeset to after the update has happened. It changes the verb tense accordingly (and drops the "a" that I think it sounds better without). Of course, this means that the commit isn't actually hidden anymore when the message is printed. I think that's fine. Differential Revision: https://phab.mercurial-scm.org/D3479
author Martin von Zweigbergk <martinvonz@google.com>
date Mon, 07 May 2018 19:43:43 -0700
parents 7a97a622244d
children a8a7ccec1783
files mercurial/commands.py tests/test-directaccess.t tests/test-log.t tests/test-obshistory.t tests/test-obsmarker-template.t tests/test-obsolete.t tests/test-rebase-obsolete.t tests/test-update-branches.t
diffstat 8 files changed, 98 insertions(+), 75 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Fri Apr 27 01:35:00 2018 -0400
+++ b/mercurial/commands.py	Mon May 07 19:43:43 2018 -0700
@@ -5583,18 +5583,19 @@
             repo = scmutil.unhidehashlikerevs(repo, [rev], 'nowarn')
         ctx = scmutil.revsingle(repo, rev, rev)
         rev = ctx.rev()
-        if ctx.hidden():
+        hidden = ctx.hidden()
+        repo.ui.setconfig('ui', 'forcemerge', opts.get(r'tool'), 'update')
+
+        ret = hg.updatetotally(ui, repo, rev, brev, clean=clean,
+                               updatecheck=updatecheck)
+        if hidden:
             ctxstr = ctx.hex()[:12]
-            ui.warn(_("updating to a hidden changeset %s\n") % ctxstr)
+            ui.warn(_("updated to hidden changeset %s\n") % ctxstr)
 
             if ctx.obsolete():
                 obsfatemsg = obsutil._getfilteredreason(repo, ctxstr, ctx)
                 ui.warn("(%s)\n" % obsfatemsg)
-
-        repo.ui.setconfig('ui', 'forcemerge', opts.get(r'tool'), 'update')
-
-        return hg.updatetotally(ui, repo, rev, brev, clean=clean,
-                                updatecheck=updatecheck)
+        return ret
 
 @command('verify', [])
 def verify(ui, repo):
--- a/tests/test-directaccess.t	Fri Apr 27 01:35:00 2018 -0400
+++ b/tests/test-directaccess.t	Mon May 07 19:43:43 2018 -0700
@@ -156,9 +156,9 @@
 `hg update`
 
   $ hg up 28ad74
-  updating to a hidden changeset 28ad74487de9
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  updated to hidden changeset 28ad74487de9
   (hidden revision '28ad74487de9' was rewritten as: 2443a0e66469)
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
   $ hg up 3
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
--- a/tests/test-log.t	Fri Apr 27 01:35:00 2018 -0400
+++ b/tests/test-log.t	Mon May 07 19:43:43 2018 -0700
@@ -1943,7 +1943,7 @@
 test that parent prevent a changeset to be hidden
 
   $ hg up 1 -q --hidden
-  updating to a hidden changeset a765632148dc
+  updated to hidden changeset a765632148dc
   (hidden revision 'a765632148dc' is pruned)
   $ hg log --template='{rev}:{node}\n'
   1:a765632148dc55d38c35c4f247c618701886cb2f
--- a/tests/test-obshistory.t	Fri Apr 27 01:35:00 2018 -0400
+++ b/tests/test-obshistory.t	Mon May 07 19:43:43 2018 -0700
@@ -55,9 +55,9 @@
   (use --hidden to access hidden revisions)
   [255]
   $ hg update --hidden "desc(A0)"
-  updating to a hidden changeset 471f378eab4c
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  updated to hidden changeset 471f378eab4c
   (hidden revision '471f378eab4c' was rewritten as: 4ae3a4151de9)
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 Test output with pruned commit
 ==============================
@@ -118,9 +118,9 @@
   (use --hidden to access hidden revisions)
   [255]
   $ hg up --hidden -r 'desc(B0)'
-  updating to a hidden changeset 0dec01379d3b
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  updated to hidden changeset 0dec01379d3b
   (hidden revision '0dec01379d3b' is pruned)
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 Test output with splitted commit
 ================================
@@ -195,9 +195,9 @@
   (use --hidden to access hidden revisions)
   [255]
   $ hg update --hidden 'min(desc(A0))'
-  updating to a hidden changeset 471597cad322
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  updated to hidden changeset 471597cad322
   (hidden revision '471597cad322' was split as: 337fec4d2edc, f257fde29c7a)
-  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 Test output with lots of splitted commit
 ========================================
@@ -294,9 +294,9 @@
   (use --hidden to access hidden revisions)
   [255]
   $ hg update --hidden 'min(desc(A0))'
-  updating to a hidden changeset de7290d8b885
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  updated to hidden changeset de7290d8b885
   (hidden revision 'de7290d8b885' was split as: 337fec4d2edc, f257fde29c7a and 2 more)
-  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 Test output with folded commit
 ==============================
@@ -373,17 +373,17 @@
   (use --hidden to access hidden revisions)
   [255]
   $ hg update --hidden 'desc(A0)'
-  updating to a hidden changeset 471f378eab4c
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  updated to hidden changeset 471f378eab4c
   (hidden revision '471f378eab4c' was rewritten as: eb5a0daa2192)
-  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
   $ hg update 0dec01379d3b
   abort: hidden revision '0dec01379d3b' was rewritten as: eb5a0daa2192!
   (use --hidden to access hidden revisions)
   [255]
   $ hg update --hidden 'desc(B0)'
-  updating to a hidden changeset 0dec01379d3b
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  updated to hidden changeset 0dec01379d3b
   (hidden revision '0dec01379d3b' was rewritten as: eb5a0daa2192)
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 Test output with divergence
 ===========================
@@ -416,9 +416,9 @@
      summary:     ROOT
   
   $ hg update --hidden 'desc(A0)'
-  updating to a hidden changeset 471f378eab4c
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  updated to hidden changeset 471f378eab4c
   (hidden revision '471f378eab4c' was rewritten as: fdf9bde5129a)
-  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg commit --amend -m "A2"
   2 new content-divergent changesets
   $ hg log --hidden -G
@@ -456,9 +456,9 @@
   (use --hidden to access hidden revisions)
   [255]
   $ hg update --hidden 'desc(A0)'
-  updating to a hidden changeset 471f378eab4c
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  updated to hidden changeset 471f378eab4c
   (hidden revision '471f378eab4c' has diverged)
-  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 Test output with amended + folded commit
 ========================================
@@ -551,13 +551,13 @@
   (use --hidden to access hidden revisions)
   [255]
   $ hg update --hidden 'desc(A0)'
-  updating to a hidden changeset 471f378eab4c
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  updated to hidden changeset 471f378eab4c
   (hidden revision '471f378eab4c' was rewritten as: eb5a0daa2192)
-  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
   $ hg update --hidden 0dec01379d3b
-  updating to a hidden changeset 0dec01379d3b
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  updated to hidden changeset 0dec01379d3b
   (hidden revision '0dec01379d3b' was rewritten as: eb5a0daa2192)
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg update 0dec01379d3b
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg update --hidden 'desc(B0)'
--- a/tests/test-obsmarker-template.t	Fri Apr 27 01:35:00 2018 -0400
+++ b/tests/test-obsmarker-template.t	Mon May 07 19:43:43 2018 -0700
@@ -75,9 +75,9 @@
 Check templates
 ---------------
   $ hg up 'desc(A0)' --hidden
-  updating to a hidden changeset 471f378eab4c
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  updated to hidden changeset 471f378eab4c
   (hidden revision '471f378eab4c' was rewritten as: d004c8f274b9)
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 Predecessors template should show current revision as it is the working copy
   $ hg tlog
@@ -148,9 +148,9 @@
      summary:     ROOT
   
   $ hg up 'desc(A1)' --hidden
-  updating to a hidden changeset a468dc9b3633
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  updated to hidden changeset a468dc9b3633
   (hidden revision 'a468dc9b3633' was rewritten as: d004c8f274b9)
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 Predecessors template should show current revision as it is the working copy
   $ hg tlog
@@ -417,9 +417,9 @@
 ---------------
 
   $ hg up 'obsolete()' --hidden
-  updating to a hidden changeset 471597cad322
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  updated to hidden changeset 471597cad322
   (hidden revision '471597cad322' was split as: 337fec4d2edc, f257fde29c7a)
-  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 Predecessors template should show current revision as it is the working copy
   $ hg tlog
@@ -627,9 +627,9 @@
 ---------------
 
   $ hg up 'desc(A0)' --hidden
-  updating to a hidden changeset 471f378eab4c
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  updated to hidden changeset 471f378eab4c
   (hidden revision '471f378eab4c' was rewritten as: eb5a0daa2192)
-  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
 
 Predecessors template should show current revision as it is the working copy
   $ hg tlog
@@ -653,9 +653,9 @@
   o  ea207398892e
   
   $ hg up 'desc(B0)' --hidden
-  updating to a hidden changeset 0dec01379d3b
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  updated to hidden changeset 0dec01379d3b
   (hidden revision '0dec01379d3b' was rewritten as: eb5a0daa2192)
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 Predecessors template should show both predecessors as they should be both
 displayed
@@ -820,9 +820,9 @@
      summary:     ROOT
   
   $ hg update --hidden 'desc(A0)'
-  updating to a hidden changeset 471f378eab4c
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  updated to hidden changeset 471f378eab4c
   (hidden revision '471f378eab4c' was rewritten as: fdf9bde5129a)
-  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg commit --amend -m "A2"
   2 new content-divergent changesets
   $ hg log --hidden -G
@@ -894,9 +894,9 @@
 ---------------
 
   $ hg up 'desc(A0)' --hidden
-  updating to a hidden changeset 471f378eab4c
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  updated to hidden changeset 471f378eab4c
   (hidden revision '471f378eab4c' has diverged)
-  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 Predecessors template should show current revision as it is the working copy
   $ hg tlog
@@ -1161,9 +1161,9 @@
 ---------------
 
   $ hg up 'desc(A0)' --hidden
-  updating to a hidden changeset 471f378eab4c
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  updated to hidden changeset 471f378eab4c
   (hidden revision '471f378eab4c' was rewritten as: eb5a0daa2192)
-  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
 
 Predecessors template should show current revision as it is the working copy
   $ hg tlog
@@ -1187,9 +1187,9 @@
   o  ea207398892e
   
   $ hg up 'desc(B0)' --hidden
-  updating to a hidden changeset 0dec01379d3b
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  updated to hidden changeset 0dec01379d3b
   (hidden revision '0dec01379d3b' was rewritten as: eb5a0daa2192)
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 Predecessors template should both predecessors as they are visible
   $ hg tlog
@@ -1219,9 +1219,9 @@
   o  ea207398892e
   
   $ hg up 'desc(B1)' --hidden
-  updating to a hidden changeset b7ea6d14e664
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  updated to hidden changeset b7ea6d14e664
   (hidden revision 'b7ea6d14e664' was rewritten as: eb5a0daa2192)
-  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 Predecessors template should both predecessors as they are visible
   $ hg tlog
@@ -1623,9 +1623,9 @@
   
 
   $ hg up -r "desc(B0)" --hidden
-  updating to a hidden changeset 0dec01379d3b
+  2 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  updated to hidden changeset 0dec01379d3b
   (hidden revision '0dec01379d3b' is pruned)
-  2 files updated, 0 files merged, 1 files removed, 0 files unresolved
   $ hg tlog
   o  f897c6137566
   |    Predecessors: 2:0dec01379d3b
@@ -2087,9 +2087,9 @@
   o  ea207398892e
   
   $ hg up --hidden 4
-  updating to a hidden changeset 9bd10a0775e4
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  updated to hidden changeset 9bd10a0775e4
   (hidden revision '9bd10a0775e4' has diverged)
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg rebase -r 7 -d 8 --config extensions.rebase=
   rebasing 7:ba2ed02b0c9a "Add A,B,C"
   $ hg tlog
@@ -2333,9 +2333,9 @@
   obsoleted 1 changesets
 
   $ hg up -r "desc(A0)" --hidden
-  updating to a hidden changeset 471f378eab4c
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  updated to hidden changeset 471f378eab4c
   (hidden revision '471f378eab4c' is pruned)
-  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg commit --amend -m "A2"
   $ hg debugobsolete --record-parent `getid "."`
   obsoleted 1 changesets
@@ -2344,9 +2344,9 @@
 ------------
 
   $ hg up "desc(A0)" --hidden
-  updating to a hidden changeset 471f378eab4c
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  updated to hidden changeset 471f378eab4c
   (hidden revision '471f378eab4c' is pruned)
-  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg tlog
   @  471f378eab4c
   |
@@ -2499,9 +2499,9 @@
 ---------------
 
   $ hg up 'desc("A0")' --hidden
-  updating to a hidden changeset 471597cad322
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  updated to hidden changeset 471597cad322
   (hidden revision '471597cad322' is pruned)
-  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 # todo: the obsfate output is not ideal
   $ hg fatelog
@@ -2512,9 +2512,9 @@
   o  ea207398892e
   
   $ hg up -r 'desc("A2")' --hidden
-  updating to a hidden changeset 0d0ef4bdf70e
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  updated to hidden changeset 0d0ef4bdf70e
   (hidden revision '0d0ef4bdf70e' is pruned)
-  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
   $ hg fatelog --hidden
   @  0d0ef4bdf70e
--- a/tests/test-obsolete.t	Fri Apr 27 01:35:00 2018 -0400
+++ b/tests/test-obsolete.t	Mon May 07 19:43:43 2018 -0700
@@ -62,7 +62,7 @@
   $ hg tip
   -1:000000000000 (public) [tip ] 
   $ hg up --hidden tip --quiet
-  updating to a hidden changeset 97b7c2d76b18
+  updated to hidden changeset 97b7c2d76b18
   (hidden revision '97b7c2d76b18' is pruned)
 
 Killing a single changeset with itself should fail
--- a/tests/test-rebase-obsolete.t	Fri Apr 27 01:35:00 2018 -0400
+++ b/tests/test-rebase-obsolete.t	Mon May 07 19:43:43 2018 -0700
@@ -281,7 +281,7 @@
 even though it is hidden (until we're moved there).
 
   $ hg --hidden up -qr 'first(hidden())'
-  updating to a hidden changeset 42ccdea3bb16
+  updated to hidden changeset 42ccdea3bb16
   (hidden revision '42ccdea3bb16' is pruned)
   $ hg rebase --rev 13 --dest 15
   rebasing 13:98f6af4ee953 "C"
@@ -642,9 +642,9 @@
 Test hidden changesets in the rebase set (issue4504)
 
   $ hg up --hidden 9
-  updating to a hidden changeset 4bde274eefcf
+  3 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  updated to hidden changeset 4bde274eefcf
   (hidden revision '4bde274eefcf' was rewritten as: acd174b7ab39)
-  3 files updated, 0 files merged, 1 files removed, 0 files unresolved
   $ echo J > J
   $ hg add J
   $ hg commit -m J
@@ -764,9 +764,9 @@
   $ hg commit --amend -m B1
   $ hg commit --amend -m B2
   $ hg up --hidden 'desc(B0)'
-  updating to a hidden changeset a8b11f55fb19
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  updated to hidden changeset a8b11f55fb19
   (hidden revision 'a8b11f55fb19' was rewritten as: 261e70097290)
-  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ echo C > C
   $ hg add C
   $ hg commit -m C
@@ -790,9 +790,9 @@
 Even when the chain include missing node
 
   $ hg up --hidden 'desc(B0)'
-  updating to a hidden changeset a8b11f55fb19
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  updated to hidden changeset a8b11f55fb19
   (hidden revision 'a8b11f55fb19' was rewritten as: 261e70097290)
-  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
   $ echo D > D
   $ hg add D
   $ hg commit -m D
@@ -909,9 +909,9 @@
   $ hg add bar
   $ hg commit --amend -m "10'"
   $ hg up 10 --hidden
-  updating to a hidden changeset 121d9e3bc4c6
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  updated to hidden changeset 121d9e3bc4c6
   (hidden revision '121d9e3bc4c6' was rewritten as: 77d874d096a2)
-  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
   $ echo "bar" > foo
   $ hg add foo
   $ hg commit -m "bar foo"
@@ -1706,7 +1706,7 @@
   $ rm .hg/localtags
 
   $ hg update -q $C --hidden
-  updating to a hidden changeset 7829726be4dc
+  updated to hidden changeset 7829726be4dc
   (hidden revision '7829726be4dc' is pruned)
   $ hg rebase -s $B -d $D
   rebasing 1:2ec65233581b "B"
--- a/tests/test-update-branches.t	Fri Apr 27 01:35:00 2018 -0400
+++ b/tests/test-update-branches.t	Mon May 07 19:43:43 2018 -0700
@@ -516,11 +516,33 @@
   $ hg bookmarks
    * bm                        5:ff252e8273df
 
+Test that we abort before we warn about the hidden commit if the working
+directory is dirty
+  $ echo conflict > a
+  $ hg up --hidden 3
+  abort: uncommitted changes
+  (commit or update --clean to discard changes)
+  [255]
+
+Test that we still warn also when there are conflicts
+  $ hg up -m --hidden 3
+  merging a
+  warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
+  0 files updated, 0 files merged, 0 files removed, 1 files unresolved
+  use 'hg resolve' to retry unresolved file merges
+  (leaving bookmark bm)
+  updated to hidden changeset 6efa171f091b
+  (hidden revision '6efa171f091b' was rewritten as: d047485b3896)
+  [1]
+  $ hg revert -r . a
+  $ hg resolve -m
+  (no more unresolved files)
+
 Test that 4 is detected as the no-argument destination from 3 and also moves
 the bookmark with it
   $ hg up --quiet 0          # we should be able to update to 3 directly
   $ hg up --quiet --hidden 3 # but not implemented yet.
-  updating to a hidden changeset 6efa171f091b
+  updated to hidden changeset 6efa171f091b
   (hidden revision '6efa171f091b' was rewritten as: d047485b3896)
   $ hg book -f bm
   $ hg up
@@ -532,7 +554,7 @@
 Test that 5 is detected as a valid destination from 1
   $ hg up --quiet 0          # we should be able to update to 3 directly
   $ hg up --quiet --hidden 3 # but not implemented yet.
-  updating to a hidden changeset 6efa171f091b
+  updated to hidden changeset 6efa171f091b
   (hidden revision '6efa171f091b' was rewritten as: d047485b3896)
   $ hg up 5
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved