Mercurial > public > mercurial-scm > evolve
diff hgext3rd/topic/__init__.py @ 6376:5c8196a550b6
topic: make hg stack work for branches with double slashes in them
Other commands are likely affected as well.
Things to note: we're using FQBN-formatted branch instead of full
branch//namespace/topic in the workingctx.dirty() check because otherwise, if
you had no topic active and were trying to update to a topic, wdir would be
considered to be dirty and update would abort (same with unset topic namespace
and trying to update to a changeset with topic namespace set). With just a bare
branch, this doesn't happen, because you can't deactivate a branch. This is
caught by test-topic.t.
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Thu, 15 Dec 2022 15:44:39 +0400 |
parents | 573174ef1bbf |
children | faea18a26188 bbf93745dc54 |
line wrap: on
line diff
--- a/hgext3rd/topic/__init__.py Mon Jan 30 19:19:52 2023 +0400 +++ b/hgext3rd/topic/__init__.py Thu Dec 15 15:44:39 2022 +0400 @@ -410,6 +410,26 @@ with discovery.override_context_branch(repo) as repo: return orig(ui, repo, *args, **kwargs) +def wrapwctxbranch(orig, self): + branch = orig(self) + return common.formatfqbn(branch=branch) + +def wrapwctxdirty(orig, self, missing=False, merge=True, branch=True): + """check whether a working directory is modified""" + # check subrepos first + for s in sorted(self.substate): + if self.sub(s).dirty(missing=missing): + return True + # check current working dir + return ( + (merge and self.p2()) + or (branch and self.branch() != common.formatfqbn(branch=self.p1().branch())) + or self.modified() + or self.added() + or self.removed() + or (missing and self.deleted()) + ) + def uisetup(ui): destination.modsetup(ui) discovery.modsetup(ui) @@ -458,6 +478,10 @@ # Wrap workingctx extra to return the topic name extensions.wrapfunction(context.workingctx, '__init__', wrapinit) + # Wrap workingctx.branch() to return branch name in the "//" format + extensions.wrapfunction(context.workingctx, 'branch', wrapwctxbranch) + # Wrap workingctx.dirty() to check branch//namespace/topic + extensions.wrapfunction(context.workingctx, 'dirty', wrapwctxdirty) # Wrap changelog.add to drop empty topic extensions.wrapfunction(changelog.changelog, 'add', wrapadd) # Make exchange._checkpublish handle experimental.topic.publish-bare-branch