Beispiel #1
0
def revset_firefoxrelease(repo, subset, x):
    """``firefoxrelease([channel=], [platform=])

    Changesets that have Firefox releases built from them.

    Accepts the following named arguments:

    channel
       Which release channel to look at. e.g. ``nightly``. Multiple channels
       can be delimited by spaces.
    platform
       Which platform to limit builds to. e.g. ``win32``. Multiple platforms
       can be delimited by spaces.

    If multiple filters are requested filters are combined using logical AND.

    If no filters are specified, all revisions having a Firefox release are
    matched.
    """
    args = revset.getargsdict(x, 'firefoxrelease', 'channel platform')

    channels = set()

    if 'channel' in args:
        channels = set(
            revset.getstring(args['channel'],
                             _('channel requires a string')).split())

    platforms = set()

    if 'platform' in args:
        platforms = set(
            revset.getstring(args['platform'],
                             _('platform requires a '
                               'string')).split())

    db = db_for_repo(repo)
    if not db:
        repo.ui.warn(_('(warning: firefoxrelease() revset not available)\n'))
        return revset.baseset()

    def get_revs():
        for rev, builds in release_builds_by_revision(db, repo).iteritems():
            for build in builds:
                if channels and build.channel not in channels:
                    continue

                if platforms and build.platform not in platforms:
                    continue

                yield rev
                break

    return subset & revset.generatorset(get_revs())
def revset_pushdate(repo, subset, x):
    """Changesets that were pushed within the interval, see :hg:`help dates`."""
    l = revset.getargs(x, 1, 1, 'pushdate requires one argument')

    ds = revset.getstring(l[0], 'pushdate requires a string argument')
    dm = util.matchdate(ds)

    def getrevs():
        for push in repo.pushlog.pushes():
            if dm(push.when):
                for node in push.nodes:
                    yield repo[node].rev()

    return subset & revset.generatorset(getrevs())
def revset_pushdate(repo, subset, x):
    """``pushdate(interval)``
    Changesets that were pushed within the interval, see :hg:`help dates`.
    """
    l = revset.getargs(x, 1, 1, 'pushdate requires one argument')

    ds = revset.getstring(l[0], 'pushdate requires a string argument')
    dm = util.matchdate(ds)

    def getrevs():
        for pushid, who, when, nodes in repo.pushlog.pushes():
            if dm(when):
                for node in nodes:
                    yield repo[node].rev()

    return subset & revset.generatorset(getrevs())
def revset_pushhead(repo, subset, x):
    """``pushhead([TREE])``
    Changesets that are push heads.

    A push head is a changeset that was a head when it was pushed to a
    repository. In other words, the automation infrastructure likely
    kicked off a build using this changeset.

    If an argument is given, we limit ourselves to pushes on the specified
    tree.

    If no argument is given, we return all push heads for all trees. Note that
    a changeset can be a push head multiple times. This function doesn't care
    where the push was made if no argument was given.
    """
    # We have separate code paths because the single tree path uses a single
    # query and is faster.
    if x:
        tree = revset.getstring(x, _('pushhead() requires a string argument.'))
        tree, uri = resolve_trees_to_uris([tree])[0]

        if not uri:
            raise util.Abort(_("Don't know about tree: %s") % tree)

        def pushheads():
            for push_id, head_changeset in repo.changetracker.tree_push_head_changesets(
                    tree):
                try:
                    head = repo[head_changeset].rev()
                    yield head
                except error.RepoLookupError:
                    # There are some malformed pushes.  Ignore them.
                    continue

        # Push heads are returned in order of ascending push ID, which
        # corresponds to ascending commit order in hg.
        return subset & revset.generatorset(pushheads(), iterasc=True)
    else:

        def is_pushhead(r):
            node = repo[r].node()
            for push in repo.changetracker.pushes_for_changeset(node):
                if str(push[4]) == node:
                    return True
            return False

        return subset.filter(is_pushhead)
def revset_pushhead(repo, subset, x):
    """Changesets that were heads when they were pushed.

    A push head is a changeset that was a head at the time it was pushed.
    """
    revset.getargs(x, 0, 0, 'pushhead takes no arguments')

    # Iterating over all pushlog data is unfortunate, as there is overhead
    # involved. However, this is less overhead than issuing a SQL query for
    # every changeset, especially on large repositories. There is room to make
    # this optimal by batching SQL, but that adds complexity. For now,
    # simplicity wins.
    def getrevs():
        for push in repo.pushlog.pushes():
            yield repo[push.nodes[-1]].rev()

    return subset & revset.generatorset(getrevs())
