comparison hgext3rd/topic/discovery.py @ 5623:fe31179e1941 stable

branching: merge into stable in preparation for release
author Anton Shestakov <av6@dwimlabs.net>
date Sat, 31 Oct 2020 17:25:32 +0800
parents 36ccafa69095
children 1dece375d2ab
comparison
equal deleted inserted replaced
5622:71cc223fd109 5623:fe31179e1941
8 bundle2, 8 bundle2,
9 discovery, 9 discovery,
10 error, 10 error,
11 exchange, 11 exchange,
12 extensions, 12 extensions,
13 scmutil,
13 util, 14 util,
14 ) 15 )
15 from . import ( 16 from . import (
16 common, 17 common,
17 compat, 18 compat,
184 for b in repo.branchmap().iterbranches(): 185 for b in repo.branchmap().iterbranches():
185 if b':' in b[0]: 186 if b':' in b[0]:
186 continue 187 continue
187 oldheads = [repo[n].rev() for n in b[1]] 188 oldheads = [repo[n].rev() for n in b[1]]
188 newheads = _filter_obsolete_heads(repo, oldheads) 189 newheads = _filter_obsolete_heads(repo, oldheads)
189 data[b[0]] = len(newheads) 190 data[b[0]] = newheads
190 return data 191 return data
191 192
192 def handlecheckheads(orig, op, inpart): 193 def handlecheckheads(orig, op, inpart):
193 """This is used to check for new heads when publishing changeset""" 194 """This is used to check for new heads when publishing changeset"""
194 orig(op, inpart) 195 orig(op, inpart)
209 repo = reporef() 210 repo = reporef()
210 if repo is not None: 211 if repo is not None:
211 repo.invalidatecaches() 212 repo.invalidatecaches()
212 finalheads = _nbheads(repo) 213 finalheads = _nbheads(repo)
213 for branch, oldnb in tr._prepushheads.items(): 214 for branch, oldnb in tr._prepushheads.items():
214 newnb = finalheads.pop(branch, 0) 215 newheads = finalheads.pop(branch, [])
215 if oldnb < newnb: 216 if len(oldnb) < len(newheads):
216 msg = _(b'push create a new head on branch "%s"' % branch) 217 cl = repo.changelog
218 newheads = sorted(set(newheads).difference(oldnb))
219 heads = scmutil.nodesummaries(repo, [cl.node(r) for r in newheads])
220 msg = _(
221 b"push creates new heads on branch '%s': %s"
222 % (branch, heads)
223 )
217 raise error.Abort(msg) 224 raise error.Abort(msg)
218 for branch, newnb in finalheads.items(): 225 for branch, newnb in finalheads.items():
219 if 1 < newnb: 226 if 1 < len(newnb):
220 msg = _(b'push create more than 1 head on new branch "%s"' 227 cl = repo.changelog
221 % branch) 228 heads = scmutil.nodesummaries(repo, [cl.node(r) for r in newnb])
222 raise error.Abort(msg) 229 msg = _(
230 b"push creates new branch '%s' with multiple heads: %s"
231 % (branch, heads)
232 )
233 hint = _(b"merge or see 'hg help push' for details about "
234 b"pushing new heads")
235 raise error.Abort(msg, hint=hint)
223 236
224 def validator(tr): 237 def validator(tr):
225 _validate(tr) 238 _validate(tr)
226 return oldvalidator(tr) 239 return oldvalidator(tr)
227 240