Patchwork [04,of,14,RFC] localrepo: use context.nodeorctx to reduce code

login
register
mail settings
Submitter Sean Farley
Date July 9, 2013, 9:54 p.m.
Message ID <399c9dd59e118005e37d.1373406875@laptop.local>
Download mbox | patch
Permalink /patch/1813/
State Changes Requested
Headers show

Comments

Sean Farley - July 9, 2013, 9:54 p.m.
# HG changeset patch
# User Sean Farley <sean.michael.farley@gmail.com>
# Date 1373323244 18000
#      Mon Jul 08 17:40:44 2013 -0500
# Node ID 399c9dd59e118005e37d0cf22f82fc5f7d9d2ab8
# Parent  6724e421bc24d936a6ce57ceb941612be4867d66
localrepo: use context.nodeorctx to reduce code

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 = context.nodeorctx(self, node1)
+        ctx2 = context.nodeorctx(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