Mercurial > hg-stable
changeset 45144:c93dd9d9f1e6
discovery: change users of `outgoing.missingheads` to `outgoing.ancestorsof`
The attribute `missingheads` was recently renamed to `ancestorsof`, as it,
despite the old name, doesn’t contain the missing heads but the changesets that
were requested (including ancestors) for the outgoing operation.
Changing all the users enables to print a warning if the old name is used.
There is a good chance that some of the users are buggy because of the old name.
Changing them to use the new name makes it more obvious that they are buggy. All
users need to be reviewed for bugs. When sending patches for fixing them, the
change will be more obvious without having to explain again and again the
discrepancy of the old attribute name and what it actually contained.
author | Manuel Jacob <me@manueljacob.de> |
---|---|
date | Fri, 17 Jul 2020 09:20:48 +0200 |
parents | 5631b0116374 |
children | aea246bc04bd |
files | hgext/infinitepush/__init__.py mercurial/bundle2.py mercurial/changegroup.py mercurial/discovery.py mercurial/exchange.py mercurial/localrepo.py mercurial/repair.py mercurial/shelve.py mercurial/wireprotov1server.py |
diffstat | 9 files changed, 44 insertions(+), 40 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/infinitepush/__init__.py Wed Jul 15 11:38:54 2020 +0200 +++ b/hgext/infinitepush/__init__.py Fri Jul 17 09:20:48 2020 +0200 @@ -466,7 +466,7 @@ version = b'02' outgoing = discovery.outgoing( - bundlerepo, commonheads=bundleroots, missingheads=[unknownhead] + bundlerepo, commonheads=bundleroots, ancestorsof=[unknownhead] ) cgstream = changegroup.makestream(bundlerepo, outgoing, version, b'pull') cgstream = util.chunkbuffer(cgstream).read()
--- a/mercurial/bundle2.py Wed Jul 15 11:38:54 2020 +0200 +++ b/mercurial/bundle2.py Fri Jul 17 09:20:48 2020 +0200 @@ -1711,7 +1711,7 @@ b'nbchanges', b'%d' % cg.extras[b'clcount'], mandatory=False ) if opts.get(b'phases') and repo.revs( - b'%ln and secret()', outgoing.missingheads + b'%ln and secret()', outgoing.ancestorsof ): part.addparam( b'targetphase', b'%d' % phases.secret, mandatory=False @@ -1753,7 +1753,7 @@ # consume little memory (1M heads is 40MB) b) we don't want to send the # part if we don't have entries and knowing if we have entries requires # cache lookups. - for node in outgoing.missingheads: + for node in outgoing.ancestorsof: # Don't compute missing, as this may slow down serving. fnode = cache.getfnode(node, computemissing=False) if fnode is not None:
--- a/mercurial/changegroup.py Wed Jul 15 11:38:54 2020 +0200 +++ b/mercurial/changegroup.py Fri Jul 17 09:20:48 2020 +0200 @@ -1629,7 +1629,7 @@ repo = repo.unfiltered() commonrevs = outgoing.common csets = outgoing.missing - heads = outgoing.missingheads + heads = outgoing.ancestorsof # We go through the fast path if we get told to, or if all (unfiltered # heads have been requested (since we then know there all linkrevs will # be pulled by the client).
--- a/mercurial/discovery.py Wed Jul 15 11:38:54 2020 +0200 +++ b/mercurial/discovery.py Fri Jul 17 09:20:48 2020 +0200 @@ -93,20 +93,17 @@ excluded is the list of missing changeset that shouldn't be sent remotely. - missingheads is an alias to ancestorsof, but the name is wrong and it - will be removed - Some members are computed on demand from the heads, unless provided upfront by discovery.''' def __init__( - self, repo, commonheads=None, missingheads=None, missingroots=None + self, repo, commonheads=None, ancestorsof=None, missingroots=None ): # at least one of them must not be set assert None in (commonheads, missingroots) cl = repo.changelog - if missingheads is None: - missingheads = cl.heads() + if ancestorsof is None: + ancestorsof = cl.heads() if missingroots: discbases = [] for n in missingroots: @@ -114,14 +111,14 @@ # TODO remove call to nodesbetween. # TODO populate attributes on outgoing instance instead of setting # discbases. - csets, roots, heads = cl.nodesbetween(missingroots, missingheads) + csets, roots, heads = cl.nodesbetween(missingroots, ancestorsof) included = set(csets) - missingheads = heads + ancestorsof = heads commonheads = [n for n in discbases if n not in included] elif not commonheads: commonheads = [nullid] self.commonheads = commonheads - self.missingheads = missingheads + self.ancestorsof = ancestorsof self._revlog = cl self._common = None self._missing = None @@ -129,7 +126,7 @@ def _computecommonmissing(self): sets = self._revlog.findcommonmissing( - self.commonheads, self.missingheads + self.commonheads, self.ancestorsof ) self._common, self._missing = sets @@ -146,8 +143,15 @@ return self._missing @property - def ancestorsof(self): - return self.missingheads + def missingheads(self): + util.nouideprecwarn( + b'outgoing.missingheads never contained what the name suggests and ' + b'was renamed to outgoing.ancestorsof. check your code for ' + b'correctness.', + b'5.5', + stacklevel=2, + ) + return self.ancestorsof def findcommonoutgoing( @@ -163,7 +167,7 @@ If commoninc is given, it must be the result of a prior call to findcommonincoming(repo, other, force) to avoid recomputing it here. - If portable is given, compute more conservative common and missingheads, + If portable is given, compute more conservative common and ancestorsof, to make bundles created from the instance more portable.''' # declare an empty outgoing object to be filled later og = outgoing(repo, None, None) @@ -178,10 +182,10 @@ # compute outgoing mayexclude = repo._phasecache.phaseroots[phases.secret] or repo.obsstore if not mayexclude: - og.missingheads = onlyheads or repo.heads() + og.ancestorsof = onlyheads or repo.heads() elif onlyheads is None: # use visible heads as it should be cached - og.missingheads = repo.filtered(b"served").heads() + og.ancestorsof = repo.filtered(b"served").heads() og.excluded = [ctx.node() for ctx in repo.set(b'secret() or extinct()')] else: # compute common, missing and exclude secret stuff @@ -196,12 +200,12 @@ else: missing.append(node) if len(missing) == len(allmissing): - missingheads = onlyheads + ancestorsof = onlyheads else: # update missing heads - missingheads = phases.newheads(repo, onlyheads, excluded) - og.missingheads = missingheads + ancestorsof = phases.newheads(repo, onlyheads, excluded) + og.ancestorsof = ancestorsof if portable: - # recompute common and missingheads as if -r<rev> had been given for + # recompute common and ancestorsof as if -r<rev> had been given for # each head of missing, and --base <rev> for each head of the proper # ancestors of missing og._computecommonmissing() @@ -209,7 +213,7 @@ missingrevs = {cl.rev(n) for n in og._missing} og._common = set(cl.ancestors(missingrevs)) - missingrevs commonheads = set(og.commonheads) - og.missingheads = [h for h in og.missingheads if h not in commonheads] + og.ancestorsof = [h for h in og.ancestorsof if h not in commonheads] return og @@ -282,7 +286,7 @@ # If there are no obsstore, no post processing are needed. if repo.obsstore: torev = repo.changelog.rev - futureheads = {torev(h) for h in outgoing.missingheads} + futureheads = {torev(h) for h in outgoing.ancestorsof} futureheads |= {torev(h) for h in outgoing.commonheads} allfuturecommon = repo.changelog.ancestors(futureheads, inclusive=True) for branch, heads in sorted(pycompat.iteritems(headssum)):
--- a/mercurial/exchange.py Wed Jul 15 11:38:54 2020 +0200 +++ b/mercurial/exchange.py Fri Jul 17 09:20:48 2020 +0200 @@ -503,7 +503,7 @@ @util.propertycache def futureheads(self): """future remote heads if the changeset push succeeds""" - return self.outgoing.missingheads + return self.outgoing.ancestorsof @util.propertycache def fallbackheads(self): @@ -512,20 +512,20 @@ # not target to push, all common are relevant return self.outgoing.commonheads unfi = self.repo.unfiltered() - # I want cheads = heads(::missingheads and ::commonheads) - # (missingheads is revs with secret changeset filtered out) + # I want cheads = heads(::ancestorsof and ::commonheads) + # (ancestorsof is revs with secret changeset filtered out) # # This can be expressed as: - # cheads = ( (missingheads and ::commonheads) - # + (commonheads and ::missingheads))" + # cheads = ( (ancestorsof and ::commonheads) + # + (commonheads and ::ancestorsof))" # ) # # while trying to push we already computed the following: # common = (::commonheads) - # missing = ((commonheads::missingheads) - commonheads) + # missing = ((commonheads::ancestorsof) - commonheads) # # We can pick: - # * missingheads part of common (::commonheads) + # * ancestorsof part of common (::commonheads) common = self.outgoing.common rev = self.repo.changelog.index.rev cheads = [node for node in self.revs if rev(node) in common] @@ -918,7 +918,7 @@ # obsolete or unstable changeset in missing, at # least one of the missinghead will be obsolete or # unstable. So checking heads only is ok - for node in outgoing.missingheads: + for node in outgoing.ancestorsof: ctx = unfi[node] if ctx.obsolete(): raise error.Abort(mso % ctx) @@ -969,7 +969,7 @@ """ # * 'force' do not check for push race, # * if we don't push anything, there are nothing to check. - if not pushop.force and pushop.outgoing.missingheads: + if not pushop.force and pushop.outgoing.ancestorsof: allowunrelated = b'related' in bundler.capabilities.get( b'checkheads', () )
--- a/mercurial/localrepo.py Wed Jul 15 11:38:54 2020 +0200 +++ b/mercurial/localrepo.py Fri Jul 17 09:20:48 2020 +0200 @@ -412,13 +412,13 @@ def changegroup(self, nodes, source): outgoing = discovery.outgoing( - self._repo, missingroots=nodes, missingheads=self._repo.heads() + self._repo, missingroots=nodes, ancestorsof=self._repo.heads() ) return changegroup.makechangegroup(self._repo, outgoing, b'01', source) def changegroupsubset(self, bases, heads, source): outgoing = discovery.outgoing( - self._repo, missingroots=bases, missingheads=heads + self._repo, missingroots=bases, ancestorsof=heads ) return changegroup.makechangegroup(self._repo, outgoing, b'01', source)
--- a/mercurial/repair.py Wed Jul 15 11:38:54 2020 +0200 +++ b/mercurial/repair.py Fri Jul 17 09:20:48 2020 +0200 @@ -66,7 +66,7 @@ else: bundletype = b"HG10UN" - outgoing = discovery.outgoing(repo, missingroots=bases, missingheads=heads) + outgoing = discovery.outgoing(repo, missingroots=bases, ancestorsof=heads) contentopts = { b'cg.version': cgversion, b'obsolescence': obsolescence,
--- a/mercurial/shelve.py Wed Jul 15 11:38:54 2020 +0200 +++ b/mercurial/shelve.py Fri Jul 17 09:20:48 2020 +0200 @@ -162,7 +162,7 @@ repo = self.repo.unfiltered() outgoing = discovery.outgoing( - repo, missingroots=bases, missingheads=[node] + repo, missingroots=bases, ancestorsof=[node] ) cg = changegroup.makechangegroup(repo, outgoing, cgversion, b'shelve')
--- a/mercurial/wireprotov1server.py Wed Jul 15 11:38:54 2020 +0200 +++ b/mercurial/wireprotov1server.py Fri Jul 17 09:20:48 2020 +0200 @@ -339,7 +339,7 @@ def changegroup(repo, proto, roots): nodes = wireprototypes.decodelist(roots) outgoing = discovery.outgoing( - repo, missingroots=nodes, missingheads=repo.heads() + repo, missingroots=nodes, ancestorsof=repo.heads() ) cg = changegroupmod.makechangegroup(repo, outgoing, b'01', b'serve') gen = iter(lambda: cg.read(32768), b'') @@ -350,7 +350,7 @@ def changegroupsubset(repo, proto, bases, heads): bases = wireprototypes.decodelist(bases) heads = wireprototypes.decodelist(heads) - outgoing = discovery.outgoing(repo, missingroots=bases, missingheads=heads) + outgoing = discovery.outgoing(repo, missingroots=bases, ancestorsof=heads) cg = changegroupmod.makechangegroup(repo, outgoing, b'01', b'serve') gen = iter(lambda: cg.read(32768), b'') return wireprototypes.streamres(gen=gen)