[PATCH 2 of 4] convert: move localname state to function scope

David Soria Parra davidsp at fb.com
Tue Dec 20 13:07:20 EST 2016


# HG changeset patch
# User David Soria Parra <davidsp at fb.com>
# Date 1482254630 28800
#      Tue Dec 20 09:23:50 2016 -0800
# Node ID 6f7154489117ac5cc9f0f876e922fef5c44803d8
# Parent  4cb85a7af6deb30abfd4c40ec8e502560150999e
convert: move localname state to function scope

diff --git a/hgext/convert/p4.py b/hgext/convert/p4.py
--- a/hgext/convert/p4.py
+++ b/hgext/convert/p4.py
@@ -64,7 +64,6 @@
         self.encoding = self.ui.config('convert', 'p4.encoding',
                                        default=convcmd.orig_encoding)
         self.depotname = {}           # mapping from local name to depot name
-        self.localname = {} # mapping from depot name to local name
         self.re_type = re.compile(
             "([a-z]+)?(text|binary|symlink|apple|resource|unicode|utf\d+)"
             "(\+\w+)?$")
@@ -168,6 +167,7 @@
             files = []
             copies = {}
             copiedfiles = []
+            localname = {}
             i = 0
             while ("depotFile%d" % i) in d and ("rev%d" % i) in d:
                 oldname = d["depotFile%d" % i]
@@ -181,7 +181,7 @@
                     self.depotname[filename] = oldname
                     if (d.get("action%d" % i) == "move/add"):
                         copiedfiles.append(filename)
-                    self.localname[oldname] = filename
+                    localname[oldname] = filename
                 i += 1
 
             # Collect information about copied files
@@ -208,8 +208,8 @@
                                 j += 1
                         i += 1
 
-                    if copiedoldname and copiedoldname in self.localname:
-                        copiedfilename = self.localname[copiedoldname]
+                    if copiedoldname and copiedoldname in localname:
+                        copiedfilename = localname[copiedoldname]
                         break
 
                 if copiedfilename:


More information about the Mercurial-devel mailing list