diff hgext3rd/topic/topicmap.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 3271ec128328
children 0bc90758f613
line wrap: on
line diff
--- a/hgext3rd/topic/topicmap.py	Mon Jan 30 19:19:52 2023 +0400
+++ b/hgext3rd/topic/topicmap.py	Thu Dec 15 15:44:39 2022 +0400
@@ -14,6 +14,7 @@
 from . import (
     common,
     compat,
+    discovery,
 )
 
 basefilter = set([b'base', b'immutable'])
@@ -98,10 +99,12 @@
 def commitstatus(orig, repo, node, branch, bheads=None, tip=None, opts=None):
     # wrap commit status use the topic branch heads
     ctx = repo[node]
-    if ctx.topic() and ctx.branch() == branch:
+    ctxbranch = common.formatfqbn(branch=ctx.branch())
+    if ctx.topic() and ctxbranch == branch:
         bheads = repo.branchheads(b"%s:%s" % (branch, ctx.topic()))
 
-    ret = orig(repo, node, branch, bheads=bheads, tip=tip, opts=opts)
+    with discovery.override_context_branch(repo) as repo:
+        ret = orig(repo, node, branch, bheads=bheads, tip=tip, opts=opts)
 
     # logic copy-pasted from cmdutil.commitstatus()
     if opts is None:
@@ -111,7 +114,8 @@
     parents = ctx.parents()
 
     if (not opts.get(b'amend') and bheads and node not in bheads and not any(
-        p.node() in bheads and p.branch() == branch for p in parents
+        p.node() in bheads and common.formatfqbn(branch=p.branch()) == branch
+        for p in parents
     )):
         repo.ui.status(_(b"(consider using topic for lightweight branches."
                          b" See 'hg help topic')\n"))