Patchwork [32,of,35,V2] context: remove unnecessary check of instance

login
register
mail settings
Submitter Sean Farley
Date Aug. 7, 2013, 11:51 p.m.
Message ID <2b9d9c462478e5d903c8.1375919506@laptop.local>
Download mbox | patch
Permalink /patch/2085/
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 1375819891 18000
#      Tue Aug 06 15:11:31 2013 -0500
# Node ID 2b9d9c462478e5d903c8e9392e914ebde96d3189
# Parent  3a28dc78de7f225d29db6427c035e1f962414b59
context: remove unnecessary check of instance

The refactoring of all the context objects allows us to simply pass a context
to the __new__ constructor and have it return the same object without
allocating new memory.

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -130,11 +130,11 @@ 
 
     def diff(self, ctx2=None, match=None, **opts):
         """Returns a diff generator for the given contexts and matcher"""
         if ctx2 is None:
             ctx2 = self.p1()
-        if ctx2 is not None and not isinstance(ctx2, changectx):
+        if ctx2 is not None:
             ctx2 = self._repo[ctx2]
         diffopts = patch.diffopts(self._repo.ui, opts)
         return patch.diff(self._repo, ctx2.node(), self.node(),
                           match=match, opts=diffopts)