Mercurial > evolve
changeset 6099:435dfa125d89
picksplitsuccessor: refactor and rename this method for better quality
This patch modify the prompt message and make it more generic by removing the
`evolvecand` param, which would help us in using this method at other places
as well.
author | Sushil khanchi <sushilkhanchi97@gmail.com> |
---|---|
date | Tue, 27 Jul 2021 23:32:47 +0530 |
parents | 442771901e01 |
children | 46858e6f8b99 |
files | hgext3rd/evolve/evolvecmd.py hgext3rd/evolve/utility.py tests/test-evolve-issue5832.t tests/test-evolve-orphan-split.t |
diffstat | 4 files changed, 22 insertions(+), 36 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/evolve/evolvecmd.py Fri Dec 03 10:46:49 2021 +0300 +++ b/hgext3rd/evolve/evolvecmd.py Tue Jul 27 23:32:47 2021 +0530 @@ -133,14 +133,14 @@ ui.write_err(msg) return (False, b".") if exc.splitflag: - splitsucc = utility.picksplitsuccessor(ui, repo, obs, orig) - if not splitsucc[0]: + splitsucc = utility.select_split_successor(ui, repo, obs) + if not splitsucc: msg = _(b"could not solve instability, " b"ambiguous destination: " b"parent split across two branches\n") ui.write_err(msg) return (False, b".") - newer = splitsucc[1] + newer = splitsucc target = repo[newer] if not ui.quiet or confirm: repo.ui.write(_(b'move:'), label=b'evolve.operation')
--- a/hgext3rd/evolve/utility.py Fri Dec 03 10:46:49 2021 +0300 +++ b/hgext3rd/evolve/utility.py Tue Jul 27 23:32:47 2021 +0530 @@ -128,32 +128,28 @@ return repo[newer[0][0]].rev() -def picksplitsuccessor(ui, repo, ctx, evolvecand): - """choose a successor of ctx from split targets +def select_split_successor(ui, repo, ctx): + """Return most suitable split successor of <ctx> for evolution. - Choose highest one if all successors are in a topological branch. And if - they are split over multiple topological branches, we ask user to choose - an evolve destination. + If all successors are on one topological branch, we choose tipmost successor. + Otherwise, we ask user to choose an evolve destination. - Return (True, succ) unless split targets are split over multiple - topological branches and user didn't choose any evolve destination, - in which case return (False, '.') + Return ``None`` if no successor selected. """ targets = obsutil.successorssets(repo, ctx.node())[0] assert targets targetrevs = [repo[r].rev() for r in targets] heads = repo.revs(b'heads(%ld::%ld)', targetrevs, targetrevs) if len(heads) > 1: - cheader = (_(b"ancestor of '%s' split over multiple topological" - b" branches.\nchoose an evolve destination:") % - evolvecand) + cheader = (_(b"changeset %s split over multiple topological" + b" branches, choose an evolve destination:") % ctx) selectedrev = revselectionprompt(ui, repo, list(heads), cheader) if selectedrev is None: - return (False, '.') + return succ = repo[selectedrev] else: succ = repo[heads.first()] - return (True, repo[succ].rev()) + return repo[succ].rev() def _successorrevs(repo, ctx): try:
--- a/tests/test-evolve-issue5832.t Fri Dec 03 10:46:49 2021 +0300 +++ b/tests/test-evolve-issue5832.t Tue Jul 27 23:32:47 2021 +0530 @@ -117,8 +117,7 @@ move:[2] added b atop:[5] added a move:[4] merge commit - ancestor of '7235ef625ea3' split over multiple topological branches. - choose an evolve destination: + changeset 9402371b436e split over multiple topological branches, choose an evolve destination: 1: [62fb70414f99] added c 2: [5841d7cf9893] added d q: quit the prompt @@ -257,8 +256,7 @@ move:[2] added b atop:[6] added a move:[4] merge commit - ancestor of 'cdf2ea1b9312' split over multiple topological branches. - choose an evolve destination: + changeset 9402371b436e split over multiple topological branches, choose an evolve destination: 1: [62fb70414f99] added c 2: [5841d7cf9893] added d q: quit the prompt @@ -402,8 +400,7 @@ > EOF move:[2] added b atop:[6] added a - ancestor of 'b9b387427a53' split over multiple topological branches. - choose an evolve destination: + changeset 9402371b436e split over multiple topological branches, choose an evolve destination: 1: [62fb70414f99] added c 2: [5841d7cf9893] added d q: quit the prompt
--- a/tests/test-evolve-orphan-split.t Fri Dec 03 10:46:49 2021 +0300 +++ b/tests/test-evolve-orphan-split.t Tue Jul 27 23:32:47 2021 +0530 @@ -193,8 +193,7 @@ $ hg evolve --dry-run <<EOF > 1 > EOF - ancestor of 'd48a30875f01' split over multiple topological branches. - choose an evolve destination: + changeset f89e4764f2ed split over multiple topological branches, choose an evolve destination: 1: [f2632392aefe] added a b c 2: [7f87764e5b64] added a b c q: quit the prompt @@ -206,8 +205,7 @@ $ hg evolve --dry-run <<EOF > 2 > EOF - ancestor of 'd48a30875f01' split over multiple topological branches. - choose an evolve destination: + changeset f89e4764f2ed split over multiple topological branches, choose an evolve destination: 1: [f2632392aefe] added a b c 2: [7f87764e5b64] added a b c q: quit the prompt @@ -222,8 +220,7 @@ $ hg evolve --all <<EOF > foo > EOF - ancestor of 'd48a30875f01' split over multiple topological branches. - choose an evolve destination: + changeset f89e4764f2ed split over multiple topological branches, choose an evolve destination: 1: [f2632392aefe] added a b c 2: [7f87764e5b64] added a b c q: quit the prompt @@ -234,8 +231,7 @@ $ hg evolve --all <<EOF > 4 > EOF - ancestor of 'd48a30875f01' split over multiple topological branches. - choose an evolve destination: + changeset f89e4764f2ed split over multiple topological branches, choose an evolve destination: 1: [f2632392aefe] added a b c 2: [7f87764e5b64] added a b c q: quit the prompt @@ -246,8 +242,7 @@ $ hg evolve --all <<EOF > -1 > EOF - ancestor of 'd48a30875f01' split over multiple topological branches. - choose an evolve destination: + changeset f89e4764f2ed split over multiple topological branches, choose an evolve destination: 1: [f2632392aefe] added a b c 2: [7f87764e5b64] added a b c q: quit the prompt @@ -258,8 +253,7 @@ $ hg evolve --all <<EOF > q > EOF - ancestor of 'd48a30875f01' split over multiple topological branches. - choose an evolve destination: + changeset f89e4764f2ed split over multiple topological branches, choose an evolve destination: 1: [f2632392aefe] added a b c 2: [7f87764e5b64] added a b c q: quit the prompt @@ -271,8 +265,7 @@ $ hg evolve --all <<EOF > 1 > EOF - ancestor of 'd48a30875f01' split over multiple topological branches. - choose an evolve destination: + changeset f89e4764f2ed split over multiple topological branches, choose an evolve destination: 1: [f2632392aefe] added a b c 2: [7f87764e5b64] added a b c q: quit the prompt