Use util.nouideprecwarn because obsstore doesn't have easy access to an ui
object.
The renaming is done according to
https://www.mercurial-scm.org/wiki/CEDVocabulary.
hg-reviewers |
Use util.nouideprecwarn because obsstore doesn't have easy access to an ui
object.
The renaming is done according to
https://www.mercurial-scm.org/wiki/CEDVocabulary.
Lint Skipped |
Unit Tests Skipped |
mercurial/obsutil.py | ||
---|---|---|
210 | Ideally yes. I wanted to limit this series to external impacting changes only (either output or API changes) so extensions and tests could be updated once and for all. I plan to do variables renaming in a later series as they won't involve test changing or extensions breaking. |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/obsolete.py (20 lines) | |||
M | mercurial/obsutil.py (6 lines) |
Status | Author | Revision | |
---|---|---|---|
Closed | lothiraldan | ||
Closed | lothiraldan | ||
Closed | lothiraldan | ||
Closed | lothiraldan | ||
Closed | lothiraldan | ||
Closed | lothiraldan | ||
Closed | lothiraldan | ||
Closed | lothiraldan | ||
Closed | lothiraldan | ||
Closed | lothiraldan | ||
Closed | lothiraldan | ||
Closed | lothiraldan | ||
Closed | lothiraldan | ||
Closed | lothiraldan | ||
Closed | lothiraldan | ||
Closed | lothiraldan | ||
Closed | lothiraldan | ||
Closed | lothiraldan | ||
Closed | lothiraldan | ||
Closed | lothiraldan | ||
Closed | lothiraldan | ||
Closed | lothiraldan | ||
Closed | lothiraldan | ||
Closed | lothiraldan | ||
Closed | lothiraldan | ||
Closed | lothiraldan | ||
Closed | lothiraldan |
return markers | return markers | ||||
@propertycache | @propertycache | ||||
def successors(self): | def successors(self): | ||||
successors = {} | successors = {} | ||||
_addsuccessors(successors, self._all) | _addsuccessors(successors, self._all) | ||||
return successors | return successors | ||||
@propertycache | @property | ||||
def precursors(self): | def precursors(self): | ||||
msg = ("'obsstore.precursors' is deprecated, " | |||||
"use 'obsstore.predecessors'") | |||||
util.nouideprecwarn(msg, '4.4') | |||||
return self.predecessors | |||||
@propertycache | |||||
def predecessors(self): | |||||
predecessors = {} | predecessors = {} | ||||
_addpredecessors(predecessors, self._all) | _addpredecessors(predecessors, self._all) | ||||
return predecessors | return predecessors | ||||
@propertycache | @propertycache | ||||
def children(self): | def children(self): | ||||
children = {} | children = {} | ||||
_addchildren(children, self._all) | _addchildren(children, self._all) | ||||
return children | return children | ||||
def _cached(self, attr): | def _cached(self, attr): | ||||
return attr in self.__dict__ | return attr in self.__dict__ | ||||
def _addmarkers(self, markers, rawdata): | def _addmarkers(self, markers, rawdata): | ||||
markers = list(markers) # to allow repeated iteration | markers = list(markers) # to allow repeated iteration | ||||
self._data = self._data + rawdata | self._data = self._data + rawdata | ||||
self._all.extend(markers) | self._all.extend(markers) | ||||
if self._cached('successors'): | if self._cached('successors'): | ||||
_addsuccessors(self.successors, markers) | _addsuccessors(self.successors, markers) | ||||
if self._cached('precursors'): | if self._cached('predecessors'): | ||||
_addpredecessors(self.precursors, markers) | _addpredecessors(self.predecessors, markers) | ||||
if self._cached('children'): | if self._cached('children'): | ||||
_addchildren(self.children, markers) | _addchildren(self.children, markers) | ||||
_checkinvalidmarkers(markers) | _checkinvalidmarkers(markers) | ||||
def relevantmarkers(self, nodes): | def relevantmarkers(self, nodes): | ||||
"""return a set of all obsolescence markers relevant to a set of nodes. | """return a set of all obsolescence markers relevant to a set of nodes. | ||||
"relevant" to a set of nodes mean: | "relevant" to a set of nodes mean: | ||||
- marker that use this changeset as successor | - marker that use this changeset as successor | ||||
- prune marker of direct children on this changeset | - prune marker of direct children on this changeset | ||||
- recursive application of the two rules on precursors of these markers | - recursive application of the two rules on precursors of these markers | ||||
It is a set so you cannot rely on order.""" | It is a set so you cannot rely on order.""" | ||||
pendingnodes = set(nodes) | pendingnodes = set(nodes) | ||||
seenmarkers = set() | seenmarkers = set() | ||||
seennodes = set(pendingnodes) | seennodes = set(pendingnodes) | ||||
precursorsmarkers = self.precursors | precursorsmarkers = self.predecessors | ||||
succsmarkers = self.successors | succsmarkers = self.successors | ||||
children = self.children | children = self.children | ||||
while pendingnodes: | while pendingnodes: | ||||
direct = set() | direct = set() | ||||
for current in pendingnodes: | for current in pendingnodes: | ||||
direct.update(precursorsmarkers.get(current, ())) | direct.update(precursorsmarkers.get(current, ())) | ||||
pruned = [m for m in children.get(current, ()) if not m[1]] | pruned = [m for m in children.get(current, ()) if not m[1]] | ||||
direct.update(pruned) | direct.update(pruned) | ||||
@cachefor('divergent') | @cachefor('divergent') | ||||
def _computedivergentset(repo): | def _computedivergentset(repo): | ||||
"""the set of rev that compete to be the final successors of some revision. | """the set of rev that compete to be the final successors of some revision. | ||||
""" | """ | ||||
divergent = set() | divergent = set() | ||||
obsstore = repo.obsstore | obsstore = repo.obsstore | ||||
newermap = {} | newermap = {} | ||||
for ctx in repo.set('(not public()) - obsolete()'): | for ctx in repo.set('(not public()) - obsolete()'): | ||||
mark = obsstore.precursors.get(ctx.node(), ()) | mark = obsstore.predecessors.get(ctx.node(), ()) | ||||
toprocess = set(mark) | toprocess = set(mark) | ||||
seen = set() | seen = set() | ||||
while toprocess: | while toprocess: | ||||
prec = toprocess.pop()[0] | prec = toprocess.pop()[0] | ||||
if prec in seen: | if prec in seen: | ||||
continue # emergency cycle hanging prevention | continue # emergency cycle hanging prevention | ||||
seen.add(prec) | seen.add(prec) | ||||
if prec not in newermap: | if prec not in newermap: | ||||
obsutil.successorssets(repo, prec, cache=newermap) | obsutil.successorssets(repo, prec, cache=newermap) | ||||
newer = [n for n in newermap[prec] if n] | newer = [n for n in newermap[prec] if n] | ||||
if len(newer) > 1: | if len(newer) > 1: | ||||
divergent.add(ctx.rev()) | divergent.add(ctx.rev()) | ||||
break | break | ||||
toprocess.update(obsstore.precursors.get(prec, ())) | toprocess.update(obsstore.predecessors.get(prec, ())) | ||||
return divergent | return divergent | ||||
def createmarkers(repo, relations, flag=0, date=None, metadata=None, | def createmarkers(repo, relations, flag=0, date=None, metadata=None, | ||||
operation=None): | operation=None): | ||||
"""Add obsolete markers between changesets in a repo | """Add obsolete markers between changesets in a repo | ||||
<relations> must be an iterable of (<old>, (<new>, ...)[,{metadata}]) | <relations> must be an iterable of (<old>, (<new>, ...)[,{metadata}]) |
should this be called predecessormarkers?