def revset_pushhead(repo, subset, x):
    """``pushhead([TREE])``
    Changesets that are push heads.

    A push head is a changeset that was a head when it was pushed to a
    repository. In other words, the automation infrastructure likely
    kicked off a build using this changeset.

    If an argument is given, we limit ourselves to pushes on the specified
    tree.

    If no argument is given, we return all push heads for all trees. Note that
    a changeset can be a push head multiple times. This function doesn't care
    where the push was made if no argument was given.
    """
    # We have separate code paths because the single tree path uses a single
    # query and is faster.
    if x:
        tree = revset.getstring(x, _('pushhead() requires a string argument.'))
        tree, uri = resolve_trees_to_uris([tree])[0]

        if not uri:
            raise util.Abort(_("Don't know about tree: %s") % tree)

        def pushheads():
            for push_id, head_changeset in repo.changetracker.tree_push_head_changesets(tree):
                try:
                    head = repo[head_changeset].rev()
                    yield head
                except error.RepoLookupError:
                    # There are some malformed pushes.  Ignore them.
                    continue

        # Push heads are returned in order of ascending push ID, which
        # corresponds to ascending commit order in hg.
        return subset & revset.generatorset(pushheads(), iterasc=True)
    else:
        def is_pushhead(r):
            node = repo[r].node()
            for push in repo.changetracker.pushes_for_changeset(node):
                if str(push[4]) == node:
                    return True
            return False

        return subset.filter(is_pushhead)
def revset_pushdate(repo, subset, x):
    """``pushdate(interval)``

    Changesets that were pushed within the interval. See :hg:`help dates`.
    """
    l = revset.getargs(x, 1, 1, 'pushdate requires one argument')

    ds = revset.getstring(l[0], 'pushdate requires a string argument')
    dm = dateutil.matchdate(ds)

    def getrevs():
        to_rev = repo.changelog.rev
        for push in repo.pushlog.pushes():
            if dm(push.when):
                for node in push.nodes:
                    yield to_rev(bin(node))

    return subset & revset.generatorset(getrevs())
def revset_pushhead(repo, subset, x):
    """``pushhead()``
    Changesets that were heads when they were pushed.

    A push head is a changeset that was a head at the time it was pushed.
    """
    revset.getargs(x, 0, 0, 'pushhead takes no arguments')

    # Iterating over all pushlog data is unfortunate, as there is overhead
    # involved. However, this is less overhead than issuing a SQL query for
    # every changeset, especially on large repositories. There is room to make
    # this optimal by batching SQL, but that adds complexity. For now,
    # simplicity wins.
    def getrevs():
        for pushid, who, when, nodes in repo.pushlog.pushes():
            yield repo[nodes[-1]].rev()

    return subset & revset.generatorset(getrevs())
def revset_pushuser(repo, subset, x):
    """User name that pushed the changeset contains string.

    The match is case-insensitive.

    If `string` starts with `re:`, the remainder of the string is treated as
    a regular expression. To match a user that actually contains `re:`, use
    the prefix `literal:`.
    """
    l = revset.getargs(x, 1, 1, 'pushuser requires one argument')
    n = encoding.lower(revset.getstring(l[0], 'pushuser requires a string'))
    kind, pattern, matcher = revset._substringmatcher(n)

    def getrevs():
        for push in repo.pushlog.pushes():
            if matcher(encoding.lower(push.user)):
                for node in push.nodes:
                    yield repo[node].rev()

    return subset & revset.generatorset(getrevs())
def revset_pushuser(repo, subset, x):
    """``pushuser(string)``

    User name that pushed the changeset contains string. The match is
    case-insensitive.

    If `string` starts with `re:`, the remainder of the string is treated as
    a regular expression. To match a user that actually contains `re:`, use
    the prefix `literal:`.
    """
    l = revset.getargs(x, 1, 1, 'pushuser requires one argument')
    n = encoding.lower(revset.getstring(l[0], 'pushuser requires a string'))
    kind, pattern, matcher = revset._substringmatcher(n)

    def getrevs():
        for pushid, who, when, nodes in repo.pushlog.pushes():
            if matcher(encoding.lower(who)):
                for node in nodes:
                    yield repo[node].rev()

    return subset & revset.generatorset(getrevs())