aboutsummaryrefslogtreecommitdiffstats
path: root/MgaRepo
diff options
context:
space:
mode:
authorPer Øyvind Karlsen <proyvind@moondrake.org>2016-06-03 17:13:36 +0200
committerPer Øyvind Karlsen <proyvind@moondrake.org>2016-06-03 17:13:36 +0200
commite304a2d8c4c38cf69a6a1ffc5662b4d9273225d8 (patch)
tree52d00034680c087eaaf34fd235ab20527a2e97cc /MgaRepo
parent8e45f6e95a474272ed23865fde8c056052099030 (diff)
downloadmgarepo-e304a2d8c4c38cf69a6a1ffc5662b4d9273225d8.tar
mgarepo-e304a2d8c4c38cf69a6a1ffc5662b4d9273225d8.tar.gz
mgarepo-e304a2d8c4c38cf69a6a1ffc5662b4d9273225d8.tar.bz2
mgarepo-e304a2d8c4c38cf69a6a1ffc5662b4d9273225d8.tar.xz
mgarepo-e304a2d8c4c38cf69a6a1ffc5662b4d9273225d8.zip
implement optional conversion of svn author to full name & email
Diffstat (limited to 'MgaRepo')
-rw-r--r--MgaRepo/commands/clone.py3
-rw-r--r--MgaRepo/git.py54
-rw-r--r--MgaRepo/log.py21
-rw-r--r--MgaRepo/rpmutil.py4
4 files changed, 72 insertions, 10 deletions
diff --git a/MgaRepo/commands/clone.py b/MgaRepo/commands/clone.py
index 589ec75..86793c9 100644
--- a/MgaRepo/commands/clone.py
+++ b/MgaRepo/commands/clone.py
@@ -20,6 +20,7 @@ Options:
-b The package branch
-M Do not use the mirror (use the main repository)
-h Show this message
+ -F Do not convert svn usernames to full name & email
Examples:
repsys clone pkgname
@@ -33,6 +34,8 @@ def parse_options():
parser = OptionParser(help=HELP)
parser.add_option("--distribution", "-d", dest="distro", default=None)
parser.add_option("--branch", "-b", dest="branch", default=None)
+ parser.add_option("-F", dest="fullnames", default=True,
+ action="store_false")
opts, args = parser.parse_args()
if len(args) not in (1, 2):
raise Error("invalid arguments")
diff --git a/MgaRepo/git.py b/MgaRepo/git.py
index 45c628d..b91dcb2 100644
--- a/MgaRepo/git.py
+++ b/MgaRepo/git.py
@@ -2,8 +2,10 @@ from MgaRepo import Error, config
from MgaRepo.util import execcmd
from MgaRepo.VCS import *
from MgaRepo.svn import SVN
+from MgaRepo.log import UserTagParser
from os.path import basename, dirname, abspath, lexists, join
from os import chdir, getcwd
+from tempfile import mkstemp
import sys
import re
import time
@@ -23,7 +25,23 @@ class GIT(VCS):
self.vcs_supports['clone'] = True
self.env_defaults = {"GIT_SSH": self.vcs_wrapper}
- def clone(self, url, targetpath, **kwargs):
+ def configget(self, key="", location="--local"):
+ cmd = ["config", location, "--get-regexp", key]
+ config = None
+ status, output = self._execVcs(*cmd, noerror=True)
+ if not status and output:
+ config = eval("{'" + output.replace("\n", "',\n'").replace(" ", "' : '") + "'}")
+ return config
+
+ def configset(self, config, location="--local"):
+ cmd = ("config", location)
+ for pair in config.items():
+ status, output = self._execVcs(*cmd + pair)
+ if status:
+ return False
+ 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)
if url.split(':')[0].find("svn") < 0:
@@ -44,15 +62,31 @@ class GIT(VCS):
tags = "releases"
# cloning svn braches as well should rather be optionalif reenabled..
#cmd = ["svn", "init", topurl, "--trunk="+trunk, "--tags="+tags", targetpath]
+
+
cmd = ["svn", "init", url, abspath(targetpath)]
self._execVcs(*cmd, **kwargs)
os.environ.update({"GIT_WORK_TREE" : abspath(targetpath), "GIT_DIR" : join(abspath(targetpath),".git")})
+
for entry in logentries:
revisions.append(int(entry.attrib["revision"]))
revisions.sort()
+
+ fetchcmd = ["svn", "fetch", "--log-window-size=1000"]
+ if fullnames:
+ usermap = UserTagParser()
+ # store configuration in local git config so that'll be reused later when ie. updating
+ gitconfig = {"svn-remote.authorlog.url" : usermap.url,
+ "svn-remote.authorlog.defaultmail": usermap.defaultmail}
+ self.configset(gitconfig)
+ usermapfile = usermap.get_user_map_file()
+ fetchcmd.extend(("--authors-file", usermapfile))
+
while revisions:
- cmd = ["svn", "fetch", "--log-window-size=1000", "-r%d" % revisions.pop(0)]
- self._execVcs(*cmd, **kwargs)
+ self._execVcs(*fetchcmd + ["-r%d"%revisions.pop(0)], **kwargs)
+ if fullnames:
+ usermap.cleanup()
+
cmd = ["svn", "rebase", "--log-window-size=1000", "--local", "--fetch-all", "git-svn"]
return self._execVcs_success(*cmd, **kwargs)
@@ -114,15 +148,25 @@ class GIT(VCS):
retval, result = execcmd(*cmd)
if retval:
return retval
+
xmllog = ElementTree.fromstring(result)
logentries = xmllog.getiterator("logentry")
revisions = []
for entry in logentries:
revisions.append(int(entry.attrib["revision"]))
revisions.sort()
+
+ fetchcmd = ["svn", "fetch", "--log-window-size=1000"]
+ gitconfig = self.configget("svn-remote.authorlog")
+ if gitconfig:
+ usermap = UserTagParser(url=gitconfig.get("svn-remote.authorlog.url"),defaultmail=gitconfig.get("svn-remote.authorlog.defaultmail"))
+ usermapfile = usermap.get_user_map_file()
+ fetchcmd.extend(("--authors-file", usermapfile))
+
while revisions:
- cmd = ["svn", "fetch", "--log-window-size=1000", "-r%d" % revisions.pop(0)]
- self._execVcs(*cmd, **kwargs)
+ self._execVcs(*fetchcmd + ["-r%d"%revisions.pop(0)], **kwargs)
+ if gitconfig:
+ usermap.cleanup()
cmd = ["svn", "rebase", "--log-window-size=1000", "--local", "--fetch-all", "git-svn"]
status, output = self._execVcs(*cmd, **kwargs)
diff --git a/MgaRepo/log.py b/MgaRepo/log.py
index ffa5a4d..3fb3cc5 100644
--- a/MgaRepo/log.py
+++ b/MgaRepo/log.py
@@ -8,6 +8,7 @@ from io import StringIO
import sys
import os
+import os.path
import re
import time
import locale
@@ -569,11 +570,12 @@ class UserTagParser(HTMLParser):
userpage = None
namepat = re.compile("(?P<name>.*?)\s*\((?P<user>.*?)\)")
usermap = {}
+ usermapfile = None
- def __init__(self, url="https://people.mageia.org/u/", defaultmail="mageia.org", *cmd, **kwargs):
+ def __init__(self, url=None, defaultmail=None, *cmd, **kwargs):
HTMLParser.__init__(self, *cmd, **kwargs)
- self.url = url
- self.defaultmail = defaultmail
+ self.url = url or "http://people.mageia.org/u/"
+ self.defaultmail = defaultmail or "mageia.org"
def handle_starttag(self, tag, attrs):
if tag == "li":
@@ -607,6 +609,19 @@ class UserTagParser(HTMLParser):
self.feed(userhtml)
return self.usermap
+ def get_user_map_file(self):
+ if not self.usermap:
+ self.get_user_map()
+ self.usermapfile = tempfile.mkstemp(suffix=".txt", prefix="usermap")
+ f = open(self.usermapfile[0], "w", encoding="UTF-8")
+ f.writelines("%s = %s\n" % user for user in sorted(self.usermap.items()))
+ f.close()
+ return self.usermapfile[1]
+
+ def cleanup(self):
+ if os.path.exists(self.usermapfile[1]):
+ os.unlink(self.usermapfile[1])
+
def _map_user_names():
if not usermap:
parser = UserTagParser()
diff --git a/MgaRepo/rpmutil.py b/MgaRepo/rpmutil.py
index a9dfa7b..50313f2 100644
--- a/MgaRepo/rpmutil.py
+++ b/MgaRepo/rpmutil.py
@@ -584,7 +584,7 @@ def checkout(pkgdirurl, path=None, revision=None, branch=None, distro=None, back
binrepo.download_binaries(path)
def clone(pkgdirurl, path=None, revision=None, branch=None, distro=None, backports=None,
- spec=False):
+ spec=False, fullnames = True):
o_pkgdirurl = pkgdirurl
pkgdirurl = layout.package_url(o_pkgdirurl, distro=distro, backports=backports)
append = None
@@ -596,7 +596,7 @@ def clone(pkgdirurl, path=None, revision=None, branch=None, distro=None, backpor
path = layout.package_name(pkgdirurl)
mirror.info(current, write=True)
git = GIT()
- git.clone(current, path, show=1)
+ git.clone(current, path, fullnames=fullnames, show=1)
if not spec:
binrepo.download_binaries(path)