comparison hgext3rd/topic/discovery.py @ 6369:3271ec128328

branching: merge with stable
author Anton Shestakov <av6@dwimlabs.net>
date Tue, 17 Jan 2023 17:54:24 +0400
parents 453861da6922 e8d85d51c7b2
children 3d0b5b4b262a
comparison
equal deleted inserted replaced
6368:7434edba87a0 6369:3271ec128328
28 28
29 @contextlib.contextmanager 29 @contextlib.contextmanager
30 def override_context_branch(repo, publishedset=()): 30 def override_context_branch(repo, publishedset=()):
31 unfi = repo.unfiltered() 31 unfi = repo.unfiltered()
32 32
33 def overridebranch(p, origbranch):
34 def branch():
35 branch = origbranch()
36 if p.rev() in publishedset:
37 return common.formatfqbn(branch=branch)
38 return p.fqbn()
39 return branch
40
33 class repocls(unfi.__class__): 41 class repocls(unfi.__class__):
34 # awful hack to see branch as "branch//namespace/topic" 42 # awful hack to see branch as "branch//namespace/topic"
35 def __getitem__(self, key): 43 def __getitem__(self, key):
36 ctx = super(repocls, self).__getitem__(key) 44 ctx = super(repocls, self).__getitem__(key)
37 oldbranch = ctx.branch 45 oldbranch = ctx.branch
47 def parents(): 55 def parents():
48 parents = oldparents() 56 parents = oldparents()
49 for p in parents: 57 for p in parents:
50 if getattr(p, '_topic_ext_branch_hack', False): 58 if getattr(p, '_topic_ext_branch_hack', False):
51 continue 59 continue
52 pbranch = p.branch 60
53 61 p.branch = overridebranch(p, p.branch)
54 def branch():
55 branch = pbranch()
56 if p.rev() in publishedset:
57 return common.formatfqbn(branch=branch)
58 return p.fqbn()
59 p.branch = branch
60 p._topic_ext_branch_hack = True 62 p._topic_ext_branch_hack = True
61 return parents 63 return parents
62 64
63 ctx.branch = branch 65 ctx.branch = branch
64 ctx.parents = parents 66 ctx.parents = parents