# -*- 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
相关推荐
咕白m62512 小时前
用 Python 实现一键批量查找与替换 Excel 数据SelectDB1 天前
Apache Doris Python UDF:让 SQL 直接调用 Python 生态,支撑 Agent 时代复杂业务逻辑荣码2 天前
GraphRAG:普通RAG只能回答"点"的问题,我踩了4个坑才搞懂金銀銅鐵2 天前
[Python] 基于欧几里得算法,实现分数约分计算器Lyn_Li2 天前
Kaggle Top 5 | 198只股票、200条数据的金融预测——BattleFin高分方案从零复现小九九的爸爸2 天前
前端想要入门Agent开发,要具备哪些Python基础?阿耶同学2 天前
手把手教你用 LangGraph 搭建三层嵌套 Agent 架构花酒锄作田3 天前
Pydantic校验配置文件hboot3 天前
AI工程师第四课 - 深度学习入门ZhengEnCi3 天前
P2M-Matplotlib折线图完全指南-从数据可视化到趋势分析的Python绘图利器