[PATCH 02 of 14] posix: use local reference to removedirs

Ryan McElroy rm at fb.com
Mon Mar 20 22:10:45 EDT 2017


# HG changeset patch
# User Ryan McElroy <rmcelroy at fb.com>
# Date 1490059858 25200
#      Mon Mar 20 18:30:58 2017 -0700
# Node ID 14339b2761ba49e914ec2be4446e2005ce024e8a
# Parent  9e525e28e3c76792f57355989bdd652f0617541d
posix: use local reference to removedirs

We have a local reference to os.removedirs in module scope, but we still used
os.removedirs inside functions. This changes util to use the local reference,
which will pave the way for combining duplicated code in future patches.

diff --git a/mercurial/posix.py b/mercurial/posix.py
--- a/mercurial/posix.py
+++ b/mercurial/posix.py
@@ -542,7 +542,7 @@ def unlinkpath(f, ignoremissing=False):
             raise
     # try removing directories that might now be empty
     try:
-        os.removedirs(os.path.dirname(f))
+        removedirs(os.path.dirname(f))
     except OSError:
         pass
 


More information about the Mercurial-devel mailing list