Mercurial > hg
changeset 33149:a14e2e7f7d1f
obsutil: move 'getmarkers' to the new modules
We have a new 'obsutil' module now. We move the high level utility there to
bring 'obsolete.py' back to a more reasonable size.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Tue, 27 Jun 2017 02:06:15 +0200 |
parents | 4e30168d7939 |
children | 77e666f943a6 |
files | mercurial/debugcommands.py mercurial/obsolete.py mercurial/obsutil.py |
diffstat | 3 files changed, 23 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/debugcommands.py Tue Jun 27 01:51:40 2017 +0200 +++ b/mercurial/debugcommands.py Tue Jun 27 02:06:15 2017 +0200 @@ -1429,16 +1429,16 @@ if opts['rev']: revs = scmutil.revrange(repo, opts['rev']) nodes = [repo[r].node() for r in revs] - markers = list(obsolete.getmarkers(repo, nodes=nodes, + markers = list(obsutil.getmarkers(repo, nodes=nodes, exclusive=opts['exclusive'])) markers.sort(key=lambda x: x._data) else: - markers = obsolete.getmarkers(repo) + markers = obsutil.getmarkers(repo) markerstoiter = markers isrelevant = lambda m: True if opts.get('rev') and opts.get('index'): - markerstoiter = obsolete.getmarkers(repo) + markerstoiter = obsutil.getmarkers(repo) markerset = set(markers) isrelevant = lambda m: m in markerset
--- a/mercurial/obsolete.py Tue Jun 27 01:51:40 2017 +0200 +++ b/mercurial/obsolete.py Tue Jun 27 02:06:15 2017 +0200 @@ -796,21 +796,6 @@ finally: lock.release() -def getmarkers(repo, nodes=None, exclusive=False): - """returns markers known in a repository - - If <nodes> is specified, only markers "relevant" to those nodes are are - returned""" - if nodes is None: - rawmarkers = repo.obsstore - elif exclusive: - rawmarkers = obsutil.exclusivemarkers(repo, nodes) - else: - rawmarkers = repo.obsstore.relevantmarkers(nodes) - - for markerdata in rawmarkers: - yield obsutil.marker(repo, markerdata) - # keep compatibility for the 4.3 cycle def allprecursors(obsstore, nodes, ignoreflags=0): movemsg = 'obsolete.allprecursors moved to obsutil.allprecursors' @@ -827,6 +812,11 @@ repo.ui.deprecwarn(movemsg, '4.3') return obsutil.marker(repo, data) +def getmarkers(repo, nodes=None, exclusive=False): + movemsg = 'obsolete.getmarkers moved to obsutil.getmarkers' + repo.ui.deprecwarn(movemsg, '4.3') + return obsutil.getmarkers(repo, nodes=nodes, exclusive=exclusive) + def exclusivemarkers(repo, nodes): movemsg = 'obsolete.exclusivemarkers moved to obsutil.exclusivemarkers' repo.ui.deprecwarn(movemsg, '4.3')
--- a/mercurial/obsutil.py Tue Jun 27 01:51:40 2017 +0200 +++ b/mercurial/obsutil.py Tue Jun 27 02:06:15 2017 +0200 @@ -48,6 +48,21 @@ """The flags field of the marker""" return self._data[2] +def getmarkers(repo, nodes=None, exclusive=False): + """returns markers known in a repository + + If <nodes> is specified, only markers "relevant" to those nodes are are + returned""" + if nodes is None: + rawmarkers = repo.obsstore + elif exclusive: + rawmarkers = exclusivemarkers(repo, nodes) + else: + rawmarkers = repo.obsstore.relevantmarkers(nodes) + + for markerdata in rawmarkers: + yield marker(repo, markerdata) + def closestpredecessors(repo, nodeid): """yield the list of next predecessors pointing on visible changectx nodes