[PATCH 02 of 35 V2] context: return a copied context if changeid is already a context
Sean Farley
sean.michael.farley at gmail.com
Wed Aug 7 18:51:16 CDT 2013
# HG changeset patch
# User Sean Farley <sean.michael.farley at gmail.com>
# Date 1375822228 18000
# Tue Aug 06 15:50:28 2013 -0500
# Node ID 21cc2a972033673988500bb126c24e77f2ed37e1
# Parent 339f5b17a04f405040de893becb51b7270b8613d
context: return a copied context if changeid is already a context
This implements a copy constructor so that we can pass a context-derived object
in future refactorings.
diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -22,11 +22,20 @@
workingctx: a context that represents the working directory and can
be committed,
memctx: a context that represents changes in-memory and can also
be committed."""
def __new__(cls, repo, changeid='', *args, **kwargs):
- return super(context, cls).__new__(cls)
+ if isinstance(changeid, context):
+ return changeid
+
+ o = super(context, cls).__new__(cls)
+
+ o._repo = repo
+ o._rev = nullrev
+ o._node = nullid
+
+ return o
class changectx(context):
"""A changecontext object makes access to data related to a particular
changeset convenient. It represents a read-only context already presnt in
the repo."""
More information about the Mercurial-devel
mailing list