Mercurial > evolve
changeset 5884:21a8f0336f26 stable
next: treat targets that need evolution the same as regular targets
Unless --no-evolve is given.
In case when there's only one stable child that otherwise fits perfectly as a
hg next target, but there are also unstable children on the current topic and
we are allowed to evolve them, hg next should treat them as targets too and
give a prompt to select the revision to update to. With this patch it does.
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Thu, 22 Apr 2021 17:19:01 +0800 |
parents | 24bfb5c7bf7a |
children | 35d0fdb223f3 |
files | hgext3rd/evolve/__init__.py tests/test-topic-prev-next.t |
diffstat | 2 files changed, 177 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/evolve/__init__.py Thu Apr 22 17:18:37 2021 +0800 +++ b/hgext3rd/evolve/__init__.py Thu Apr 22 17:19:01 2021 +0800 @@ -885,17 +885,17 @@ else: cmdutil.bailifchanged(repo, hint=_(b'do you want --merge?')) - if len(children) == 1: + if len(children) == 1 and (not opts['evolve'] or not aspchildren): c = children[0] return _updatetonext(ui, repo, c, display, opts) elif children: cheader = _(b"ambiguous next changeset, choose one to update:") - crevs = [c.rev() for c in children] + crevs = [c.rev() for c in children] + aspchildren selectedrev = utility.revselectionprompt(ui, repo, crevs, cheader) if selectedrev is None: ui.warn(_(b"ambiguous next changeset:\n")) - for c in children: - display(c) + for rev in crevs: + display(repo[rev]) ui.warn(_(b"explicitly update to one of them\n")) return 1 else:
--- a/tests/test-topic-prev-next.t Thu Apr 22 17:18:37 2021 +0800 +++ b/tests/test-topic-prev-next.t Thu Apr 22 17:19:01 2021 +0800 @@ -8,6 +8,179 @@ > logtemplate = '{rev} [{topic}] {desc}\n' > EOF +Checking target ambiguity in hg next + + $ hg init ambiguous-next + $ cd ambiguous-next + + $ mkcommit root + $ hg topic A + marked working directory as topic: A + $ mkcommit A1 + active topic 'A' grew its first changeset + (see 'hg help topics' for more information) + $ mkcommit A2 + $ mkcommit A3 + $ mkcommit A4 + $ hg up 'desc("A3")' + 0 files updated, 0 files merged, 1 files removed, 0 files unresolved + $ mkcommit A5 + $ hg up 'desc("A2")' + 0 files updated, 0 files merged, 2 files removed, 0 files unresolved + $ hg topic B + $ mkcommit B1 + active topic 'B' grew its first changeset + (see 'hg help topics' for more information) + $ mkcommit B2 + + $ hg log -G + @ 7 [B] B2 + | + o 6 [B] B1 + | + | o 5 [A] A5 + | | + | | o 4 [A] A4 + | |/ + | o 3 [A] A3 + |/ + o 2 [A] A2 + | + o 1 [A] A1 + | + o 0 [] root + + +Quick sanity check + + $ hg up 'desc("A1")' + switching to topic A + 0 files updated, 0 files merged, 3 files removed, 0 files unresolved + $ hg next + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + [s2] A2 + $ hg stack + ### topic: A (2 heads) + ### target: default (branch) + s5: A4 + s3^ A3 (base) + s4: A5 + s3: A3 + s2@ A2 (current) + s1: A1 + s0^ root (base) + $ hg next + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + [s3] A3 + $ hg log -G + o 7 [B] B2 + | + o 6 [B] B1 + | + | o 5 [A] A5 + | | + | | o 4 [A] A4 + | |/ + | @ 3 [A] A3 + |/ + o 2 [A] A2 + | + o 1 [A] A1 + | + o 0 [] root + + $ hg next + ambiguous next changeset: + [s5] A4 + [s4] A5 + explicitly update to one of them + [1] + +Let's make some changesets unstable + + $ hg up 'desc("A2")' + 0 files updated, 0 files merged, 1 files removed, 0 files unresolved + $ echo foo > A2 + $ hg amend + 5 new orphan changesets + $ hg stack + ### topic: A (2 heads) + ### target: default (branch) + s5$ A4 (orphan) + s3^ A3 (base orphan) + s4$ A5 (orphan) + s3$ A3 (orphan) + s2@ A2 (current) + s1: A1 + s0^ root (base) + $ hg log -G + @ 8 [A] A2 + | + | * 7 [B] B2 + | | + | * 6 [B] B1 + | | + | | * 5 [A] A5 + | | | + | | | * 4 [A] A4 + | | |/ + | | * 3 [A] A3 + | |/ + | x 2 [A] A2 + |/ + o 1 [A] A1 + | + o 0 [] root + + +B1 shouldn't be considered a target, orphan or not + + $ hg next + move:[s3] A3 + atop:[s2] A2 + working directory is now at 2b67b6a6cae1 + +B1 is not considered a target when it's been stabilized + + $ hg up 'desc("A2")' + 0 files updated, 0 files merged, 1 files removed, 0 files unresolved + $ hg evolve --rev 'desc("B1")' + move:[6] B1 + atop:[8] A2 + switching to topic A + $ hg next + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + [s3] A3 + +A4 and A5 should be ambiguous for hg next even if A5 is an orphan and A4 is not + + $ hg evolve --rev 'desc("A3") + desc("A4")' + move:[s5] A4 + atop:[s3] A3 + $ hg up 'desc("A3")' + 0 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ hg stack + ### topic: A (2 heads) + ### target: default (branch) + s5: A4 + s3^ A3 (base current) + s4$ A5 (orphan) + s3@ A3 (current) + s2: A2 + s1: A1 + s0^ root (base) + $ hg next --no-evolve --dry-run + hg update 51d70e81d730; + [s5] A4 + $ hg next + ambiguous next changeset: + [s5] A4 + [s4] A5 + explicitly update to one of them + [1] + + $ cd .. + Making sure plain hg next sticks to topic when target is unstable $ hg init next-unstable-topic