示例#1
0
 def handle(self, *args, **options):
     if len(args) != 2:
         raise CommandError, "two arguments required, old and new appversion"
     fork = AppVersion.objects.get(code=args[0])
     target = AppVersion.objects.get(code=args[1])
     if fork.tree.l10n != target.tree.l10n:
         raise CommandError, "Fork and target appversion don't share l10n"
     fsos = accepted_signoffs(id=fork.id)
     tsos = accepted_signoffs(id=target.id)
     known_push_ids = dict(tsos.values_list('locale__code','push__id'))
     sos = fsos.exclude(push__id__in=known_push_ids.values())
     
     for so in sos.order_by('locale__code').select_related('locale'):
         if so.push_id <= known_push_ids[so.locale.code]:
             print "not merging %s, target newer" % so.locale.code
             continue
         print "merging " + so.locale.code
         _so = target.signoffs.create(push = so.push,
                                   author = so.author,
                                   when = so.when,
                                   locale = so.locale)
         for a in so.action_set.order_by('pk'):
             _so.action_set.create(flag = a.flag,
                                   author = a.author,
                                   when = a.when,
                                   comment = a.comment)
示例#2
0
    def handle(self, *args, **options):
        if len(args) != 2:
            raise CommandError("two arguments required, " +
                               "old and new appversion")
        fork = AppVersion.objects.get(code=args[0])
        target = AppVersion.objects.get(code=args[1])
        if (fork.trees_over_time.latest().tree.l10n !=
                target.trees_over_time.latest().tree.l10n):
            raise CommandError("Fork and target appversion don't share l10n")
        fsos = accepted_signoffs(fork)
        tsos = accepted_signoffs(target)
        known_push_ids = dict(tsos.values_list('locale__code', 'push__id'))
        sos = fsos.exclude(push__id__in=known_push_ids.values())

        for so in sos.order_by('locale__code').select_related('locale'):
            if so.push_id <= known_push_ids[so.locale.code]:
                print "not merging %s, target newer" % so.locale.code
                continue
            print "merging " + so.locale.code
            _so = target.signoffs.create(push=so.push,
                                         author=so.author,
                                         when=so.when,
                                         locale=so.locale)
            for a in so.action_set.order_by('pk'):
                _so.action_set.create(flag=a.flag,
                                      author=a.author,
                                      when=a.when,
                                      comment=a.comment)
示例#3
0
文件: update_l10n.py 项目: stasm/elmo
    def handle(self, *args, **options):
        quiet = options.get('quiet', False)
        if not args:
            return
        try:
            ms = Milestone.objects.get(code=args[0])
        except:
            raise CommandError, "No milestone with code %s found" % args[0]

        forest = ms.appver.tree.l10n.name.split('/')

        def resolve(path):
            return os.path.join(settings.REPOSITORY_BASE,
                                *(forest + path.split('/')))

        if ms.status == Milestone.SHIPPED:
            sos = ms.signoffs
        else:
            sos = accepted_signoffs(id=ms.appver_id)
        sos = dict(sos.values_list('locale__code', 'push_id'))
        tips = dict(
            Push.objects.filter(id__in=sos.values()).annotate(
                tip=Max('changesets__id')).values_list('id', 'tip'))
        revs = dict(
            Changeset.objects.filter(id__in=tips.values()).values_list(
                'id', 'revision'))
        from pushes.management import hgcompat
        for loc in sorted(sos.keys()):
            repopath = resolve(loc)
            rev = revs[tips[sos[loc]]]
            hgcompat.dispatch(['update', '-R', repopath, '-r', rev])
示例#4
0
文件: update_l10n.py 项目: gerv/elmo
    def handle(self, *args, **options):
        quiet = options.get('quiet', False)
        if not args:
            return
        try:
            ms = Milestone.objects.get(code=args[0])
        except:
            raise CommandError, "No milestone with code %s found" % args[0]

        forest = ms.appver.tree.l10n.name.split('/')
        def resolve(path):
            return os.path.join(settings.REPOSITORY_BASE, *(forest + path.split('/')))

        if ms.status == Milestone.SHIPPED:
            sos = ms.signoffs
        else:
            sos = accepted_signoffs(id=ms.appver_id)
        sos=dict(sos.values_list('locale__code', 'push_id'))
        tips = dict(Push.objects.filter(id__in=sos.values()).annotate(tip=Max('changesets__id')).values_list('id', 'tip'))
        revs = dict(Changeset.objects.filter(id__in=tips.values()).values_list('id','revision'))
        from mercurial import dispatch
        for loc in sorted(sos.keys()):
            repopath = resolve(loc)
            rev = revs[tips[sos[loc]]]
            dispatch.dispatch(
                dispatch.request(['update', '-R', repopath, '-r', rev])
                )
