37def main(git_repo, svn_repo, output=os.getcwd()):
39 Main function to execute the script.
44 __temp_path = os.path.join(os.getcwd(),Utility.GetTemporaryFileName(extension=
""))
46 print(
"==================================")
47 print(
"Processing %s" % git_repo.upper())
48 print(
"==================================")
49 svn.remote.RemoteClient(svn_repo).checkout(__temp_path)
52 bash = os.path.join(os.path.dirname(os.path.dirname(Utility.GetExecutable(git.Git.GIT_PYTHON_GIT_EXECUTABLE, get_path=
True)[-1])),
"bin",
"bash.exe")
54 command =
"svn log -q | awk -F"+
" '|' '/^r/ "+
'{sub("^ ", "", $2); sub(" $", "", $2); ' +
'print $2" = "$2" <"$2">"}'+
"' | sort -u > authors-git.txt"
55 with open(
"authors.sh",
"w")
as script: script.write(command)
56 command =
" ".join([
'"'+bash+
'"',
"-c",
"./authors.sh"])
58 subprocess.Popen(command, shell=
True);
61 if os.path.exists(os.path.join(os.getcwd(),
"authors-git.txt")):
62 shutil.move(os.path.join(os.getcwd(),
"authors-git.txt"),os.path.join(Scratch,
"authors-git.txt"))
67 try: Utility.DeleteRedundantFolders(__temp_path, ignore_readonly=
True);
break
69 source = os.path.dirname(svn_repo)
70 trunk = Utility.PathLeaf(svn_repo)
73 g = git.Repo.init(os.path.join(os.getcwd(),git_repo))
74 if Utility.GetPlatform() ==
"windows": g.git.execute(
"git config --global core.longpaths true")
77 command =
"git svn clone "+source+
" --no-metadata --no-minimize-url -T "+trunk+
" --authors-file="+str(os.path.join(
'"'+os.getcwd(),
"authors-git.txt"+
'"'))+
" "+
"."
80 while not glob.glob(os.path.join(os.getcwd(),git_repo,
'*')):
83 g.git.execute(shlex.split(command,posix=
not os.name.lower()
in [
"nt"]))
84 except Exception
as e:
88 print(
"==================================")
89 print(
"This error is deemed non-critical. Ignoring")
90 print(
"==================================")
94 Utility.DeleteFilesbyEnding(
"authors-git.txt")
95 if os.getcwd() != output: Utility.MoveIO(git_repo, os.path.join(output,git_repo))