Patchwork [5,of,8] localrepo: import "lock" module as "lockmod" for readability

login
register
mail settings
Submitter Katsunori FUJIWARA
Date Nov. 12, 2013, 7:31 a.m.
Message ID <ae12d4da995ee8693612.1384241514@juju>
Download mbox | patch
Permalink /patch/2927/
State Accepted
Commit 7cbb79bddee7188d072c1eb217b298a20d0ba0a2
Headers show

Comments

Katsunori FUJIWARA - Nov. 12, 2013, 7:31 a.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1384241032 -32400
#      Tue Nov 12 16:23:52 2013 +0900
# Node ID ae12d4da995ee86936125ce681895e28d1fb4134
# Parent  b512914b9b4dee15b87a20a3ed311acb9fd181e5
localrepo: import "lock" module as "lockmod" for readability

Before this patch, "localrepo.py" has many methods defining local
variable "lock", even though it imports "lock" module as "lock". This
ambiguity decreases readability.

Patch

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -8,7 +8,8 @@ 
 from i18n import _
 import peer, changegroup, subrepo, discovery, pushkey, obsolete, repoview
 import changelog, dirstate, filelog, manifest, context, bookmarks, phases
-import lock, transaction, store, encoding
+import lock as lockmod
+import transaction, store, encoding
 import scmutil, util, extensions, hook, error, revset
 import match as matchmod
 import merge as mergemod
@@ -1000,15 +1001,16 @@ 
 
     def _lock(self, lockname, wait, releasefn, acquirefn, desc):
         try:
-            l = lock.lock(lockname, 0, releasefn, desc=desc)
+            l = lockmod.lock(lockname, 0, releasefn, desc=desc)
         except error.LockHeld, inst:
             if not wait:
                 raise
             self.ui.warn(_("waiting for lock on %s held by %r\n") %
                          (desc, inst.locker))
             # default to 600 seconds timeout
-            l = lock.lock(lockname, int(self.ui.config("ui", "timeout", "600")),
-                          releasefn, desc=desc)
+            l = lockmod.lock(lockname,
+                             int(self.ui.config("ui", "timeout", "600")),
+                             releasefn, desc=desc)
         if acquirefn:
             acquirefn()
         return l