Mercurial > evolve
diff hgext/evolve.py @ 1067:5d063fed9e3d
evolve: yield to relevant markers handling in core
The handling of obsolescence marker is now performed in core. If we detect a
mercurial with such power we skip the wrapping from evolve.
This changeset also suffer from massive diff from the change in display of
obsolescence marker with parent information introduced at the same time in core.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Wed, 20 Aug 2014 20:49:48 -0700 |
parents | 742c1ce79a96 |
children | 9f87b103f7b5 bac4e0bc9f6a |
line wrap: on
line diff
--- a/hgext/evolve.py Wed Aug 20 21:14:49 2014 -0700 +++ b/hgext/evolve.py Wed Aug 20 20:49:48 2014 -0700 @@ -70,6 +70,9 @@ from mercurial.hgweb import hgweb_mod from mercurial import bundle2 +cmdtable = {} +command = cmdutil.command(cmdtable) + _pack = struct.pack if gboptsmap is not None: @@ -357,52 +360,96 @@ if not opts.get('user') and opts.get('current_user'): opts['user'] = ui.username() -@eh.wrapfunction(mercurial.obsolete, 'createmarkers') -def _createmarkers(orig, repo, relations, *args, **kwargs): - """register parent information at prune time""" - # every time this test is run, a kitten is slain. - # Change it as soon as possible - if '[,{metadata}]' in orig.__doc__: - relations = list(relations) - for idx, rel in enumerate(relations): - prec = rel[0] - sucs = rel[1] - if not sucs: - meta = {} - if 2 < len(rel): - meta.update(rel[2]) - for i, p in enumerate(prec.parents(), 1): - meta['p%i' % i] = p.hex() - relations[idx] = (prec, sucs, meta) - return orig(repo, relations, *args, **kwargs) - -def createmarkers(*args, **kwargs): - return obsolete.createmarkers(*args, **kwargs) - -class pruneobsstore(obsolete.obsstore): - - def __init__(self, *args, **kwargs): - self.prunedchildren = {} - return super(pruneobsstore, self).__init__(*args, **kwargs) - - def _load(self, markers): - markers = self._prunedetectingmarkers(markers) - return super(pruneobsstore, self)._load(markers) - - - def _prunedetectingmarkers(self, markers): - for m in markers: - if not m[1]: # no successors - meta = obsolete.decodemeta(m[3]) - if 'p1' in meta: - p1 = node.bin(meta['p1']) - self.prunedchildren.setdefault(p1, set()).add(m) - if 'p2' in meta: - p2 = node.bin(meta['p2']) - self.prunedchildren.setdefault(p2, set()).add(m) - yield m - -obsolete.obsstore = pruneobsstore + +createmarkers = obsolete.createmarkers +if not util.safehasattr(obsolete.obsstore, 'relevantmarkers'): + + @eh.wrapfunction(mercurial.obsolete, 'createmarkers') + def _createmarkers(orig, repo, relations, *args, **kwargs): + """register parent information at prune time""" + # every time this test is run, a kitten is slain. + # Change it as soon as possible + if '[,{metadata}]' in orig.__doc__: + relations = list(relations) + for idx, rel in enumerate(relations): + prec = rel[0] + sucs = rel[1] + if not sucs: + meta = {} + if 2 < len(rel): + meta.update(rel[2]) + for i, p in enumerate(prec.parents(), 1): + meta['p%i' % i] = p.hex() + relations[idx] = (prec, sucs, meta) + return orig(repo, relations, *args, **kwargs) + + def createmarkers(*args, **kwargs): + return obsolete.createmarkers(*args, **kwargs) + + class pruneobsstore(obsolete.obsstore): + + def __init__(self, *args, **kwargs): + self.prunedchildren = {} + return super(pruneobsstore, self).__init__(*args, **kwargs) + + def _load(self, markers): + markers = self._prunedetectingmarkers(markers) + return super(pruneobsstore, self)._load(markers) + + + def _prunedetectingmarkers(self, markers): + for m in markers: + if not m[1]: # no successors + meta = obsolete.decodemeta(m[3]) + if 'p1' in meta: + p1 = node.bin(meta['p1']) + self.prunedchildren.setdefault(p1, set()).add(m) + if 'p2' in meta: + p2 = node.bin(meta['p2']) + self.prunedchildren.setdefault(p2, set()).add(m) + yield m + + obsolete.obsstore = pruneobsstore + + @eh.addattr(obsolete.obsstore, 'relevantmarkers') + def relevantmarkers(self, nodes): + """return a set of all obsolescence marker relevant to a set of node. + + "relevant" to a set of node mean: + + - marker that use this changeset as successors + - prune marker of direct children on this changeset. + - recursive application of the two rules on precursors of these markers + + It a set so you cannot rely on order""" + seennodes = set(nodes) + seenmarkers = set() + pendingnodes = set(nodes) + precursorsmarkers = self.precursors + prunedchildren = self.prunedchildren + while pendingnodes: + direct = set() + for current in pendingnodes: + direct.update(precursorsmarkers.get(current, ())) + direct.update(prunedchildren.get(current, ())) + direct -= seenmarkers + pendingnodes = set([m[0] for m in direct]) + seenmarkers |= direct + pendingnodes -= seennodes + seennodes |= pendingnodes + return seenmarkers + +@command('debugobsoleterelevant', + [], + 'REVSET') +def debugobsoleterelevant(ui, repo, *revsets): + """print allobsolescence marker relevant to a set of revision""" + nodes = [ctx.node() for ctx in repo.set('%lr', revsets)] + markers = repo.obsstore.relevantmarkers(nodes) + for rawmarker in sorted(markers): + marker = obsolete.marker(repo, rawmarker) + cmdutil.showmarker(ui, marker) + ##################################################################### ### Critical fix ### @@ -913,8 +960,6 @@ ### new command ############################# -cmdtable = {} -command = cmdutil.command(cmdtable) metadataopts = [ ('d', 'date', '', _('record the specified date in metadata'), _('DATE')), @@ -2285,44 +2330,6 @@ ui.progress(topic, *args, **kwargs) -@command('debugobsoleterelevant', - [], - 'REVSET') -def debugobsoleterelevant(ui, repo, *revsets): - """print allobsolescence marker relevant to a set of revision""" - nodes = [ctx.node() for ctx in repo.set('%lr', revsets)] - markers = repo.obsstore.relevantmarkers(nodes) - for rawmarker in sorted(markers): - marker = obsolete.marker(repo, rawmarker) - cmdutil.showmarker(ui, marker) - -@eh.addattr(obsolete.obsstore, 'relevantmarkers') -def relevantmarkers(self, nodes): - """return a set of all obsolescence marker relevant to a set of node. - - "relevant" to a set of node mean: - - - marker that use this changeset as successors - - prune marker of direct children on this changeset. - - recursive application of the two rules on precursors of these markers - - It a set so you cannot rely on order""" - seennodes = set(nodes) - seenmarkers = set() - pendingnodes = set(nodes) - precursorsmarkers = self.precursors - prunedchildren = self.prunedchildren - while pendingnodes: - direct = set() - for current in pendingnodes: - direct.update(precursorsmarkers.get(current, ())) - direct.update(prunedchildren.get(current, ())) - direct -= seenmarkers - pendingnodes = set([m[0] for m in direct]) - seenmarkers |= direct - pendingnodes -= seennodes - seennodes |= pendingnodes - return seenmarkers _pushkeyescape = getattr(obsolete, '_pushkeyescape', None)