From dad24be156b4bce751224cda8609bb0229c00c39 Mon Sep 17 00:00:00 2001 From: Bogdano Arendartchuk Date: Fri, 20 Oct 2006 15:47:57 +0000 Subject: - SVN.log now contains information about the changed paths --- RepSys/svn.py | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) (limited to 'RepSys/svn.py') diff --git a/RepSys/svn.py b/RepSys/svn.py index e83b072..bc565b0 100644 --- a/RepSys/svn.py +++ b/RepSys/svn.py @@ -11,6 +11,7 @@ class SVNLogEntry: self.revision = revision self.author = author self.date = date + self.changed = [] self.lines = [] def __cmp__(self, other): @@ -248,7 +249,7 @@ class SVN: return None def log(self, url, start=None, end=0, limit=None, **kwargs): - cmd = ["log", url] + cmd = ["log", "-v", url] if start is not None or end != 0: if start is not None and type(start) is not type(0): try: @@ -273,17 +274,32 @@ class SVN: return None revheader = re.compile("^r(?P[0-9]+) \| (?P[^\|]+) \| (?P[^\|]+) \| (?P[0-9]+) (?:line|lines)$") + changedpat = re.compile(r"^\s+(?P[^\s]+) (?P[^\s]+)(?: \([^\s]+ (?P[^:]+)(?:\:(?P[0-9]+))?\))?$") logseparator = "-"*72 linesleft = 0 entry = None log = [] - emptyline = 0 + appendchanged = 0 + changedheader = 0 for line in output.splitlines(): - if emptyline: - emptyline = 0 - continue line = line.rstrip() - if linesleft == 0: + if not line: + appendchanged = 0 + if changedheader: + appendchanged = 1 + changedheader = 0 + elif appendchanged: + m = changedpat.match(line) + if m: + changed = m.groupdict().copy() + from_rev = changed.get("from_rev") + if from_rev is not None: + try: + changed["from_rev"] = int(from_rev) + except (ValueError, TypeError): + raise Error, "invalid revision number in svn log" + entry.changed.append(changed) + elif linesleft == 0: if line != logseparator: m = revheader.match(line) if m: @@ -294,7 +310,7 @@ class SVN: entry = SVNLogEntry(int(m.group("revision")), m.group("author"), timetuple) log.append(entry) - emptyline = 1 + changedheader = 1 else: entry.lines.append(line) linesleft -= 1 -- cgit v1.2.1 From 47253e1456e038e9d155655f767cf05b608f69d6 Mon Sep 17 00:00:00 2001 From: Bogdano Arendartchuk Date: Fri, 20 Oct 2006 21:58:28 +0000 Subject: - fixed small bug in the svn log parser in which it was getting more lines than the entry had. --- RepSys/svn.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'RepSys/svn.py') diff --git a/RepSys/svn.py b/RepSys/svn.py index bc565b0..1483a02 100644 --- a/RepSys/svn.py +++ b/RepSys/svn.py @@ -283,12 +283,13 @@ class SVN: changedheader = 0 for line in output.splitlines(): line = line.rstrip() - if not line: - appendchanged = 0 if changedheader: appendchanged = 1 changedheader = 0 elif appendchanged: + if not line: + appendchanged = 0 + continue m = changedpat.match(line) if m: changed = m.groupdict().copy() -- cgit v1.2.1 From 275cab2de13197085229b0478ecebb1859036092 Mon Sep 17 00:00:00 2001 From: Bogdano Arendartchuk Date: Tue, 2 Jan 2007 15:23:10 +0000 Subject: Make source lines fit in 80 columns --- RepSys/svn.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'RepSys/svn.py') diff --git a/RepSys/svn.py b/RepSys/svn.py index 1483a02..4e073dc 100644 --- a/RepSys/svn.py +++ b/RepSys/svn.py @@ -205,7 +205,8 @@ class SVN: return [x.split() for x in output.split()] return None - def merge(self, url1, url2=None, rev1=None, rev2=None, path=None, **kwargs): + def merge(self, url1, url2=None, rev1=None, rev2=None, path=None, + **kwargs): cmd = ["merge"] if rev1 and rev2 and not url2: cmd.append("-r") -- cgit v1.2.1 From 2e0c7def5895fea29177718abb690b75bc21695e Mon Sep 17 00:00:00 2001 From: Bogdano Arendartchuk Date: Wed, 2 May 2007 19:41:47 +0000 Subject: Added initial support to mirrors, as requested by mrl. It was added an option "mirror" to repsys.conf, that will contain an URL to the mirror repository. Also added the subcommand "ci", which will relocate one working copy to the master repository before effectively commiting. --- RepSys/svn.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'RepSys/svn.py') diff --git a/RepSys/svn.py b/RepSys/svn.py index 4e073dc..a13db8b 100644 --- a/RepSys/svn.py +++ b/RepSys/svn.py @@ -169,6 +169,12 @@ class SVN: if status == 0: return output.splitlines() return None + + def info2(self, *args, **kwargs): + lines = self.info(*args, **kwargs) + pairs = [[w.strip() for w in line.split(":", 1)] for line in lines] + info = dict(pairs) + return info def ls(self, path, **kwargs): cmd = ["ls", path] @@ -197,6 +203,19 @@ class SVN: return [x.split() for x in output.split()] return None + def switch(self, url, oldurl=None, path=None, relocate=False, **kwargs): + cmd = ["switch"] + if relocate: + if oldurl is None: + raise Error, "You must supply the old URL when "\ + "relocating working copies" + cmd.append("--relocate") + cmd.append(oldurl) + cmd.append(url) + if path is not None: + cmd.append(path) + return self._execsvn_success(*cmd, **kwargs) + def update(self, path, **kwargs): cmd = ["update", path] self._add_revision(cmd, kwargs, optional=1) -- cgit v1.2.1 From 928b0bed6fff9a002fcd10533fd1fa464e1bc10b Mon Sep 17 00:00:00 2001 From: Bogdano Arendartchuk Date: Thu, 3 May 2007 21:03:27 +0000 Subject: Added one cheap copy of the sync subcommand from mdvsys. It required two sensitive changes: - in order to parse the spec file, "rpm" module was used, so this is the brand new package dependency; and - as RepSys already had one "rpm" module, we had to rename it to "simplerpm" in order to allow access to the module from python-rpm (I think py2.4 is still used a lot so we can't use absolute imports) --- RepSys/svn.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'RepSys/svn.py') diff --git a/RepSys/svn.py b/RepSys/svn.py index a13db8b..b4ad4e9 100644 --- a/RepSys/svn.py +++ b/RepSys/svn.py @@ -187,6 +187,8 @@ class SVN: cmd = ["status", path] if kwargs.get("verbose"): cmd.append("-v") + if kwargs.get("noignore"): + cmd.append("--no-ignore") status, output = self._execsvn(*cmd, **kwargs) if status == 0: return [x.split() for x in output.splitlines()] -- cgit v1.2.1 From 5f1a15b9c7b253c0267d05613683ac1fb5f88e6c Mon Sep 17 00:00:00 2001 From: Bogdano Arendartchuk Date: Tue, 5 Jun 2007 19:17:27 +0000 Subject: Improved (and fixed) the support to mirrors and "switch" subcommand - added the switch subcommand to quickly switch between the default and the mirrored repositories - fixed bug of generating bogus mirror URLs - make "ci" smarter by only relocation if something has been changed in the working copy and it is not already relocated. --- RepSys/svn.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'RepSys/svn.py') diff --git a/RepSys/svn.py b/RepSys/svn.py index b4ad4e9..cc3811d 100644 --- a/RepSys/svn.py +++ b/RepSys/svn.py @@ -189,6 +189,8 @@ class SVN: cmd.append("-v") if kwargs.get("noignore"): cmd.append("--no-ignore") + if kwargs.get("quiet"): + cmd.append("--quiet") status, output = self._execsvn(*cmd, **kwargs) if status == 0: return [x.split() for x in output.splitlines()] -- cgit v1.2.1 From 4b66a3a0f18650052127dbc9ba87f53c9ceca2cf Mon Sep 17 00:00:00 2001 From: Anssi Hannula Date: Thu, 7 Jun 2007 12:31:07 +0000 Subject: - use correct revision number for last commit (this commit by Andreas was accidentally reverted during SVN recovery) --- RepSys/svn.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'RepSys/svn.py') diff --git a/RepSys/svn.py b/RepSys/svn.py index cc3811d..b91af0c 100644 --- a/RepSys/svn.py +++ b/RepSys/svn.py @@ -159,8 +159,8 @@ class SVN: status, output = self._execsvn(local=True, *cmd, **kwargs) if status == 0: for line in output.splitlines(): - if line.startswith("Revision: "): - return int(line.split()[1]) + if line.startswith("Last Changed Rev: "): + return int(line.split()[3]) return None def info(self, path, **kwargs): -- cgit v1.2.1 From e196e676aa302cd3a1f7b37f259491a8b03cc483 Mon Sep 17 00:00:00 2001 From: Bogdano Arendartchuk Date: Thu, 15 Nov 2007 05:30:56 +0000 Subject: 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 --- RepSys/svn.py | 79 ++++++++++++++--------------------------------------------- 1 file changed, 19 insertions(+), 60 deletions(-) (limited to 'RepSys/svn.py') 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) -- cgit v1.2.1 From 91d55b129c0b8fb2980aaa372e053e8a3c157935 Mon Sep 17 00:00:00 2001 From: Bogdano Arendartchuk Date: Tue, 5 Feb 2008 20:49:18 +0000 Subject: Make SVN.info2 to return None when the target is not versioned --- RepSys/svn.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'RepSys/svn.py') diff --git a/RepSys/svn.py b/RepSys/svn.py index 3244c3a..4b1e9da 100644 --- a/RepSys/svn.py +++ b/RepSys/svn.py @@ -125,12 +125,14 @@ class SVN: def info(self, path, **kwargs): cmd = ["info", path] status, output = self._execsvn(local=True, *cmd, **kwargs) - if status == 0: + if status == 0 and "Not a versioned resource" not in output: return output.splitlines() return None def info2(self, *args, **kwargs): lines = self.info(*args, **kwargs) + if lines is None: + return None pairs = [[w.strip() for w in line.split(":", 1)] for line in lines] info = dict(pairs) return info -- cgit v1.2.1 From 970849f41b0370f1b225d53ee39a8fd3ed07eab3 Mon Sep 17 00:00:00 2001 From: Bogdano Arendartchuk Date: Tue, 5 Feb 2008 20:57:03 +0000 Subject: Don't use --non-interactive with the commands "add", "revert" and "cleanup" --- RepSys/svn.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'RepSys/svn.py') diff --git a/RepSys/svn.py b/RepSys/svn.py index 4b1e9da..7459033 100644 --- a/RepSys/svn.py +++ b/RepSys/svn.py @@ -19,7 +19,8 @@ class SVNLogEntry: class SVN: def _execsvn(self, *args, **kwargs): - if not kwargs.get("show"): + localcmds = ("add", "revert", "cleanup") + if not kwargs.get("show") and args[0] not in localcmds: args = list(args) args.append("--non-interactive") svn_command = config.get("global", "svn-command", -- cgit v1.2.1 From 66fb7a96a4101acc06de59492ab74f00e5c85210 Mon Sep 17 00:00:00 2001 From: Bogdano Arendartchuk Date: Tue, 5 Feb 2008 20:57:42 +0000 Subject: Fixed mistake in svn error message handling --- RepSys/svn.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'RepSys/svn.py') diff --git a/RepSys/svn.py b/RepSys/svn.py index 7459033..985329d 100644 --- a/RepSys/svn.py +++ b/RepSys/svn.py @@ -34,7 +34,7 @@ class SVN: "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": + elif "authorization failed" in e.message: raise Error, ("%s\n" "Note that repsys does not support any HTTP " "authenticated access." % e) -- cgit v1.2.1