#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import sys
import shutil
import subprocess
"""
递归强制解锁(break lock)指定目录下的文件
用法:python svn-unlock.py [targetDir]
作者:koqiui@163.com
"""
# 当前脚本所在目录
__dir__ = os.path.abspath(os.path.dirname(__file__))
# 要解锁的目标目录(默认为本脚本所在目录)
targetDir = __dir__
# 忽略的目录
ignoredDirNames = ['.svn', 'target']
def unlockDirFiles(theDir):
baseName = os.path.basename(theDir)
if baseName not in ignoredDirNames:
print('正在解锁目录 {0}'.format(theDir))
subprocess.call([
'svn', 'unlock', '--force', os.path.join(theDir, '*.*')
])
# ------------------------------------
fileItems = os.listdir(theDir)
for fileItem in fileItems:
filePath = os.path.join(theDir, fileItem)
if os.path.isdir(filePath):
unlockDirFiles(filePath)
# ------------------------------------
# 单独调用
if __name__ == '__main__':
argCo
快速递归解锁svn锁定的目录下的文件
最新推荐文章于 2026-04-22 03:01:26 发布


1154

被折叠的 条评论
为什么被折叠?



