Patchwork [STABLE] hghave: fix 'rmcwd' to ensure temporary directory is removed

login
register
mail settings
Submitter Yuya Nishihara
Date Nov. 1, 2016, 12:44 p.m.
Message ID <389cbfe63586d2b4c53e.1478004245@mimosa>
Download mbox | patch
Permalink /patch/17241/
State Accepted
Headers show

Comments

Yuya Nishihara - Nov. 1, 2016, 12:44 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1478002473 -32400
#      Tue Nov 01 21:14:33 2016 +0900
# Branch stable
# Node ID 389cbfe63586d2b4c53e3220fcc01b211906ba85
# Parent  cac4ca036dff882c71f48f3130b72597d3e1fc64
hghave: fix 'rmcwd' to ensure temporary directory is removed

On platforms where cwd can't be removed, it should try rmdir() after chdir
to the original cwd.
Pierre-Yves David - Nov. 1, 2016, 2:23 p.m.
On 11/01/2016 01:44 PM, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1478002473 -32400
> #      Tue Nov 01 21:14:33 2016 +0900
> # Branch stable
> # Node ID 389cbfe63586d2b4c53e3220fcc01b211906ba85
> # Parent  cac4ca036dff882c71f48f3130b72597d3e1fc64
> hghave: fix 'rmcwd' to ensure temporary directory is removed

pushed, thanks.

cheer

Patch

diff --git a/tests/hghave.py b/tests/hghave.py
--- a/tests/hghave.py
+++ b/tests/hghave.py
@@ -360,6 +360,11 @@  def has_rmcwd():
         return False
     finally:
         os.chdir(ocwd)
+        # clean up temp dir on platforms where cwd can't be removed
+        try:
+            os.rmdir(temp)
+        except OSError:
+            pass
 
 @check("tla", "GNU Arch tla client")
 def has_tla():