Automatically remove Subversion unversioned files

前端 未结 30 3089
感情败类
感情败类 2020-11-28 18:54

Does anybody know a way to recursively remove all files in a working copy that are not under version control? (I need this to get more reliable results in my automatic build

30条回答
  •  情深已故
    2020-11-28 19:00

    I would add this as a comment to Thomas Watnedal's answer , but can't yet.

    A minor issue with it (which won't affect Windows) is that it only checks for files or directories. For Unix like systems where symbolic links may be present, it is necessary to change the line:

    if os.path.isfile(fullpath):
    

    to

    if os.path.isfile(fullpath) or os.path.islink(fullpath):
    

    to also remove links.

    For me, changing the last line if match: removeall(match.group(1)) into

        if match:
            print "Removing " + match.group(1)
            removeall(match.group(1))
    

    so that it displays what it is removing was useful too.

    Depending on the use case, the ?[\?ID] part of the regular expression may be better as ?[\?I], as the D also removes deleted files, which were under version control. I want to use this to build in a clean, checked in folder, so there should be no files in a D state.

提交回复
热议问题