aboutsummaryrefslogtreecommitdiffstats
path: root/RepSys/svn.py
diff options
context:
space:
mode:
authorBogdano Arendartchuk <bogdano@mandriva.org>2007-11-15 05:30:56 +0000
committerBogdano Arendartchuk <bogdano@mandriva.org>2007-11-15 05:30:56 +0000
commite196e676aa302cd3a1f7b37f259491a8b03cc483 (patch)
tree47a3bcd478e678037e748d661ba861a6a8f44328 /RepSys/svn.py
parentfa6fb5c9da640532db63db2aa9111c523cb35fe4 (diff)
downloadmgarepo-e196e676aa302cd3a1f7b37f259491a8b03cc483.tar
mgarepo-e196e676aa302cd3a1f7b37f259491a8b03cc483.tar.gz
mgarepo-e196e676aa302cd3a1f7b37f259491a8b03cc483.tar.bz2
mgarepo-e196e676aa302cd3a1f7b37f259491a8b03cc483.tar.xz
mgarepo-e196e676aa302cd3a1f7b37f259491a8b03cc483.zip
Dropped all authenticated access support
Subversion authentication has been broken for a long time and the workarounds weren't decent. It will be back in 1.7.x. Also added configuration option svn-command in the global section, allowing to replace the default svn command. And use svn+ssh:// URLs to be in BatchMode, in order to not have any interactivity at all with ssh
Diffstat (limited to 'RepSys/svn.py')
-rw-r--r--RepSys/svn.py79
1 files changed, 19 insertions, 60 deletions
diff --git a/RepSys/svn.py b/RepSys/svn.py
index b91af0c..3244c3a 100644
--- a/RepSys/svn.py
+++ b/RepSys/svn.py
@@ -1,4 +1,4 @@
-from RepSys import Error, config, pexpect
+from RepSys import Error, config
from RepSys.util import execcmd, get_auth
import sys
import re
@@ -18,67 +18,26 @@ class SVNLogEntry:
return cmp(self.date, other.date)
class SVN:
- def __init__(self, username=None, password=None, noauth=0, baseurl=None):
- self.noauth = noauth or (
- baseurl and (
- baseurl.startswith("file:") or
- baseurl.startswith("svn+ssh:")))
- if not self.noauth: # argh
- self.username, self.password = get_auth()
-
-
def _execsvn(self, *args, **kwargs):
- cmdstr = "svn "+" ".join(args)
- if kwargs.get("local") or kwargs.get("noauth") or self.noauth:
+ if not kwargs.get("show"):
+ args = list(args)
+ args.append("--non-interactive")
+ svn_command = config.get("global", "svn-command",
+ "SVN_SSH='ssh -o \"BatchMode yes\"' svn")
+ cmdstr = svn_command + " " + " ".join(args)
+ try:
return execcmd(cmdstr, **kwargs)
- show = kwargs.get("show")
- noerror = kwargs.get("noerror")
- p = pexpect.spawn(cmdstr, timeout=1)
- p.setmaxread(1024)
- p.setecho(False)
- outlist = []
- while True:
- i = p.expect_exact([pexpect.EOF, pexpect.TIMEOUT,
- "username:", "password:",
- "(p)ermanently?",
- "Authorization failed"])
- if i == 0:
- if show and p.before:
- print p.before,
- outlist.append(p.before)
- break
- elif i == 1:
- if show and p.before:
- print p.before,
- outlist.append(p.before)
- elif i == 2:
- p.sendline(self.username)
- outlist = []
- elif i == 3:
- p.sendline(self.password)
- outlist = []
- elif i == 4:
- p.sendline("p")
- outlist = []
- elif i == 5:
- if not noerror:
- raise Error, "authorization failed"
- else:
- break
- while p.isalive():
- try:
- time.sleep(1)
- except (pexpect.TIMEOUT, pexpect.EOF):
- # Continue until the child dies
- pass
- status, output = p.exitstatus, "".join(outlist).strip()
- if status != 0 and not kwargs.get("noerror"):
- sys.stderr.write(cmdstr)
- sys.stderr.write("\n")
- sys.stderr.write(output)
- sys.stderr.write("\n")
- raise Error, "command failed: "+cmdstr
- return status, output
+ except Error, e:
+ if "Permission denied" in e.message:
+ raise Error, ("%s\n"
+ "Seems ssh-agent or ForwardAgent are not setup, see "
+ "http://wiki.mandriva.com/en/Development/Docs/Contributor_Tricks#SSH_configuration"
+ " for more information." % e)
+ elif "authorization failed":
+ raise Error, ("%s\n"
+ "Note that repsys does not support any HTTP "
+ "authenticated access." % e)
+ raise
def _execsvn_success(self, *args, **kwargs):
status, output = self._execsvn(*args, **kwargs)