[PATCH 3 of 7] context: add a markerctx context
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Mon May 14 11:10:24 CDT 2012
# HG changeset patch
# User Pierre-Yves.David at ens-lyon.org
# Date 1337008999 -7200
# Node ID f895c60ac3e0de611419c1c2c7c5a56e6157e3c4
# Parent 5f8d61f6111dd069abf4eb7aef0a51aca4c9ece9
context: add a markerctx context
Add associated method on local repository.
diff -r 5f8d61f6111d -r f895c60ac3e0 mercurial/context.py
--- a/mercurial/context.py Mon May 14 17:06:34 2012 +0200
+++ b/mercurial/context.py Mon May 14 17:23:19 2012 +0200
@@ -8,7 +8,7 @@
from node import nullid, nullrev, short, hex, bin
from i18n import _
import ancestor, mdiff, error, util, scmutil, subrepo, patch, encoding, phases
-import copies
+import copies, obsolete
import match as matchmod
import os, errno, stat
@@ -1273,3 +1273,30 @@
return 'l' in self._flags
def renamed(self):
return self._copied
+
+class markerctx(object):
+ """markerctx represent an obsolete marker """
+
+ def __init__(self, repo, data):
+ self._repo = repo
+ self._data = data
+ self._decodedmeta = None
+
+ def obsnode(self):
+ """node-id of the changeset obsoleted by this marker (as single string)"""
+ return self._data[0]
+
+ def replnodes(self):
+ """node-id of replacement in this marker (as a list)"""
+ return self._data[1]
+
+ def metadata(self):
+ """decoded version of a marker metadata"""
+ if self._decodedmeta is None:
+ self._decodedmeta = obsolete.decodemeta(self._data[3])
+ return self._decodedmeta
+
+ def date(self):
+ """marker creation date (float, int)"""
+ parts = self.metadata()['date'].split(' ')
+ return (float(parts[0]), int(parts[1]))
diff -r 5f8d61f6111d -r f895c60ac3e0 mercurial/localrepo.py
--- a/mercurial/localrepo.py Mon May 14 17:06:34 2012 +0200
+++ b/mercurial/localrepo.py Mon May 14 17:23:19 2012 +0200
@@ -254,6 +254,11 @@
for i in xrange(len(self)):
yield i
+ def markers(self):
+ """all obsolete markers known in this repository"""
+ for marker in self.obsstore._all:
+ yield context.markerctx(self, marker)
+
def revs(self, expr, *args):
'''Return a list of revisions matching the given revset'''
expr = revset.formatspec(expr, *args)
More information about the Mercurial-devel
mailing list