Exemplo n.º 1
0
def main():

	svn_args = arg.repos_args("svn")
	if svn_args == "-m":
		os.system("svn st | grep '^M' | awk '{print $2}'")
	elif svn_args == "-d":
		os.system("svn st | grep '^!' | awk '{print $2}'")
	elif svn_args == "-o":
		os.system("svn st | grep '^?' | awk '{print $2}'")
	# Clean all svn repos at current path
	elif svn_args == "-c":
		current_path = os.getcwd()
		for r in os.walk(current_path).next()[1]:
			rev = os.popen("svn info " + r + " | awk '/Revision:/ { print $2 }'").read()
			rev = "-svn" + rev.split("\n")[0]			
			# patch backup
			cmd.tryit("svn st " + r + " | grep '^M' | awk '{print $2}' | xargs svn revert ")
			cmd.tryit("svn st " + r + " | grep '^?' | awk '{print $2}' | xargs rm -rf ")
			cmd.tryit("find "   + r + " -name \"*.o\" | xargs rm -f")
			cmd.tryit("svn up " + r)
	# backup all svn repos at current path
	elif svn_args == "-b":
		current_path = os.getcwd()
		for r in os.walk(current_path).next()[1]:
			rev = os.popen("svn info " + r + " | awk '/Revision:/ { print $2 }'").read()
			rev = "-svn" + rev.split("\n")[0]
			cmd.tryit("tar -jcf " + r + rev + ".tar.bz2 " + r)
	elif svn_args == "-s":
		printf.status("svn info")
		os.system("svn info")

	sys.exit(0)
Exemplo n.º 2
0
def main():
	svn_args = arg.repos_args("svn")

	if svn_args['-p'] != "":
		path.push()
		path.change(svn_args['-p'])	
	
	if svn_args['-m'] == "true":
		os.system("svn st --no-ignore | grep '^M' | awk '{print $2}'")
	elif svn_args['-d'] == "true":
		os.system("svn st --no-ignore | grep '^!' | awk '{print $2}'")
	elif svn_args['-o'] == "true":
		os.system("svn st --no-ignore | grep '^?' | awk '{print $2}'")
	# Clean all svn repos at current path
	elif svn_args['-r'] == "true":
		current_path = os.getcwd()
		for r in os.walk(current_path).next()[1]:
			rev = os.popen("svn info " + r + " | awk '/Revision:/ { print $2 }'").read()
			rev = "-svn" + rev.split("\n")[0]			
			# patch backup
			cmd.tryit("svn st --no-ignore " + r + " | grep '^M' | awk '{print $2}' | xargs svn revert ")
			cmd.tryit("svn st --no-ignore " + r + " | grep '^?' | awk '{print $2}' | xargs rm -rf ")
			cmd.tryit("find "   + r + " -name \"*.o\" | xargs rm -f")
			cmd.tryit("svn up " + r)
	# backup all svn repos at current path
	elif svn_args['-b'] == "true":
		current_path = os.getcwd()
		for r in os.walk(current_path).next()[1]:
			rev = os.popen("svn info " + r + " | awk '/Revision:/ { print $2 }'").read()
			rev = "-svn" + rev.split("\n")[0]
			cmd.tryit("tar -jcf " + r + rev + ".tar.bz2 " + r)
	elif svn_args == "-s":
		printf.status("svn info")
		os.system("svn info")

	if svn_args['-p'] != "":
		path.pop()
	sys.exit(0)
Exemplo n.º 3
0
	def patch_new(self):
		global patch_cmd
		printf.silence("源码生成补丁 ...")
		patch_cnt = 0

		# 生成单个补丁文件
		repos_diff = self.out_path + "/" + self.ini_args[glb.source_repos] + ".diff"
		fp = codecs.open(repos_diff, "w", "utf-8")
		fp.close()

		out_modify  = os.popen(patch_cmd['list_modify']).read()
		# 判断是否需要对非托管文件打补丁
		out_untrack = ""
		if self.patch_args['-u'] == 0:
			for i in self.in_all_path: # 指定非托管文件打补丁路径,".h"、".c"、".cpp"、".mk"
				path.push()
				path.change(i)
				path_paste = i.replace(self.in_path + "/","")
				out_untrack_all = os.popen(patch_cmd['list_untrack']).read()
				path.pop()
				for i in out_untrack_all.split("\n"):
					if i == "":
						continue
					if i.upper().find(".H") == -1: # 文件过滤
						if i.upper().find(".C") == -1:
							if i.upper().find(".CPP") == -1:
								if i.upper().find(".MK") == -1:
									continue
					out_untrack = out_untrack + path_paste + "/" + i + "\n"
		else:
			out_untrack = os.popen(patch_cmd['list_untrack']).read()

		# 生成修改文件补丁
		cmd.do("rm -f " + self.out_path + "/*" + glb.patch_filetype) # 清除老补丁
		cmd.do("rm -f " + self.out_path + "/*.diff") # 清除老补丁
		patch_list = out_modify.split("\n")
		printf.status("Modify files: " + str(len(patch_list) - 1))
		for i in patch_list:
			if i == "":
				continue
			patch_cnt = patch_cnt + 1
			name = self.out_path + "/" + self.ini_args[glb.source_repos] + "-" + i.replace("/","_") + glb.patch_filetype
			cmd.do(patch_cmd['diff'] + " " + i + " > " + name)
			cmd.do(patch_cmd['diff'] + " " + i + " >> " + repos_diff)

		# 生成未托管文件补丁
		patch_list = out_untrack.split("\n")
		printf.status("Untrack files: " + str(len(patch_list) - 1))
		for i in patch_list:
			if i == "" or i.find(glb.patch_flag) != -1:
				continue
			patch_cnt = patch_cnt + 1
			name = self.out_path + "/" + "git-" + i.replace("/","_") + glb.patch_filetype
			cmd.tryit("git diff /dev/null " + i + " > " + name)
			cmd.tryit("git diff /dev/null " + i + " >> " + repos_diff)

		# 备份新生成的补丁
		if os.path.isdir(self.out_path):
			patch_list_new = []
			new_patchs = self.out_path + "/*" + glb.patch_filetype
			new_diff = self.out_path + "/*.diff"
			patch_list_new.extend(glob.glob(new_patchs))
			if len(patch_list_new) > 0:
				patch_bak_path = self.out_path + "/" + time.timestamp()
				cmd.do("mkdir -p " + patch_bak_path)
				cmd.do("cp " + new_patchs + " " + patch_bak_path)
				cmd.do("cp " + new_diff + " " + patch_bak_path)

		# 完成操作退出
		printf.status("Total patch: " + str(patch_cnt))
		if patch_cnt != 0:
			self.create_flag(1)
		else:
			self.create_flag(0)