[PATCH 02 of 14 RFC] context: add a method to convert node to ctx
Sean Farley
sean.michael.farley at gmail.com
Tue Jul 9 21:54:33 UTC 2013
# HG changeset patch
# User Sean Farley <sean.michael.farley at gmail.com>
# Date 1373322965 18000
# Mon Jul 08 17:36:05 2013 -0500
# Node ID bf0f87c072f524b8e054de72af143a0dfc2fcffb
# Parent 2bda9c94e65cff8c6968d82cfc07ec6049b194c0
context: add a method to convert node to ctx
I had a hard time deciding where to place this function. Perhaps it could go
into scmutil or util?
This adds a method as a common place for testing if an object is a context
object, and if it isn't, then to find the corresponding context object in the
repo.
diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -14,10 +14,15 @@
import obsolete as obsmod
import repoview
propertycache = util.propertycache
+def nodeorctx(repo, node):
+ if isinstance(node, changectx):
+ return node
+ return repo[node]
+
class changectx(object):
"""A changecontext object makes access to data related to a particular
changeset convenient."""
def __init__(self, repo, changeid=''):
"""changeid is a revision number, node, or tag"""
More information about the Mercurial-devel
mailing list