Patchwork [8,of,8,V2] obsutil: move 'getmarkers' to the new modules

login
register
mail settings
Submitter Pierre-Yves David
Date June 28, 2017, 9:21 p.m.
Message ID <4baf909a9c08b8765303.1498684919@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/21820/
State Accepted
Headers show

Comments

Pierre-Yves David - June 28, 2017, 9:21 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1498521975 -7200
#      Tue Jun 27 02:06:15 2017 +0200
# Node ID 4baf909a9c08b87653035ce15f1057decab39fda
# Parent  1241624a84695b93570af70529d60fe4d6186de2
# EXP-Topic obsutil
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 4baf909a9c08
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.
Sean Farley - June 30, 2017, 11:30 p.m.
Pierre-Yves David <pierre-yves.david@ens-lyon.org> writes:

> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@octobus.net>
> # Date 1498521975 -7200
> #      Tue Jun 27 02:06:15 2017 +0200
> # Node ID 4baf909a9c08b87653035ce15f1057decab39fda
> # Parent  1241624a84695b93570af70529d60fe4d6186de2
> # EXP-Topic obsutil
> # Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
> #              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 4baf909a9c08
> 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.

Looks like some good code movement. Thanks, queued!

Patch

diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -1429,16 +1429,16 @@  def debugobsolete(ui, repo, precursor=No
         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
 
diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -796,21 +796,6 @@  def pushmarker(repo, key, old, new):
     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 @@  def marker(repo, data):
     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')
diff --git a/mercurial/obsutil.py b/mercurial/obsutil.py
--- a/mercurial/obsutil.py
+++ b/mercurial/obsutil.py
@@ -48,6 +48,21 @@  class marker(object):
         """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