示例#5
0
    def handle(self, *args, **options):
        sos = accepted_signoffs()
        triples = list(
            sos.order_by("appversion__code", "locale__code").values_list("appversion__code", "locale__code", "push")
        )
        pushes = set(t[2] for t in triples)
        cs4push = dict(Push.objects.filter(id__in=pushes).annotate(tip=Max("changesets")).values_list("id", "tip"))
        revs = dict(Changeset.objects.filter(id__in=cs4push.values()).values_list("id", "revision"))

        rv = defaultdict(dict)
        for av, loc, pushid in triples:
            rv[av][loc] = revs[cs4push[pushid]][:12]

        print json.dumps(rv, indent=2, sort_keys=True)
示例#6
0
 def handle(self, *args, **options):
     if len(args) != 2:
         raise CommandError, "two arguments required, old and new appversion"
     old = AppVersion.objects.get(code=args[0])
     new = AppVersion.objects.get(code=args[1])
     if old.tree.l10n != new.tree.l10n:
         raise CommandError, "Old and new appversion don't share l10n"
     sos = accepted_signoffs(id=old.id)
     for so in sos:
         print "transplanting " + so.locale.code
         _so = new.signoffs.create(push=so.push,
                                   author=so.author,
                                   when=so.when,
                                   locale=so.locale)
         for a in so.action_set.order_by('pk'):
             _so.action_set.create(flag=a.flag,
                                   author=a.author,
                                   when=a.when,
                                   comment=a.comment)
示例#7
0
 def handle(self, *args, **options):
     if len(args) != 2:
         raise CommandError, "two arguments required, old and new appversion"
     old = AppVersion.objects.get(code=args[0])
     new = AppVersion.objects.get(code=args[1])
     if old.tree.l10n != new.tree.l10n:
         raise CommandError, "Old and new appversion don't share l10n"
     sos = accepted_signoffs(id=old.id)
     for so in sos:
         print "transplanting " + so.locale.code
         _so = new.signoffs.create(push = so.push,
                                   author = so.author,
                                   when = so.when,
                                   locale = so.locale)
         for a in so.action_set.order_by('pk'):
             _so.action_set.create(flag = a.flag,
                                   author = a.author,
                                   when = a.when,
                                   comment = a.comment)
示例#8
0
文件: __init__.py 项目: stasm/elmo
def ship_mstone(request):
    """The actual worker method to ship a milestone.

    Redirects to milestones().
    """
    if request.method != "POST":
        return HttpResponseNotAllowed(["POST"])
    if not request.user.has_perm('shipping.can_ship'):
        # XXX: personally I'd prefer if this was a raised 4xx error (peter)
        # then I can guarantee better test coverage
        return HttpResponseRedirect(reverse('shipping.views.milestones'))

    mstone = get_object_or_404(Milestone, code=request.POST['ms'])
    if mstone.status != Milestone.OPEN:
        return HttpResponseForbidden('Can only ship open milestones')
    cs = (accepted_signoffs(id=mstone.appver_id)
          .values_list('id', flat=True))
    mstone.signoffs.add(*list(cs))  # add them
    mstone.status = 2
    # XXX create event
    mstone.save()

    return HttpResponseRedirect(reverse('shipping.views.milestones'))
示例#9
0
 def data_for_appversion(self, appver):
     return (accepted_signoffs(appver, up_until=self.up_until),)
示例#10
0
文件: status.py 项目: stasm/elmo
 def data_for_avq(self, avq):
     return (accepted_signoffs(**avq), )
示例#11
0
文件: status.py 项目: lauraxt/elmo
 def data_for_avq(self, avq):
     return (accepted_signoffs(**avq),)
示例#12
0
def statuses(req, ms_code):
    """JSON work horse for the about() view.

    @see: about
    """
    try:
        ms = Milestone.objects.get(code=ms_code)
    except:
        return HttpResponse('no milestone found for %s' % ms_code)

    if ms.appver.tree is not None:
        tree = ms.appver.tree
    else:
        tree = ms.appver.lasttree

    if ms.status == Milestone.SHIPPED:
        sos_vals = ms.signoffs.values_list('id', 'push__id', 'locale__code')
    else:
        sos_vals = (accepted_signoffs(id=ms.appver.id).values_list(
            'id', 'push__id', 'locale__code'))
    sos = dict(d[:2] for d in sos_vals)
    loc2push = dict((d[2], d[1]) for d in sos_vals)
    locales = sorted(d[2] for d in sos_vals)
    allpushes = sos.values()

    def runs2dict(rs, prefix=''):
        fields = [prefix + f for f in ['locale__code'] + Run.dfields]
        dcs = Run.to_class_string(runs.values(*fields), prefix)
        return dict((d[prefix + 'locale__code'], {
            'class': cls,
            'val': strval
        }) for d, cls, strval in dcs)

    # if the milestone is not shipped, let's check the active Runs, too
    active = {}
    if ms.status != 2:
        runs = Run.objects.filter(active__isnull=False)
        runs = runs.filter(tree=tree)
        active = runs2dict(runs)

    # if we have a previously shipped milestone, check the diffs
    previous = {}
    so_ids = dict((d[2], d[0]) for d in sos_vals)  # current signoff ids
    pso = Milestone_Signoffs.objects.filter(milestone__id__lt=ms.id,
                                            milestone__appver__milestone=ms.id)
    pso = pso.order_by('milestone__id')
    for loc, sid, pid, mcode in pso.values_list('signoff__locale__code',
                                                'signoff__id',
                                                'signoff__push__id',
                                                'milestone__code'):
        previous[loc] = {'signoff': sid, 'push': pid, 'stone': mcode}
    # whatever is in so_ids but not in previous is added
    added = [loc for loc in so_ids.iterkeys() if loc not in previous]
    removed = []  # not yet used
    # drop those from previous that we're shipping in the same rev
    for loc, details in previous.items():
        if loc in so_ids:
            if so_ids[loc] <= details['signoff']:
                previous.pop(loc)
        else:
            removed.append(loc)
    allpushes += [d['push'] for d in previous.itervalues()]

    # get the most recent result for the signed off stamps
    cs = Changeset.objects.filter(pushes__id__in=sos.values())
    cs_ids = list(cs.values_list('id', flat=True))
    runs = Run_Revisions.objects.filter(changeset__id__in=cs_ids,
                                        run__tree=tree)
    latest = runs2dict(runs, 'run__')

    # get the snapshots from the sign-offs
    snaps = Snapshot.objects.filter(signoff__id__in=sos.keys(), test=0)
    runs = Run.objects.filter(id__in=list(snaps.values_list('tid', flat=True)))
    snapshots = runs2dict(runs)

    # get the shortrev's for all pushes, current sign-offs and previous
    pushes = Push.objects.annotate(tip=Max('changesets__id'))
    pushes = pushes.filter(id__in=allpushes)
    tips = dict(pushes.values_list('id', 'tip'))
    revmap = dict(
        Changeset.objects.filter(id__in=tips.values()).values_list(
            'id', 'revision'))

    # generator to convert the various information to exhibit json
    def items():
        for loc in locales:
            d = {'label': loc, 'revision': revmap[tips[loc2push[loc]]][:12]}
            if loc in active:
                d['active'] = active[loc]['val']
                d['active_class'] = active[loc]['class']
            if loc in latest:
                d['latest'] = latest[loc]['val']
                d['latest_class'] = latest[loc]['class']
            if loc in snapshots:
                d['snapshot'] = snapshots[loc]['val']
                d['snapshot_class'] = snapshots[loc]['class']
            if loc in previous:
                d['updatedFromRev'] = revmap[tips[previous[loc]['push']]][:12]
                d['updatedFrom'] = previous[loc]['stone']
            elif loc in added:
                d['added'] = 'added'
            yield d

    return HttpResponse(simplejson.dumps({'items': list(items())}, indent=2),
                        mimetype="text/plain")
 def data_for_appversion(self, appver):
     return (accepted_signoffs(appver, up_until=self.up_until), )
