Patchwork [7,of,8] obsutil: move the 'marker' class to the new modules

login
register
mail settings
Submitter Pierre-Yves David
Date June 27, 2017, 8:56 a.m.
Message ID <4289cfcd7e3a5176c668.1498553810@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/21766/
State Superseded
Headers show

Comments

Pierre-Yves David - June 27, 2017, 8:56 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1498521100 -7200
#      Tue Jun 27 01:51:40 2017 +0200
# Node ID 4289cfcd7e3a5176c6680cc532dd8bc32cce85db
# Parent  2d143a083ded57fdf7825bb8a263cf792e409e0c
# 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 4289cfcd7e3a
obsutil: move the 'marker' class to the new modules

We have a new 'obsutil' module now. We move high level utility there to bring
'obsolete.py' back to a more reasonable size.

Patch

diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -306,7 +306,7 @@  def _debugobsmarkers(ui, part, indent=0,
         ui.write(msg)
         fm = ui.formatter('debugobsolete', opts)
         for rawmarker in sorted(markers):
-            m = obsolete.marker(None, rawmarker)
+            m = obsutil.marker(None, rawmarker)
             fm.startitem()
             fm.plain(indent_string)
             cmdutil.showmarker(fm, m)
diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -465,48 +465,6 @@  def encodemarkers(markers, addheader=Fal
     for marker in markers:
         yield encodeone(marker)
 
-
-class marker(object):
-    """Wrap obsolete marker raw data"""
-
-    def __init__(self, repo, data):
-        # the repo argument will be used to create changectx in later version
-        self._repo = repo
-        self._data = data
-        self._decodedmeta = None
-
-    def __hash__(self):
-        return hash(self._data)
-
-    def __eq__(self, other):
-        if type(other) != type(self):
-            return False
-        return self._data == other._data
-
-    def precnode(self):
-        """Precursor changeset node identifier"""
-        return self._data[0]
-
-    def succnodes(self):
-        """List of successor changesets node identifiers"""
-        return self._data[1]
-
-    def parentnodes(self):
-        """Parents of the precursors (None if not recorded)"""
-        return self._data[5]
-
-    def metadata(self):
-        """Decoded metadata dictionary"""
-        return dict(self._data[3])
-
-    def date(self):
-        """Creation date as (unixtime, offset)"""
-        return self._data[4]
-
-    def flags(self):
-        """The flags field of the marker"""
-        return self._data[2]
-
 @util.nogc
 def _addsuccessors(successors, markers):
     for mark in markers:
@@ -851,7 +809,7 @@  def getmarkers(repo, nodes=None, exclusi
         rawmarkers = repo.obsstore.relevantmarkers(nodes)
 
     for markerdata in rawmarkers:
-        yield marker(repo, markerdata)
+        yield obsutil.marker(repo, markerdata)
 
 # keep compatibility for the 4.3 cycle
 def allprecursors(obsstore, nodes, ignoreflags=0):
@@ -864,6 +822,11 @@  def allsuccessors(obsstore, nodes, ignor
     util.nouideprecwarn(movemsg, '4.3')
     return obsutil.allsuccessors(obsstore, nodes, ignoreflags)
 
+def marker(repo, data):
+    movemsg = 'obsolete.marker moved to obsutil.marker'
+    repo.ui.deprecwarn(movemsg, '4.3')
+    return obsutil.marker(repo, data)
+
 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
@@ -7,6 +7,47 @@ 
 
 from __future__ import absolute_import
 
+class marker(object):
+    """Wrap obsolete marker raw data"""
+
+    def __init__(self, repo, data):
+        # the repo argument will be used to create changectx in later version
+        self._repo = repo
+        self._data = data
+        self._decodedmeta = None
+
+    def __hash__(self):
+        return hash(self._data)
+
+    def __eq__(self, other):
+        if type(other) != type(self):
+            return False
+        return self._data == other._data
+
+    def precnode(self):
+        """Precursor changeset node identifier"""
+        return self._data[0]
+
+    def succnodes(self):
+        """List of successor changesets node identifiers"""
+        return self._data[1]
+
+    def parentnodes(self):
+        """Parents of the precursors (None if not recorded)"""
+        return self._data[5]
+
+    def metadata(self):
+        """Decoded metadata dictionary"""
+        return dict(self._data[3])
+
+    def date(self):
+        """Creation date as (unixtime, offset)"""
+        return self._data[4]
+
+    def flags(self):
+        """The flags field of the marker"""
+        return self._data[2]
+
 def closestpredecessors(repo, nodeid):
     """yield the list of next predecessors pointing on visible changectx nodes