Patchwork [2,of,3,v2] posix: use local reference to removedirs

login
register
mail settings
Submitter Ryan McElroy
Date March 21, 2017, 1:53 p.m.
Message ID <9fbbf88888d286cce1b4.1490104399@devbig314.prn1.facebook.com>
Download mbox | patch
Permalink /patch/19516/
State Accepted
Headers show

Comments

Ryan McElroy - March 21, 2017, 1:53 p.m.
# HG changeset patch
# User Ryan McElroy <rmcelroy@fb.com>
# Date 1490104228 25200
#      Tue Mar 21 06:50:28 2017 -0700
# Node ID 9fbbf88888d286cce1b48b3defc6c50a09596367
# Parent  281fd76b392c38bd5299198810f85f9e3c2034be
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.

Patch

diff --git a/mercurial/posix.py b/mercurial/posix.py
--- a/mercurial/posix.py
+++ b/mercurial/posix.py
@@ -545,7 +545,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