update: support updating to hidden cset if directaccess config is set
authorPulkit Goyal <7895pulkit@gmail.com>
Wed, 27 Dec 2017 00:14:00 +0530
changeset 35518 02fdb8c018aa
parent 35517 ba0fb0e33c3a
child 35519 31fe397f2bda
update: support updating to hidden cset if directaccess config is set This patch adds support for updating to a hidden changeset without using --hidden if `experimental.directacces=True` is set. The update command will print out a warning when updating to a hidden changeset saying: `updating to a hidden changeset <hash>` The warning is also printed when directaccess is not used and --hidden is passed which I think is good behaviour. Tests are added for the directaccess part and updated output of tests which have case of updating to hidden cset using `--hidden`. Differential Revision: https://phab.mercurial-scm.org/D1762
mercurial/commands.py
tests/test-directaccess.t
tests/test-log.t
tests/test-obsmarker-template.t
tests/test-obsolete.t
tests/test-rebase-obsolete.t
tests/test-update-branches.t
--- a/mercurial/commands.py	Tue Dec 26 22:54:45 2017 +0530
+++ b/mercurial/commands.py	Wed Dec 27 00:14:00 2017 +0530
@@ -5528,7 +5528,11 @@
 
         # if we defined a bookmark, we have to remember the original name
         brev = rev
-        rev = scmutil.revsingle(repo, rev, rev).rev()
+        repo = scmutil.unhidehashlikerevs(repo, [rev], 'nowarn')
+        ctx = scmutil.revsingle(repo, rev, rev)
+        rev = ctx.rev()
+        if ctx.hidden():
+            ui.warn(_("updating to a hidden changeset %s\n") % ctx.hex()[:12])
 
         repo.ui.setconfig('ui', 'forcemerge', tool, 'update')
 
--- a/tests/test-directaccess.t	Tue Dec 26 22:54:45 2017 +0530
+++ b/tests/test-directaccess.t	Wed Dec 27 00:14:00 2017 +0530
@@ -143,6 +143,15 @@
   $ hg status --change 28ad74
   A c
 
+`hg update`
+
+  $ hg up 28ad74
+  updating to a hidden changeset 28ad74487de9
+  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
+
 Commands with undefined cmdtype should not work right now
 
   $ hg phase -r 28ad74
--- a/tests/test-log.t	Tue Dec 26 22:54:45 2017 +0530
+++ b/tests/test-log.t	Wed Dec 27 00:14:00 2017 +0530
@@ -1824,6 +1824,7 @@
 test that parent prevent a changeset to be hidden
 
   $ hg up 1 -q --hidden
+  updating to a hidden changeset a765632148dc
   $ hg log --template='{rev}:{node}\n'
   1:a765632148dc55d38c35c4f247c618701886cb2f
   0:9f758d63dcde62d547ebfb08e1e7ee96535f2b05
--- a/tests/test-obsmarker-template.t	Tue Dec 26 22:54:45 2017 +0530
+++ b/tests/test-obsmarker-template.t	Wed Dec 27 00:14:00 2017 +0530
@@ -75,6 +75,7 @@
 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
 
 Predecessors template should show current revision as it is the working copy
@@ -146,6 +147,7 @@
      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
 
 Predecessors template should show current revision as it is the working copy
@@ -413,6 +415,7 @@
 ---------------
 
   $ hg up 'obsolete()' --hidden
+  updating to a hidden changeset 471597cad322
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 Predecessors template should show current revision as it is the working copy
@@ -620,6 +623,7 @@
 ---------------
 
   $ hg up 'desc(A0)' --hidden
+  updating to a hidden changeset 471f378eab4c
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
 
 Predecessors template should show current revision as it is the working copy
@@ -644,6 +648,7 @@
   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
 
 Predecessors template should show both predecessors as they should be both
@@ -809,6 +814,7 @@
      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
   $ hg commit --amend -m "A2"
   $ hg log --hidden -G
