# -*- coding:utf-8 -*-
import subprocess
import xml.dom.minidom
ST_MISSING = "missing"
ST_MODIFIED = "modified"
ST_UNVERSIONED = "unversioned"
cmds = {ST_MISSING :"svn del \"{}\"",ST_UNVERSIONED:"svn add \"{}\""}
def runCmd(command):
ret = subprocess.run(command,shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE,timeout=1)
return ret
def svnCommit():
ret = runCmd("svn status --xml")
DOMTree = xml.dom.minidom.parseString(ret.stdout)
collection = DOMTree.documentElement
es = collection.getElementsByTagName("entry")
for entry in es:
statusNode = entry.getElementsByTagName("wc-status")[0]
filePath = entry.getAttribute("path")
status=statusNode.getAttribute("item")
# print(filePath + " = " + status)
if status in cmds:
cmd = cmds[status].format(filePath)
print(cmd)
runCmd(cmd)
runCmd("svn commit -m \"auto commit by python\" ")
svnCommit()
通过python获取svn状态
_Bruce2023-10-28 21:56
相关推荐
人工智能训练43 分钟前
【极速部署】Ubuntu24.04+CUDA13.0 玩转 VLLM 0.15.0:预编译 Wheel 包 GPU 版安装全攻略yaoming1681 小时前
python性能优化方案研究码云数智-大飞2 小时前
使用 Python 高效提取 PDF 中的表格数据并导出为 TXT 或 Excelbiuyyyxxx3 小时前
Python自动化办公学习笔记(一) 工具安装&教程极客数模3 小时前
【2026美赛赛题初步翻译F题】2026_ICM_Problem_F小鸡吃米…5 小时前
机器学习中的代价函数Li emily6 小时前
如何通过外汇API平台快速实现实时数据接入?m0_561359676 小时前
掌握Python魔法方法(Magic Methods)Ulyanov6 小时前
顶层设计——单脉冲雷达仿真器的灵魂蓝图2401_838472517 小时前
使用Python进行图像识别:CNN卷积神经网络实战