Patchwork [3,of,6,V2] similar: use common names for changectx variables

login
register
mail settings
Submitter Yuya Nishihara
Date March 23, 2017, 2:13 p.m.
Message ID <f1b08899545270dea26a.1490278425@mimosa>
Download mbox | patch
Permalink /patch/19601/
State Accepted
Headers show

Comments

Yuya Nishihara - March 23, 2017, 2:13 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1490271045 -32400
#      Thu Mar 23 21:10:45 2017 +0900
# Node ID f1b08899545270dea26ac954d21a02ebd5beb5f3
# Parent  8b33a51771425d2623aa37dbcff05cdb5cc8e2fa
similar: use common names for changectx variables

We generally use 'wctx' and 'pctx' for working context and its parent
respectively.

Patch

diff --git a/mercurial/similar.py b/mercurial/similar.py
--- a/mercurial/similar.py
+++ b/mercurial/similar.py
@@ -95,16 +95,16 @@  def _findsimilarmatches(repo, added, rem
 
 def findrenames(repo, added, removed, threshold):
     '''find renamed files -- yields (before, after, score) tuples'''
-    parentctx = repo['.']
-    workingctx = repo[None]
+    wctx = repo[None]
+    pctx = wctx.p1()
 
     # Zero length files will be frequently unrelated to each other, and
     # tracking the deletion/addition of such a file will probably cause more
     # harm than good. We strip them out here to avoid matching them later on.
-    addedfiles = [workingctx[fp] for fp in sorted(added)
-                  if workingctx[fp].size() > 0]
-    removedfiles = [parentctx[fp] for fp in sorted(removed)
-                    if fp in parentctx and parentctx[fp].size() > 0]
+    addedfiles = [wctx[fp] for fp in sorted(added)
+                  if wctx[fp].size() > 0]
+    removedfiles = [pctx[fp] for fp in sorted(removed)
+                    if fp in pctx and pctx[fp].size() > 0]
 
     # Find exact matches.
     matchedfiles = set()