# HG changeset patch # User Pulkit Goyal <7895pulkit@gmail.com> # Date 1521186201 -19800 # Node ID ce346c6165c66e9649abc847496ba87dcb2fccde # Parent 78d3ba4e17ac1b0d7df5ff5db664f0385adb474f prev: prompt user to choose parent in case of multiple parents This patch adds functionality to `hg prev` to prompt user to choose one parent to update when multiple parents exist. Surprisingly there were no tests for this case before this patch, I added one with this patch. diff -r 78d3ba4e17ac -r ce346c6165c6 hgext3rd/evolve/__init__.py --- a/hgext3rd/evolve/__init__.py Fri Mar 16 12:48:03 2018 +0530 +++ b/hgext3rd/evolve/__init__.py Fri Mar 16 13:13:21 2018 +0530 @@ -1008,9 +1008,15 @@ if movebookmark: bookmark = repo._activebookmark else: - for p in parents: - displayer.show(p) - repo.ui.warn(_('multiple parents, explicitly update to one\n')) + header = _("multiple parents, choose one to update:") + prevs = [p.rev() for p in parents] + choosedrev = utility.revselectionprompt(repo.ui, repo, prevs, header) + if choosedrev is None: + for p in parents: + displayer.show(p) + repo.ui.warn(_('multiple parents, explicitly update to one\n')) + else: + target = repo[choosedrev] return target, bookmark @eh.command( diff -r 78d3ba4e17ac -r ce346c6165c6 tests/test-prev-next.t --- a/tests/test-prev-next.t Fri Mar 16 12:48:03 2018 +0530 +++ b/tests/test-prev-next.t Fri Mar 16 13:13:21 2018 +0530 @@ -264,6 +264,64 @@ atop:[6] added b (3) working directory is now at 47ea25be8aea +prev with multiple parents + + $ hg log -GT "{rev}:{node|short} {desc}\n" + @ 8:47ea25be8aea added d + | + | o 7:5ce67c2407b0 added c + |/ + o 6:d7f119adc759 added b (3) + | + o 0:a154386e50d1 added a + + $ hg merge -r 5ce67c2407b0 + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + (branch merge, don't forget to commit) + $ hg ci -m "merge commit" + + $ hg prev < q + > EOF + multiple parents, choose one to update: + 0: [47ea25be8aea] added d + 1: [5ce67c2407b0] added c + q: quit the prompt + enter the index of the revision you want to select: q + [8] added d + [7] added c + multiple parents, explicitly update to one + [1] + + $ hg prev --config ui.interactive=False + [8] added d + [7] added c + multiple parents, explicitly update to one + [1] + + $ hg prev < 1 + > EOF + multiple parents, choose one to update: + 0: [47ea25be8aea] added d + 1: [5ce67c2407b0] added c + q: quit the prompt + enter the index of the revision you want to select: 1 + 0 files updated, 0 files merged, 1 files removed, 0 files unresolved + [7] added c + + $ hg log -GT "{rev}:{node|short} {desc}\n" + o 9:a4b8c25a87d3 merge commit + |\ + | o 8:47ea25be8aea added d + | | + @ | 7:5ce67c2407b0 added c + |/ + o 6:d7f119adc759 added b (3) + | + o 0:a154386e50d1 added a + + $ cd .. prev and next should lock properly against other commands