From 3dac8f9086fdde5a9d5380c454bb9cef85451db6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20=C3=98yvind=20Karlsen?= Date: Fri, 3 Jun 2016 17:21:12 +0200 Subject: check whether target path contains either of svn or git repo --- MgaRepo/git.py | 7 ++++--- MgaRepo/svn.py | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'MgaRepo') diff --git a/MgaRepo/git.py b/MgaRepo/git.py index b91dcb2..07d57ac 100644 --- a/MgaRepo/git.py +++ b/MgaRepo/git.py @@ -18,9 +18,9 @@ class GITLogEntry(VCSLogEntry): class GIT(VCS): vcs_dirname = ".git" + vcs_name = "git" def __init__(self): VCS.__init__(self) - self.vcs_name = "git" self.vcs_command = config.get("global", "git-command", ["git"]) self.vcs_supports['clone'] = True self.env_defaults = {"GIT_SSH": self.vcs_wrapper} @@ -42,8 +42,9 @@ class GIT(VCS): return True def clone(self, url, targetpath, fullnames=True, **kwargs): - if lexists(join(targetpath, SVN.vcs_dirname)): - raise Error("Target path %s already contains svn checkout, aborting..." % targetpath) + for vcs in (SVN, GIT): + if lexists(join(targetpath, vcs.vcs_dirname)): + raise Error("target path %s already contains %s repository, aborting..." % (targetpath, vcs.vcs_name)) if url.split(':')[0].find("svn") < 0: return VCS.clone(self, url, **kwargs) else: diff --git a/MgaRepo/svn.py b/MgaRepo/svn.py index 120c19c..a9038df 100644 --- a/MgaRepo/svn.py +++ b/MgaRepo/svn.py @@ -13,9 +13,9 @@ class SVNLogEntry(VCSLogEntry): class SVN(VCS): vcs_dirname = ".svn" + vcs_name = "svn" def __init__(self): VCS.__init__(self) - self.vcs_name = "svn" self.vcs_command = config.get("global", "svn-command", ["svn"]) self.env_defaults = {"SVN_SSH": self.vcs_wrapper} -- cgit v1.2.1