Patchwork [1,of,3] keyword: really clean up kwdemo temp tree

login
register
mail settings
Submitter Christian Ebert
Date Aug. 2, 2014, 8:48 a.m.
Message ID <74bfbf5ddd132a286b54.1406969311@1.0.0.127.in-addr.arpa>
Download mbox | patch
Permalink /patch/5227/
State Accepted
Headers show

Comments

Christian Ebert - Aug. 2, 2014, 8:48 a.m.
# HG changeset patch
# User Christian Ebert <blacktrash@gmx.net>
# Date 1406969051 -3600
#      Sat Aug 02 09:44:11 2014 +0100
# Node ID 74bfbf5ddd132a286b54d6acefdf3d8628390423
# Parent  3467cf39aae688e844d5c1c22b7daa85c590bef9
keyword: really clean up kwdemo temp tree

Patch

diff -r 3467cf39aae6 -r 74bfbf5ddd13 hgext/keyword.py
--- a/hgext/keyword.py	Fri Aug 01 18:32:52 2014 -0500
+++ b/hgext/keyword.py	Sat Aug 02 09:44:11 2014 +0100
@@ -87,7 +87,7 @@  from mercurial import localrepo, match, 
 from mercurial import scmutil, pathutil
 from mercurial.hgweb import webcommands
 from mercurial.i18n import _
-import os, re, shutil, tempfile
+import os, re, tempfile
 
 cmdtable = {}
 command = cmdutil.command(cmdtable)
@@ -450,7 +450,12 @@  def demo(ui, repo, *args, **opts):
     repo.commit(text=msg)
     ui.status(_('\n\tkeywords expanded\n'))
     ui.write(repo.wread(fn))
-    shutil.rmtree(tmpdir, ignore_errors=True)
+    for root, dirs, files in os.walk(tmpdir, topdown=False):
+        for f in files:
+            util.unlink(os.path.join(root, f))
+        for d in dirs:
+            os.rmdir(os.path.join(root, d))
+    os.rmdir(tmpdir)
 
 @command('kwexpand',
     commands.walkopts,