SVN版本差异文件对比小工具
SVN版本差异文件对比小工具
基于测试需求,经常出现计划外内容修改,加之敏捷开发下没有过多时间用于功能全量回归,为避免出现漏测,通过把控版本差异文件,把测试覆盖范围尽量扩大
PS:pysvn无法正常使用 也是无奈
功能主体
目前简略版只实现了版本差异文件提取功能,功能后续再持续增加:1、支持版本号和本地地址录入 2、支持文件可视化输出
from tkinter import *
import os
import re
#这里由于创建的UI量有限 直接莽
#可视化操作界面
def CreateUI():window = Tk()window.title("svn对比工具")window.geometry("800x300+500+200")# 版本号输入框UIfirst_label = Label(window, text="前置版本号", font=12, bg="white", width=10, height=2, justify=CENTER)first_entry = Entry(window, width=30, bg="white", fg="blue")first_label.place(x=30, y=40)first_entry.place(x=135, y=50)last_label = Label(window, text="后置版本号", font=12, bg="white", width=10, height=2, justify=CENTER)last_entry = Entry(window, width=30, bg="white", fg="blue")last_label.place(x=30, y=100)last_entry.place(x=135, y=110)path_label = Label(window, text="版本地址", font=12, bg="white", width=10, height=2, justify=CENTER)path_entry = Entry(window, width=30, bg="white", fg="blue")path_label.place(x=30, y=160)path_entry.place(x=135, y=170)# 创建输出文本框back_text = Text(window, width=60, height=20, fg="blue", bg="white")back_text.place(x=360, y=20)# 执行按钮do_btn = Button(window, text="执行对比", bg="white", font=12, relief="raised", width=20, height=3,command=lambda:GetInput(first_entry,last_entry,path_entry,back_text))do_btn.place(x=75, y=220)window.mainloop()
#对比回调方法:前置版本号、后置版本号、本地SVN地址、文本输出控件
def Commpare(first,last,path,back_text):# 获取svn 版本记录差异命令行cmd_dir = "svn log -r " +first+":"+last +" "+path +" -v"#调用执行back=os.popen(cmd_dir)res=back.read()for result in res.splitlines():#这里的M指的是svn的status# svn status命令查看svn状态# A:add,新增# C:conflict,冲突; tc以他们改得为准# D:delete,删除# M:modify,本地已经修改# G:modify and merGed,本地文件修改并且和服务器的进行合并# U:update,从服务器更新# R:replace,从服务器替换# I:ignored,忽略#由此来看的话 直接用判断行中是否存在对应首字母是不稳定的#使用正则表达式截取准确文件名 \w+.\w+$ 匹配文件尾# 正则范式:dir_str="\w+.\w+$"#匹配地址最后文件名的方法:# # target=result.split("/")[-1] 通过字符分割法 取最后一个字符串# target = os.path.basename(result) 基于系统方法可直接取到文件名# # target = re.search(dir_str, result, flags=0) 通过正则表达式进行抽取#对比cmd输出格式 由“M” 匹配改成"M /"匹配字符串 可以满足只匹配到差异文件的需求if "M /" in result:target=os.path.basename(result)back_text.insert(END,target+"\n")elif "A /" in result:target = os.path.basename(result)back_text.insert(END, target + "\n")
#获取输入参数数据的方法并将查询到的数据 输出值可视化文本框
def GetInput(first_entry,last_entry,path_entry,back_text):#抽取输入内容first=first_entry.get()last=last_entry.get()path=path_entry.get()#获取版本记录数据#如果三者数据都不为空,则执行抽取if first and last and path:Commpare(first, last, path,back_text)else:print("数据为空!!")CreateUI()
简易版界面

本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
