Patchwork [03,of,35,V2] changectx: if passing a context then exit __init__ immediately

login
register
mail settings
Submitter Sean Farley
Date Aug. 7, 2013, 11:51 p.m.
Message ID <93e23839fcc5b6c0eb22.1375919477@laptop.local>
Download mbox | patch
Permalink /patch/2056/
State Accepted
Headers show

Comments

Sean Farley - Aug. 7, 2013, 11:51 p.m.
# HG changeset patch
# User Sean Farley <sean.michael.farley@gmail.com>
# Date 1375825361 18000
#      Tue Aug 06 16:42:41 2013 -0500
# Node ID 93e23839fcc5b6c0eb22592f27b5abbe2c4c1321
# Parent  21cc2a972033673988500bb126c24e77f2ed37e1
changectx: if passing a context then exit __init__ immediately

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -39,10 +39,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"""
+
+        # since context.__new__ already took care of copying the object, we
+        # don't need to do anything in __init__, so we just exit here
+        if isinstance(changeid, context):
+            return
+
         if changeid == '':
             changeid = '.'
         self._repo = repo
 
         if isinstance(changeid, int):