comparison 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
comparison
equal deleted inserted replaced
6375:fcbca44dd0df 6376:5c8196a550b6
12 ) 12 )
13 13
14 from . import ( 14 from . import (
15 common, 15 common,
16 compat, 16 compat,
17 discovery,
17 ) 18 )
18 19
19 basefilter = set([b'base', b'immutable']) 20 basefilter = set([b'base', b'immutable'])
20 def topicfilter(name): 21 def topicfilter(name):
21 """return a "topic" version of a filter level""" 22 """return a "topic" version of a filter level"""
96 return orig(self, other, *args, **kwargs) 97 return orig(self, other, *args, **kwargs)
97 98
98 def commitstatus(orig, repo, node, branch, bheads=None, tip=None, opts=None): 99 def commitstatus(orig, repo, node, branch, bheads=None, tip=None, opts=None):
99 # wrap commit status use the topic branch heads 100 # wrap commit status use the topic branch heads
100 ctx = repo[node] 101 ctx = repo[node]
101 if ctx.topic() and ctx.branch() == branch: 102 ctxbranch = common.formatfqbn(branch=ctx.branch())
103 if ctx.topic() and ctxbranch == branch:
102 bheads = repo.branchheads(b"%s:%s" % (branch, ctx.topic())) 104 bheads = repo.branchheads(b"%s:%s" % (branch, ctx.topic()))
103 105
104 ret = orig(repo, node, branch, bheads=bheads, tip=tip, opts=opts) 106 with discovery.override_context_branch(repo) as repo:
107 ret = orig(repo, node, branch, bheads=bheads, tip=tip, opts=opts)
105 108
106 # logic copy-pasted from cmdutil.commitstatus() 109 # logic copy-pasted from cmdutil.commitstatus()
107 if opts is None: 110 if opts is None:
108 opts = {} 111 opts = {}
109 if ctx.topic(): 112 if ctx.topic():
110 return ret 113 return ret
111 parents = ctx.parents() 114 parents = ctx.parents()
112 115
113 if (not opts.get(b'amend') and bheads and node not in bheads and not any( 116 if (not opts.get(b'amend') and bheads and node not in bheads and not any(
114 p.node() in bheads and p.branch() == branch for p in parents 117 p.node() in bheads and common.formatfqbn(branch=p.branch()) == branch
118 for p in parents
115 )): 119 )):
116 repo.ui.status(_(b"(consider using topic for lightweight branches." 120 repo.ui.status(_(b"(consider using topic for lightweight branches."
117 b" See 'hg help topic')\n")) 121 b" See 'hg help topic')\n"))
118 122
119 return ret 123 return ret