Make the -g/--git option the default, removing the svn equivalents

This commit is contained in:
Alexander van Gessel 2012-03-04 19:35:45 +01:00
parent 62caeb242f
commit 7ea2f8bc39

View File

@ -49,7 +49,6 @@ class tempdir:
logging.debug("removed tempdir '%s'", self.path)
if __name__ == "__main__":
use_git = False
git_version = None
git_userpass = None
@ -155,44 +154,27 @@ if __name__ == "__main__":
# If the directory in svn doesn't exist we need to create and commit it.
message = "wescamp.py automatic update"
if use_git:
github = libgithub.GitHub(svn_dir, git_version, userpass=git_userpass)
github = libgithub.GitHub(svn_dir, git_version, userpass=git_userpass)
if(os.path.isdir(svn_dir + "/" + addon) == False):
logging.info("Creating directory in svn '%s'.",
svn_dir + "/" + addon)
if use_git:
if not github.addon_exists(addon):
github.create_addon(addon)
else:
svn = libsvn.SVN(svn_dir)
# Don't update we're in the root and if we update the status of all
# other campaigns is lost and no more updates are executed.
os.mkdir(svn_dir + "/" + addon)
res = svn.add(addon)
res = svn.commit("wescamp_client: adding directory for initial "
+ "inclusion of addon '" + addon + "'", [addon])
if not github.addon_exists(addon):
github.create_addon(addon)
# Update the directory
if use_git:
addon_obj = github.addon(addon)
addon_obj.update()
else:
svn = libsvn.SVN(svn_dir + "/" + addon)
svn.update()
addon_obj = github.addon(addon)
addon_obj.update()
# Translation needs to be prevented from the campaign to overwrite
# the ones in wescamp.
# The other files are present in wescamp and shouldn't be deleted.
ignore_list = ["translations", "po", "campaign.def",
"config.status", "Makefile"]
if(addon_obj.sync_from(temp_dir, ignore_list)
if use_git
else svn.copy_to_svn(temp_dir, ignore_list)):
if(addon_obj.sync_from(temp_dir, ignore_list)):
(addon_obj if use_git else svn).commit("wescamp_client: automatic update of addon '"
addon_obj.commit("wescamp_client: automatic update of addon '"
+ addon + "'")
logging.info("New version of addon '%s' uploaded.", addon)
else:
@ -222,17 +204,11 @@ if __name__ == "__main__":
server, addon, temp_dir, svn_dir)
# update the wescamp checkout for the translation,
if use_git:
addon_obj = libgithub.GitHub(wescamp, git_version, userpass=git_userpass).addon(addon)
else:
svn = libsvn.SVN(wescamp + "/" + addon)
addon_obj = libgithub.GitHub(wescamp, git_version, userpass=git_userpass).addon(addon)
# The result of the update can be ignored, no changes when updating
# doesn't mean no changes to the translations.
if use_git:
addon_obj.update()
else:
svn.update()
addon_obj.update()
# test whether the svn has a translations dir, if not we can stop
if(os.path.isdir(wescamp + "/"
@ -245,13 +221,9 @@ if __name__ == "__main__":
return True
# Export the entire addon data dir.
if use_git:
source = os.path.join(wescamp, addon, addon)
dest = os.path.join(temp_dir, addon)
shutil.copytree(source, dest)
else:
svn_addon = libsvn.SVN(wescamp + "/" + addon + "/" + addon)
svn_addon.export(temp_dir + "/" + addon)
source = os.path.join(wescamp, addon, addon)
dest = os.path.join(temp_dir, addon)
shutil.copytree(source, dest)
# If it is the old format with the addon.cfg copy that as well.
svn_cfg = wescamp + "/" + addon + "/" + addon + ".cfg"
@ -292,19 +264,10 @@ if __name__ == "__main__":
logging.debug("Erase addon from wescamp addon = '%s' svn_dir = '%s'",
addon, svn_dir)
if use_git:
addon_obj = libgithub.GitHub(svn_dir, git_version, userpass=git_userpass).addon(addon)
addon_obj = libgithub.GitHub(svn_dir, git_version, userpass=git_userpass).addon(addon)
# Note: this is probably not implemented, as it would destroy a repository, including the history.
addon_obj.erase()
else:
svn = libsvn.SVN(svn_dir)
svn.update(None, [addon])
svn.remove(addon)
svn.commit("Erasing addon " + addon)
# Note: this is probably not implemented, as it would destroy a repository, including the history.
addon_obj.erase()
"""Checkout all add-ons of one wesnoth version from wescamp.
@ -423,16 +386,17 @@ if __name__ == "__main__":
password = options.password
if(options.git):
use_git = True
git_userpass = options.github_login
if not wescamp:
logging.error("No wescamp checkout specified. Needed for git usage.")
sys.exit(2)
try:
git_version = wescamp.split("-")[-1].strip("/").split("/")[-1]
except:
logging.error("Wescamp directory path does not end in a version suffix. Currently needed for git usage.")
sys.exit(2)
pass
#TODO: warning of not being needed any more
git_userpass = options.github_login
if not wescamp:
logging.error("No wescamp checkout specified. Needed for git usage.")
sys.exit(2)
try:
git_version = wescamp.split("-")[-1].strip("/").split("/")[-1]
except:
logging.error("Wescamp directory path does not end in a version suffix. Currently needed for git usage.")
sys.exit(2)
# List the addons on the server and optional filter on translatable
# addons.
@ -639,10 +603,6 @@ if __name__ == "__main__":
logging.error("No wescamp checkout specified.")
sys.exit(2)
if not use_git:
logging.error("The checkout option is for git only. If you're still using svn for some reason, you can use svn co.")
sys.exit(2)
try:
checkout(wescamp, git_version, userpass=git_userpass)
except libgithub.Error, e: