[PATCH 36 of 36] changectx: if passing a context then exit __init__ immediately

Sean Farley sean.michael.farley at gmail.com
Wed Aug 7 13:13:36 CDT 2013


# HG changeset patch
# User Sean Farley <sean.michael.farley at gmail.com>
# Date 1375825361 18000
#      Tue Aug 06 16:42:41 2013 -0500
# Node ID 7316661a4968456c3868c178cab6e32004094504
# Parent  3f12610b25b6e786c81d84734ca8433ad47ab7a3
changectx: if passing a context then exit __init__ immediately

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -152,10 +152,16 @@
     """A changecontext object makes access to data related to a particular
     changeset convenient. It represents a read-only context already presnt in
     the repo."""
     def __init__(self, repo, changeid=''):
         """changeid is a revision number, node, or tag"""
+
+        # allow changeid to be a context so that we can simplify creating a
+        # copy
+        if isinstance(changeid, context):
+            return
+
         if changeid == '':
             changeid = '.'
         self._repo = repo
 
         if isinstance(changeid, int):


More information about the Mercurial-devel mailing list