Mercurial > evolve
changeset 6749:107c5af631a7 stable
topic: make debug-default-topic-namespace --clear slightly smarter
Now we don't have to run evolve too much after using this flag. Logic taken
directly from the `hg topic` command when it changes topic of multiple
changesets.
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Fri, 29 Mar 2024 15:02:02 -0300 |
parents | ab60707314e9 |
children | d0e2b0101bfc |
files | hgext3rd/topic/__init__.py tests/test-namespaces.t |
diffstat | 2 files changed, 12 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/topic/__init__.py Fri Mar 15 17:05:09 2024 -0300 +++ b/hgext3rd/topic/__init__.py Fri Mar 29 15:02:02 2024 -0300 @@ -1944,13 +1944,15 @@ revs = repo.revs(b'not public() and not obsolete() and (%lr)', condition) if opts[b'clear']: with repo.wlock(), repo.lock(), repo.transaction(b'debug-default-topic-namespace'): + successors = {} for rev in revs: - _clear_tns_extras(ui, repo, rev) + _clear_tns_extras(ui, repo, rev, successors) + scmutil.cleanupnodes(repo, successors, b'debug-default-topic-namespace') return displayer = logcmdutil.changesetdisplayer(ui, repo, opts) logcmdutil.displayrevs(ui, repo, revs, displayer, None) -def _clear_tns_extras(ui, repo, rev): +def _clear_tns_extras(ui, repo, rev, successors): ctx = repo[rev] if len(ctx.parents()) > 1: @@ -1972,6 +1974,10 @@ p1 = ctx.p1().node() p2 = ctx.p2().node() + if p1 in successors: + p1 = successors[p1][0] + if p2 in successors: + p2 = successors[p2][0] mc = context.memctx(repo, (p1, p2), ctx.description(), @@ -1985,8 +1991,7 @@ with repo.ui.configoverride(overrides, b'debug-default-topic-namespace'): newnode = repo.commitctx(mc) - replacements = {(ctx.node(),): (newnode,)} - scmutil.cleanupnodes(repo, replacements, b'debug-default-topic-namespace') + successors[ctx.node()] = (newnode,) @command(b'debug-parse-fqbn', commands.formatteropts, _(b'FQBN'), optionalrepo=True) def debugparsefqbn(ui, repo, fqbn, **opts):
--- a/tests/test-namespaces.t Fri Mar 15 17:05:09 2024 -0300 +++ b/tests/test-namespaces.t Fri Mar 29 15:02:02 2024 -0300 @@ -324,17 +324,15 @@ 5:16d6061fce0c branch=stable topic-namespace=default $ hg debug-default-topic-namespace --none --default --clear - 1 new orphan changesets $ hg debug-default-topic-namespace --none --default + $ hg evolve --config extensions.evolve= --list + $ hg evolve --config extensions.evolve= --any update:[7] tns=default 0 files updated, 0 files merged, 0 files removed, 0 files unresolved - working directory is now at 68ef84f4b0a2 - move:[7] tns=default - atop:[6] tns=none - working directory is now at ddeaa72064d4 + working directory is now at 38c9ea9d27a7 $ hg debug-default-topic-namespace --none --default