@@ -880,6 +886,7 @@
 ---------------
 
   $ hg up 'desc(A0)' --hidden
+  updating to a hidden changeset 471f378eab4c
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 Predecessors template should show current revision as it is the working copy
@@ -1144,6 +1151,7 @@
 ---------------
 
   $ hg up 'desc(A0)' --hidden
+  updating to a hidden changeset 471f378eab4c
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
 
 Predecessors template should show current revision as it is the working copy
@@ -1168,6 +1176,7 @@
   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
 
 Predecessors template should both predecessors as they are visible
@@ -1198,6 +1207,7 @@
   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
 
 Predecessors template should both predecessors as they are visible
@@ -1599,6 +1609,7 @@
   
 
   $ hg up -r "desc(B0)" --hidden
+  updating to a hidden changeset 0dec01379d3b
   2 files updated, 0 files merged, 1 files removed, 0 files unresolved
   $ hg tlog
   o  f897c6137566
@@ -2059,6 +2070,7 @@
   o  ea207398892e
   
   $ hg up --hidden 4
+  updating to a hidden changeset 9bd10a0775e4
   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"
@@ -2303,6 +2315,7 @@
   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
   $ hg commit --amend -m "A2"
   $ hg debugobsolete --record-parent `getid "."`
@@ -2312,6 +2325,7 @@
 ------------
 
   $ hg up "desc(A0)" --hidden
+  updating to a hidden changeset 471f378eab4c
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg tlog
   @  471f378eab4c
@@ -2465,6 +2479,7 @@
 ---------------
 
   $ hg up 'desc("A0")' --hidden
+  updating to a hidden changeset 471597cad322
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 # todo: the obsfate output is not ideal
@@ -2476,6 +2491,7 @@
   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
 
   $ hg fatelog --hidden
--- a/tests/test-obsolete.t	Tue Dec 26 22:54:45 2017 +0530
+++ b/tests/test-obsolete.t	Wed Dec 27 00:14:00 2017 +0530
@@ -62,6 +62,7 @@
   $ hg tip
   -1:000000000000 (public) [tip ] 
   $ hg up --hidden tip --quiet
+  updating to a hidden changeset 97b7c2d76b18
 
 Killing a single changeset with itself should fail
 (simple local safeguard)
--- a/tests/test-rebase-obsolete.t	Tue Dec 26 22:54:45 2017 +0530
+++ b/tests/test-rebase-obsolete.t	Wed Dec 27 00:14:00 2017 +0530
@@ -280,6 +280,7 @@
 even though it is hidden (until we're moved there).
 
   $ hg --hidden up -qr 'first(hidden())'
+  updating to a hidden changeset 42ccdea3bb16
   $ hg rebase --rev 13 --dest 15
   rebasing 13:98f6af4ee953 "C"
   $ hg log -G
@@ -610,6 +611,7 @@
 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
   $ echo J > J
   $ hg add J
@@ -725,6 +727,7 @@
   $ 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
   $ echo C > C
   $ hg add C
@@ -748,6 +751,7 @@
 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
   $ echo D > D
   $ hg add D
@@ -862,6 +866,7 @@
   $ 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
   $ echo "bar" > foo
   $ hg add foo
@@ -1595,6 +1600,7 @@
   $ rm .hg/localtags
 
   $ hg update -q $C --hidden
+  updating to a hidden changeset 7829726be4dc
   $ hg rebase -s $B -d $D
   rebasing 1:2ec65233581b "B"
   merging D
--- a/tests/test-update-branches.t	Tue Dec 26 22:54:45 2017 +0530
+++ b/tests/test-update-branches.t	Wed Dec 27 00:14:00 2017 +0530
@@ -520,6 +520,7 @@
 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
   $ hg book -f bm
   $ hg up
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
@@ -530,6 +531,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
   $ hg up 5
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved