[damned-lies] Allow updating modules pointing to the same repo
- From: Claude Paroz <claudep src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [damned-lies] Allow updating modules pointing to the same repo
- Date: Thu, 24 Jan 2013 19:07:19 +0000 (UTC)
commit e308ae276f475a1350247775d1494d227f280d9a
Author: Claude Paroz <claude 2xlibre net>
Date: Thu Jan 24 20:02:35 2013 +0100
Allow updating modules pointing to the same repo
Typical use case is the gtk+ module being split in different
modules to allow it being listed in different release categories.
stats/management/commands/update-stats.py | 45 ++++++++++++++++++-----------
1 files changed, 28 insertions(+), 17 deletions(-)
---
diff --git a/stats/management/commands/update-stats.py b/stats/management/commands/update-stats.py
index cbfc860..8f8745f 100644
--- a/stats/management/commands/update-stats.py
+++ b/stats/management/commands/update-stats.py
@@ -1,8 +1,11 @@
# -*- coding: utf-8 -*-
import sys, traceback
from optparse import make_option
+
from django.core.management.base import BaseCommand, CommandError
from django.core.mail import mail_admins
+from django.db.models import Q
+
from stats.models import Module, Branch
class Command(BaseCommand):
@@ -27,23 +30,31 @@ class Command(BaseCommand):
# Update the specific branch(es) of a module
module_arg = args[0]
branch_list = args[1:]
- for branch_arg in branch_list:
- if branch_arg == "trunk":
- branch_arg = "HEAD"
- try:
- branch = Branch.objects.get(module__name=module_arg, name=branch_arg)
- except Branch.DoesNotExist:
- raise CommandError("Unable to find branch '%s' for module '%s' in the database." % (
- branch_arg, module_arg))
- if branch.module.archived and not options['force']:
- raise CommandError("The module '%s' is archived." % module_arg)
- self.stdout.write("Updating stats for %s.%s..." % (module_arg, branch_arg))
- try:
- branch.update_stats(options['force'])
- except Exception:
- tbtext = traceback.format_exc()
- mail_admins("Error while updating %s %s" % (module_arg, branch_arg), tbtext)
- raise CommandError("Error during updating, mail sent to admins")
+
+ # This allows several modules (differently named) to point to the same vcs repo
+ modules = Module.objects.filter(Q(name=module_arg) | Q(vcs_root__endswith='/%s' % module_arg))
+ for i, module in enumerate(modules):
+ if module.archived and not options['force']:
+ self.stderr.write("The module '%s' is archived. Skipping..." % module.name)
+ continue
+ for branch_arg in branch_list:
+ if branch_arg == "trunk":
+ branch_arg = "HEAD"
+
+ try:
+ branch = module.branch_set.get(name=branch_arg)
+ except Branch.DoesNotExist:
+ self.stderr.write("Unable to find branch '%s' for module '%s' in the database." % (
+ branch_arg, module.name))
+ continue
+
+ self.stdout.write("Updating stats for %s.%s..." % (module.name, branch_arg))
+ try:
+ branch.update_stats(options['force'], checkout=(i<1))
+ except Exception:
+ tbtext = traceback.format_exc()
+ mail_admins("Error while updating %s %s" % (module.name, branch_arg), tbtext)
+ raise CommandError("Error during updating, mail sent to admins")
elif len(args) == 1:
# Update all branches of a module
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]