[PATCH 2 of 7 V2] obsolete: add the detection of bumped changeset
Patrick Mézard
patrick at mezard.eu
Sun Oct 14 10:58:43 CDT 2012
Le 03/10/12 23:21, Pierre-Yves David a écrit :
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david at logilab.fr>
> # Date 1349297225 -7200
> # Node ID c09af8f861194656aa3465d2fd721749a61fdacb
> # Parent af731e6a342308e9111c11287bd73a1a0fcbbd47
> obsolete: add the detection of bumped changeset.
>
> Bumped changeset are non-public changeset that tries to succeed to a public()
> changeset.
>
> diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
> --- a/mercurial/obsolete.py
> +++ b/mercurial/obsolete.py
> @@ -399,6 +399,48 @@
> """the set of obsolete parents without non obsolete descendants"""
> return set(repo.revs('obsolete() - obsolete()::unstable()'))
>
> + at cachefor('bumped')
> +def _computebumpedset(repo):
> + """the set of rev trying to obsolete public revision"""
> + # get all possible bumped changeset
changesets
> + candidates = _anysuccessors(repo, repo.revs('public()'))
> + # revision public or already obsolete don't account as bumped
count(?)
Not sure the comment is very useful as it does not add much to the revset.
> + query = '%ld - obsolete() - public()'
> + return set(repo.revs(query, candidates))
> +
> +def _anysuccessors(repo, revs):
def _allsuccessors(repo, revs) ?
> + """return revid of all successors of a set of revs
> + """
> + toproceed = [repo[r].node() for r in revs]
toprocess or pendings or whatever but not toproceed.
> + # prevent extra processing and cycle
Not very useful comment, we are used to "seen" sets when doing traversals.
> + seen = set(toproceed)
> + # records result
Not very useful comment.
> + successors = set()
> + # mapping node -> marker that use node as precursors
> + markersfor = repo.obsstore.precursors
I would name that precursors, and drop the comment as people are supposed to know what precursors is.
> + while toproceed:
> + nc = toproceed.pop()
> + # for all markers that make this node obsolete
> + for mark in markersfor.get(nc, ()):
> + # for all successors
Not very useful comment.
> + for suc in mark[1]:
> + # record this as a successors
Not very useful comment.
> + successors.add(suc)
> + # add it to the list of node to proceed
> + # we want the successors of this successors too.
Not very useful comment.
> + if suc not in seen:
> + seen.add(suc)
> + toproceed.append(suc)
> + # only known nodes are returned
> + nm = repo.changelog.nodemap
> + cs = set()
> + for s in successors:
> + sr = nm.get(s)
> + if sr is not None:
> + cs.add(sr)
cs = set(r for r in (nm.get(s) for s in successors) if r is not None)
?
> + return cs
> +
> +
> def createmarkers(repo, relations, flag=0, metadata=None):
> """Add obsolete markers between changesets in a repo
--
Patrick Mézard
More information about the Mercurial-devel
mailing list