summaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
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 ce5ec734..42496e9d 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()