evolve: add an `--update` flag to `hg evolve` command
This patch adds a new `--update` flag which defaults to True. The update flag
updates the working directory to the head of evolved revisions after `hg evolve`
command.
This flag can be used to not update your working directory after `hg evolve`
which has been one of the biggest feature request from fig team at Google. To
not update your working directory, the user can do `hg evolve --no-update`.
If the working directory get obsoleted by evolve command, it will update to the
successor.
This patch also adds some basic tests for the flag introduced.
--- a/hgext3rd/evolve/evolvecmd.py Thu May 24 02:02:11 2018 +0530
+++ b/hgext3rd/evolve/evolvecmd.py Thu May 24 17:50:02 2018 +0530
@@ -1032,9 +1032,14 @@
return opts
-def _cleanup(ui, repo, startnode, showprogress):
+def _cleanup(ui, repo, startnode, showprogress, shouldupdate):
if showprogress:
ui.progress(_('evolve'), None)
+
+ if not shouldupdate:
+ unfi = repo.unfiltered()
+ succ = utility._singlesuccessor(repo, unfi[startnode])
+ hg.updaterepo(repo, repo[succ].node(), False)
if repo['.'] != startnode:
ui.status(_('working directory is now at %s\n') % repo['.'])
@@ -1085,6 +1090,7 @@
('', 'orphan', False, _('solves only orphan changesets (default)')),
('a', 'all', False, _('evolve all troubled changesets related to the '
'current working directory and its descendants')),
+ ('', 'update', True, _('update to the head of evolved changesets')),
('c', 'continue', False, _('continue an interrupted evolution')),
('', 'stop', False, _('stop the interrupted evolution')),
('', 'abort', False, _('abort the interrupted evolution')),
@@ -1174,6 +1180,7 @@
revopt = opts['rev']
stopopt = opts['stop']
abortopt = opts['abort']
+ shouldupdate = opts['update']
troublecategories = ['phase_divergent', 'content_divergent', 'orphan']
specifiedcategories = [t.replace('_', '')
@@ -1299,7 +1306,7 @@
evolvestate['orphanmerge'] = False
progresscb()
- _cleanup(ui, repo, startnode, showprogress)
+ _cleanup(ui, repo, startnode, showprogress, shouldupdate)
def abortevolve(ui, repo, evolvestate):
""" logic for handling of `hg evolve --abort`"""
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-evolve-noupdate.t Thu May 24 17:50:02 2018 +0530
@@ -0,0 +1,126 @@
+Testing the `--no-update` flag to `hg evolve` command
+=====================================================
+
+There is an `--update` flag to `hg evolve` command which defaults to True. The
+`--update` flag updates to the head of the evolved revisions. If you dont want
+to change your working directory or update your working directory to its
+sucessor after hg evolve, `hg evolve --no-update` is the thing for you.
+
+This patch tests that flag.
+
+Setup
+-----
+
+ $ cat >> $HGRCPATH <<EOF
+ > [alias]
+ > glog = log -GT "{rev}:{node|short} {desc}\n ({bookmarks}) {phase}"
+ > [extensions]
+ > EOF
+ $ echo "evolve=$(echo $(dirname $TESTDIR))/hgext3rd/evolve/" >> $HGRCPATH
+
+ $ hg init stoprepo
+ $ cd stoprepo
+ $ echo ".*\.orig" > .hgignore
+ $ hg add .hgignore
+ $ hg ci -m "added hgignore"
+ $ for ch in a b c d; do echo foo > $ch; hg add $ch; hg ci -qm "added "$ch; done;
+
+ $ hg glog
+ @ 4:c41c793e0ef1 added d
+ | () draft
+ o 3:ca1b80f7960a added c
+ | () draft
+ o 2:b1661037fa25 added b
+ | () draft
+ o 1:c7586e2a9264 added a
+ | () draft
+ o 0:8fa14d15e168 added hgignore
+ () draft
+
+Making sure we stay where we were is current wdir parent is not obsoleted
+--------------------------------------------------------------------------
+
+ $ hg up .^^
+ 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
+ $ echo bar > b
+ $ hg amend
+ 2 new orphan changesets
+ $ hg glog
+ @ 5:7ed0642d644b added b
+ | () draft
+ | * 4:c41c793e0ef1 added d
+ | | () draft
+ | * 3:ca1b80f7960a added c
+ | | () draft
+ | x 2:b1661037fa25 added b
+ |/ () draft
+ o 1:c7586e2a9264 added a
+ | () draft
+ o 0:8fa14d15e168 added hgignore
+ () draft
+
+There is 'working directory is now at' message because it didnt changed
+ $ hg evolve --all --no-update
+ move:[3] added c
+ atop:[5] added b
+ move:[4] added d
+ atop:[6] added c
+
+ $ hg glog
+ o 7:b6b20b8eefdc added d
+ | () draft
+ o 6:7c46f743e62f added c
+ | () draft
+ @ 5:7ed0642d644b added b
+ | () draft
+ o 1:c7586e2a9264 added a
+ | () draft
+ o 0:8fa14d15e168 added hgignore
+ () draft
+
+Updating to successor when working directory parent is obsoleted by evolution
+-----------------------------------------------------------------------------
+
+ $ hg prev
+ 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+ [1] added a
+ $ echo bar > a
+ $ hg amend
+ 3 new orphan changesets
+ $ hg up 7ed0642d644b
+ 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+ $ hg glog
+ o 8:3d41537b44ca added a
+ | () draft
+ | * 7:b6b20b8eefdc added d
+ | | () draft
+ | * 6:7c46f743e62f added c
+ | | () draft
+ | @ 5:7ed0642d644b added b
+ | | () draft
+ | x 1:c7586e2a9264 added a
+ |/ () draft
+ o 0:8fa14d15e168 added hgignore
+ () draft
+
+ $ hg evolve --all --any --no-update
+ move:[5] added b
+ atop:[8] added a
+ move:[6] added c
+ atop:[9] added b
+ move:[7] added d
+ atop:[10] added c
+ working directory is now at 12c720cb3782
+
+ $ hg glog
+ o 11:a74d9f22ba3f added d
+ | () draft
+ o 10:958f5155e8cd added c
+ | () draft
+ @ 9:12c720cb3782 added b
+ | () draft
+ o 8:3d41537b44ca added a
+ | () draft
+ o 0:8fa14d15e168 added hgignore
+ () draft