Patchwork [33,of,35,V2] localrepo: remove unnecessary check of instance

login
register
mail settings
Submitter Sean Farley
Date Aug. 7, 2013, 11:51 p.m.
Message ID <7cf9e2404d41a1f3b7e3.1375919507@laptop.local>
Download mbox | patch
Permalink /patch/2086/
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 1375819902 18000
#      Tue Aug 06 15:11:42 2013 -0500
# Node ID 7cf9e2404d41a1f3b7e3713d4591c743f8ea3c78
# Parent  2b9d9c462478e5d903c8e9392e914ebde96d3189
localrepo: 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/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1455,18 +1455,12 @@ 
             for fn in mf.keys():
                 if not match(fn):
                     del mf[fn]
             return mf
 
-        if isinstance(node1, context.changectx):
-            ctx1 = node1
-        else:
-            ctx1 = self[node1]
-        if isinstance(node2, context.changectx):
-            ctx2 = node2
-        else:
-            ctx2 = self[node2]
+        ctx1 = self[node1]
+        ctx2 = self[node2]
 
         working = ctx2.rev() is None
         parentworking = working and ctx1 == self['.']
         match = match or matchmod.always(self.root, self.getcwd())
         listignored, listclean, listunknown = ignored, clean, unknown