[PATCH] D59236: Fix git-llvm crashing when trying to remove directory while cleaning

Raphael Isemann via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 11 16:06:34 PDT 2019


teemperor created this revision.
teemperor added reviewers: mehdi_amini, jlebar.
Herald added a project: LLVM.

I'm trying to push D59198 <https://reviews.llvm.org/D59198> but it seems that `git-llvm push` can't handle the fact
that I add a new directory in the patch:

  > git llvm push -n
  Pushing 1 commit:
    e7c0a9bd136 Correctly look up declarations in inline namespaces
  Traceback (most recent call last):
    File "llvm/utils/git-svn//git-llvm", line 431, in <module>
      args.func(args)
    File "llvm/utils/git-svn//git-llvm", line 385, in cmd_push
      clean_svn(svn_root)
    File "llvm/utils/git-svn//git-llvm", line 201, in clean_svn
      os.remove(os.path.join(svn_repo, filename))
  IsADirectoryError: [Errno 21] Is a directory: '.git/llvm-upstream-svn/lldb/trunk/packages/Python/lldbsuite/test/expression_command/inline-namespace'

This patch just uses shutil to delete the directory instead of trying to use `os.remove`
which only works for files.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D59236

Files:
  llvm/utils/git-svn/git-llvm


Index: llvm/utils/git-svn/git-llvm
===================================================================
--- llvm/utils/git-svn/git-llvm
+++ llvm/utils/git-svn/git-llvm
@@ -22,6 +22,7 @@
 import errno
 import os
 import re
+import shutil
 import subprocess
 import sys
 import tempfile
@@ -198,7 +199,11 @@
         if not line.startswith('?'):
             continue
         filename = line[1:].strip()
-        os.remove(os.path.join(svn_repo, filename))
+        filepath = os.path.join(svn_repo, filename)
+        if os.path.isdir(filepath):
+            shutil.rmtree(filepath)
+        else:
+            os.remove(filepath)
 
 
 def svn_init(svn_root):


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59236.190175.patch
Type: text/x-patch
Size: 659 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190311/df3006b0/attachment.bin>


More information about the llvm-commits mailing list