示例#14
0
def statuses(req, ms_code):
    """JSON work horse for the about() view.

    @see: about
    """
    try:
        ms = Milestone.objects.get(code=ms_code)
    except:
        return HttpResponse('no milestone found for %s' % ms_code)

    tree = ms.appver.trees_over_time.latest().tree

    if ms.status == Milestone.SHIPPED:
        sos_vals = ms.signoffs.values_list('id', 'push__id', 'locale__code')
    else:
        sos_vals = (accepted_signoffs(ms.appver)
                    .values_list('id', 'push__id', 'locale__code'))
    sos = dict(d[:2] for d in sos_vals)
    loc2push = dict((d[2], d[1]) for d in sos_vals)
    locales = sorted(d[2] for d in sos_vals)
    allpushes = sos.values()

    def runs2dict(rs, prefix=''):
        fields = [prefix + f for f in ['locale__code'] + Run.dfields]
        dcs = Run.to_class_string(runs.values(*fields), prefix)
        return dict((d[prefix + 'locale__code'],
                     {'class': cls, 'val': strval})
                    for d, cls, strval in dcs)

    # if the milestone is not shipped, let's check the active Runs, too
    active = {}
    if ms.status != Milestone.SHIPPED:
        runs = Run.objects.filter(active__isnull=False)
        runs = runs.filter(tree=tree)
        active = runs2dict(runs)

    # if we have a previously shipped milestone, check the diffs
    previous = {}
    so_ids = dict((d[2], d[0]) for d in sos_vals)  # current signoff ids
    pso = Milestone_Signoffs.objects.filter(milestone__id__lt=ms.id,
                                            milestone__appver__milestone=ms.id)
    pso = pso.order_by('milestone__id')
    for loc, sid, pid, mcode in pso.values_list('signoff__locale__code',
                                                'signoff__id',
                                                'signoff__push__id',
                                                'milestone__code'):
        previous[loc] = {'signoff': sid, 'push': pid, 'stone': mcode}
    fallbacks = dict(ms.signoffs
        .exclude(appversion=ms.appver)
        .values_list('locale__code', 'appversion__code'))
    # whatever is in so_ids but not in previous is added
    added = [loc for loc in sorted(so_ids.iterkeys())
        if loc not in previous and loc not in fallbacks]
    removed = []  # not yet used
    # drop those from previous that we're shipping in the same rev
    for loc, details in previous.items():
        if loc in so_ids:
            if so_ids[loc] <= details['signoff']:
                previous.pop(loc)
        else:
            removed.append(loc)
    allpushes += [d['push'] for d in  previous.itervalues()]

    # get the most recent result for the signed off stamps
    cs = Changeset.objects.filter(pushes__id__in=sos.values())
    cs_ids = list(cs.values_list('id', flat=True))
    runs = Run_Revisions.objects.filter(changeset__id__in=cs_ids,
                                        run__tree=tree)
    latest = runs2dict(runs, 'run__')

    # get the snapshots from the sign-offs
    snaps = Snapshot.objects.filter(signoff__id__in=sos.keys(), test=0)
    runs = Run.objects.filter(id__in=list(snaps.values_list('tid', flat=True)))
    snapshots = runs2dict(runs)

    # get the shortrev's for all pushes, current sign-offs and previous
    pushes = Push.objects.annotate(tip=Max('changesets__id'))
    pushes = pushes.filter(id__in=allpushes)
    tips = dict(pushes.values_list('id', 'tip'))
    revmap = dict(Changeset.objects
                  .filter(id__in=tips.values())
                  .values_list('id', 'revision'))

    # generator to convert the various information to exhibit json
    def items():
        for loc in locales:
            d = {'label': loc, 'revision': revmap[tips[loc2push[loc]]][:12]}
            if loc in active:
                d['active'] = active[loc]['val']
                d['active_class'] = active[loc]['class']
            if loc in latest:
                d['latest'] = latest[loc]['val']
                d['latest_class'] = latest[loc]['class']
            if loc in snapshots:
                d['snapshot'] = snapshots[loc]['val']
                d['snapshot_class'] = snapshots[loc]['class']
            if loc in previous:
                d['updatedFromRev'] = revmap[tips[previous[loc]['push']]][:12]
                d['updatedFrom'] = previous[loc]['stone']
            elif loc in added:
                d['added'] = 'added'
            elif loc in fallbacks:
                d['fallback'] = fallbacks[loc]
            yield d

    return HttpResponse(simplejson.dumps({'items': list(items())}, indent=2),
                        mimetype="text/plain")
示例#15
0
文件: status.py 项目: hwine/elmo
 def data_for_appversion(self, appver):
     return (accepted_signoffs(appver),)