svn批量的添加ignore
svn没有批量添加ignore file的功能,只能一个个目录去设置,故写了脚本自动化的执行
使用了svn propset,故改了ignore file,可以反复的执行此脚本
#!/usr/bin/python
# -*- coding: utf8 -*-
# antsmallant 2018.09.05 import time
import os
import sys
import commands def print_usage():
myname = os.path.basename(sys.argv[0])
help = '''
#######################################################
usage : {0} ignore_file
e.g : {0} ../server/ignore.txt ignore_file looks like:
bin/3rd/a
bin/b
bin/c/d/e #######################################################
'''.format(myname)
print(help) #exe shell cmd, return True if no error, otherwise False
def exe_cmd(cmdstr):
print("exe_cmd, cmdstr={0}".format(cmdstr))
status, output = commands.getstatusoutput(cmdstr)
if status != 0:
print("exe_cmd fail, error={0}, errorcode={1}, cmdstr={2}".format(output, status>>8, cmdstr))
return False
print("exe_cmd success, output={0}".format(output))
return True #retrun dict
def parse_ignore_file(file_path):
f = open(file_path, "r")
allline = f.readlines()
f.close()
ret = {}
for line in allline:
line = line.strip()
line = line.replace("\n", "")
line = line.replace("\r", "")
if len(line) == 0:
continue
dn = os.path.dirname(line)
bn = os.path.basename(line)
if ret.has_key(dn):
ret[dn].append(bn)
else:
ret[dn] = []
ret[dn].append(bn)
return ret def set_ignore(dn, filelist):
assert len(filelist) > 0, "filelist has no data"+str(filelist)
print("set_ignore" + dn)
#make temp ignore file
temp_ignore = os.path.join(dn, "temp_ignore.txt")
f = open(temp_ignore, "w")
if not f:
return False
for i in filelist:
f.write(i+"\n")
f.flush()
f.close()
cmd = "cd {0} && svn up && svn propset svn:ignore ./ -F {1}".format(dn, temp_ignore)
ok = exe_cmd(cmd)
if not ok:
os.remove(temp_ignore)
return False
cmd = "cd {0}/../ && svn up && svn ci -m 'add ignore' ./".format(dn)
ok = exe_cmd(cmd)
if not ok:
os.remove(temp_ignore)
return False
os.remove(temp_ignore)
return True def main():
if len(sys.argv) < 2:
print("err: arg not given")
print_usage()
return False
ignore_file = os.path.abspath(sys.argv[1])
print("ignore_file: " + ignore_file)
if not os.path.exists(ignore_file):
print("ignore_file not exists")
return False
dn = os.path.dirname(ignore_file)
print("dirname: " + dn)
file_2_ignore = parse_ignore_file(ignore_file)
for k, v in file_2_ignore.items():
ok = set_ignore(os.path.join(dn, k), v)
if not ok:
print("something wrong when doing: "+k+" "+str(v))
return False
return True if __name__ == '__main__':
main()
svn批量的添加ignore的更多相关文章
- android stuido 在线安装svn插件,添加版本库无响应
问题:android stuido 中在线安装svn插件,添加版本库无响应. 原因: 由于android stuido 版本较高,在线安装1.6x 版本的svn,添加版本库一直没有响应,最后卡死.. ...
- 利用Dnspod api批量更新添加DNS解析【python脚本】 - 推酷
利用Dnspod api批量更新添加DNS解析[python脚本] - 推酷 undefined
- svn提交后 添加注释
svn 提交后添加注释 第一步: 第二步: 第三步:提交就可以了. 注意:如果svn服务器管理员没有激活pre-revprop-change这个hook,会出现 需要让svn服务器管理员没有激活pre ...
- 解决Git在添加ignore文件之前就提交了项目无法再过滤问题
由于未添加ignore文件造成提交的项目很大(包含生成的二进制文件).所以我们可以将编译生成的文件进行过滤,避免添加到版本库中了. 首先为避免冲突需要先同步下远程仓库 $ git pull 在本地项目 ...
- linux svn 批量添加
近期开始用svn来进行代码版本的维护管理,之前一直用git,两个感觉大同小异.用svn命令行来添加文件的话需要一个一个的选,很是蛋疼,于是就写了个shell脚本,批量添加文件,还在改进中... #!/ ...
- Eclipse中SVN设置文件为ignore后重新添加至版本控制
先前把需要版本控制的文件夹ignore了,用了很长时间找解决方法,结果发现竟如此简单,对eclipse的功能不熟悉啊. 方法如下: 在Window->Show View -> Naviga ...
- svn 批量添加命令
svn st | awk '{if ($1 == "?") {print $2} }' | xargs svn add
- zabbix利用api批量添加item,并且批量配置添加graph
关于zabbix的API见,zabbixAPI 1item批量添加 我是根据我这边的具体情况来做的,本来想在模板里面添加item,但是看了看API不支持,只是支持在host里面添加,所以我先在一个ho ...
- svn 强制用户添加注释 和 允许用户修改注释
当我们用TortoiseSVN提交代码时,有很多人不喜欢写注释,导致以后代码版本多,也不清楚哪个版本到底改了什么东西.所以在提交的时候,我会强制要求添加注释.这是如何实现的?这个话题就涉及到了svn的 ...
- svn 批量更新 bat脚本
由于有多个程序放在svn上管理,每天都要进入相应的目录进行svn 更新操作,现在写了一个简单的脚本进行批量自动更新. Code@echo off @echo ********************* ...
随机推荐
- DSP(数字信号处理)与监控摄像机相关技术解读
提起安防领域,我们第一个想到的应该就是监控摄像机了,它对于安防的重要性,就像人的眼睛对于人的作用一样,是重要的信息获取来源. 监控摄像机广泛应用于学校.公司.银行.交通.平安城市等多个安保领域. 广州 ...
- 【文献阅读】Automatic berthing for an underactuated unmanned surface vehicle: A real-time motion planning approach
(1)文章工作 This paper presents Extended Dynamic Window Approach (EDWA) for the automatic berthing of an ...
- java okio 找不到的问题
问题描述: okio 找不到的问题 解决办法: 下载 jar_files.zip 在idea-File-Project Structure- Project Settings - Libraries ...
- Hyper-v 安装openwrt
安装注意事项: 1.只能选一代,网卡可以使用新版2.网卡高级设置,MAC地址欺骗一定要选上,不选外部交换机不能上网.3.防火墙做wan口转发4.防火墙wan口,两个reject改为 accept . ...
- jupyter notebook代码无法运行
如果是anaconda的话,直接就带有jupyter而不需要重新安装,你这样子就是路径混乱了.先输入jupyter kernelspec list查看安装的内核和位置,然后进入显示的安装目录,打开ke ...
- ONOS-2.2在IntelliJ IDEA进入调试模式
转载https://blog.csdn.net/fsdgfsf/article/details/90369709 在ONOS2.2中使用IDEA打开并支持断点调试 1.让环境变量生效 . /etc/p ...
- 为什么Controller层注入的是Service接口,而不是ServiceImpl实现类
转自csdn--https://blog.csdn.net/weixin_39565597/article/details/78078728 今天看代码发现,写法和自己理解的java写法不一致,就查找 ...
- python中的链表推导式
python中的链表推导式 博客分类: Python Python num=[1,2,3] myvec=[[x,x*2] for x in num] #嵌套一个链表,格式为一个数和他的平方 prin ...
- unity默认管线lightmap
lightmap采样 https://blog.csdn.net/wodownload2/article/details/94431040
- JDBC之Connection
Connection 目录 Connection Java连接MySQL Connection必备知识点 利用JDBC使用Connection 问题一:为什么Java操作数据库的连接不是越多越好 问题 ...