summaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-12-09 16:28:49 +0100
committerDan McGee <dan@archlinux.org>2011-12-09 16:28:49 +0100
commit4fa709ea86c8eefac05a848187fc7281edff8fa9 (patch)
tree5aa939ce6bea9a5c66d3cbdf5f5687375baaf313 /packages
parent5006da56476ebd3614cab68c574ab893e82d5aaf (diff)
downloadarchweb-4fa709ea86c8eefac05a848187fc7281edff8fa9.tar.gz
archweb-4fa709ea86c8eefac05a848187fc7281edff8fa9.tar.xz
populate_signoffs: add an SVN log cache for duplicate lookups
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'packages')
-rw-r--r--packages/management/commands/populate_signoffs.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/packages/management/commands/populate_signoffs.py b/packages/management/commands/populate_signoffs.py
index ce5ec73..42496e9 100644
--- a/packages/management/commands/populate_signoffs.py
+++ b/packages/management/commands/populate_signoffs.py
@@ -44,6 +44,9 @@ class Command(NoArgsCommand):
return add_signoff_comments()
def svn_log(pkgbase, repo):
+ '''Retrieve the most recent SVN log entry for the given pkgbase and
+ repository. The configured setting SVN_BASE_URL is used along with the
+ svn_root for each repository to form the correct URL.'''
path = '%s%s/%s/trunk/' % (settings.SVN_BASE_URL, repo.svn_root, pkgbase)
cmd = ['svn', 'log', '--limit=1', '--xml', path]
log_data = subprocess.check_output(cmd)
@@ -59,6 +62,17 @@ def svn_log(pkgbase, repo):
'message': xml.findtext('logentry/msg'),
}
+def cached_svn_log(pkgbase, repo):
+ '''Retrieve the cached version of the SVN log if possible, else delegate to
+ svn_log() to do the work and cache the result.'''
+ key = (pkgbase, repo)
+ if key in cached_svn_log.cache:
+ return cached_svn_log.cache[key]
+ log = svn_log(pkgbase, repo)
+ cached_svn_log.cache[key] = log
+ return log
+cached_svn_log.cache = {}
+
def create_specification(package, log, finder):
trimmed_message = log['message'].strip()
spec = SignoffSpecification(pkgbase=package.pkgbase,
@@ -80,7 +94,7 @@ def add_signoff_comments():
continue
logger.debug("getting SVN log for %s (%s)", group.pkgbase, group.repo)
- log = svn_log(group.pkgbase, group.repo)
+ log = cached_svn_log(group.pkgbase, group.repo)
logger.info("creating spec with SVN message for %s", group.pkgbase)
spec = create_specification(group.packages[0], log, finder)
spec.save()