Exemplo n.º 1
0
def revset_me(repo, subset, x):
    """``me()``
    Changesets that you are involved in.
    """
    if x:
        raise ParseError(_('me() does not take any arguments'))

    me = repo.ui.config('ui', 'username')
    if not me:
        raise util.Abort(_('"[ui] username" must be set to use me()'))

    ircnick = get_ircnick(repo.ui)

    n = encoding.lower(me)
    kind, pattern, matcher = revset._substringmatcher(n)

    revs = []

    for r in subset:
        ctx = repo[r]
        if matcher(encoding.lower(ctx.user())):
            revs.append(r)
            continue

        if ircnick in parse_reviewers(ctx.description()):
            revs.append(r)
            continue

    return revs
Exemplo n.º 2
0
def revset_reviewer(repo, subset, x):
    """``reviewer(REVIEWER)``

    Changesets reviewed by a specific person.
    """
    l = revset.getargs(x, 1, 1, 'reviewer requires one argument')
    n = encoding.lower(revset.getstring(l[0], 'reviewer requires a string'))

    # Do not use a matcher here because regular expressions are not safe
    # for remote execution and may DoS the server.
    def hasreviewer(r):
        for reviewer in commitparser.parse_reviewers(repo[r].description()):
            if encoding.lower(reviewer) == n:
                return True

        return False

    return subset.filter(hasreviewer)
def revset_reviewer(repo, subset, x):
    """``reviewer(REVIEWER)``

    Changesets reviewed by a specific person.
    """
    l = revset.getargs(x, 1, 1, b'reviewer requires one argument')
    n = encoding.lower(revset.getstring(l[0], b'reviewer requires a string'))

    # Do not use a matcher here because regular expressions are not safe
    # for remote execution and may DoS the server.
    def hasreviewer(r):
        for reviewer in commitparser.parse_reviewers(repo[r].description()):
            if encoding.lower(reviewer) == n:
                return True

        return False

    return subset.filter(hasreviewer)
Exemplo n.º 4
0
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())
Exemplo n.º 5
0
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())
Exemplo n.º 6
0
def revset_me(repo, subset, x):
    """Changesets that you are involved in."""
    if x:
        raise ParseError(_('me() does not take any arguments'))

    me = repo.ui.config('ui', 'username')
    if not me:
        raise error.Abort(_('"[ui] username" must be set to use me()'))

    ircnick = get_ircnick(repo.ui)

    n = encoding.lower(me)
    kind, pattern, matcher = revset._substringmatcher(n)

    def fltr(x):
        ctx = repo[x]
        if matcher(encoding.lower(ctx.user())):
            return True

        return ircnick in parse_reviewers(ctx.description())

    return subset.filter(fltr)
Exemplo n.º 7
0
 def getrevs():
     to_rev = repo.changelog.rev
     for push in repo.pushlog.pushes():
         if matcher(encoding.lower(push.user)):
             for node in push.nodes:
                 yield to_rev(bin(node))
Exemplo n.º 8
0
    def fltr(x):
        ctx = repo[x]
        if matcher(encoding.lower(ctx.user())):
            return True

        return ircnick in parse_reviewers(ctx.description())
Exemplo n.º 9
0
 def getrevs():
     for push in repo.pushlog.pushes():
         if matcher(encoding.lower(push.user)):
             for node in push.nodes:
                 yield repo[node].rev()
Exemplo n.º 10
0
 def getrevs():
     for pushid, who, when, nodes in repo.pushlog.pushes():
         if matcher(encoding.lower(who)):
             for node in nodes:
                 yield repo[node].rev()
Exemplo n.º 11
0
    def hasreviewer(r):
        for reviewer in commitparser.parse_reviewers(repo[r].description()):
            if encoding.lower(reviewer) == n:
                return True

        return False
Exemplo n.º 12
0
    def hasreviewer(r):
        for reviewer in commitparser.parse_reviewers(repo[r].description()):
            if encoding.lower(reviewer) == n:
                return True

        return False
Exemplo n.º 13
0
def _runperfilediff(
    cmdline,
    repo_root,
    ui,
    guitool,
    do3way,
    confirm,
    commonfiles,
    tmproot,
    dir1a,
    dir1b,
    dir2root,
    dir2,
    rev1a,
    rev1b,
    rev2,
):
    # Note that we need to sort the list of files because it was
    # built in an "unstable" way and it's annoying to get files in a
    # random order, especially when "confirm" mode is enabled.
    waitprocs = []
    totalfiles = len(commonfiles)
    for idx, commonfile in enumerate(sorted(commonfiles)):
        path1a = os.path.join(tmproot, dir1a, commonfile)
        label1a = commonfile + rev1a
        if not os.path.isfile(path1a):
            path1a = os.devnull

        path1b = b''
        label1b = b''
        if do3way:
            path1b = os.path.join(tmproot, dir1b, commonfile)
            label1b = commonfile + rev1b
            if not os.path.isfile(path1b):
                path1b = os.devnull

        path2 = os.path.join(dir2root, dir2, commonfile)
        label2 = commonfile + rev2

        if confirm:
            # Prompt before showing this diff
            difffiles = _(b'diff %s (%d of %d)') % (
                commonfile,
                idx + 1,
                totalfiles,
            )
            responses = _(b'[Yns?]'
                          b'$$ &Yes, show diff'
                          b'$$ &No, skip this diff'
                          b'$$ &Skip remaining diffs'
                          b'$$ &? (display help)')
            r = ui.promptchoice(b'%s %s' % (difffiles, responses))
            if r == 3:  # ?
                while r == 3:
                    for c, t in ui.extractchoices(responses)[1]:
                        ui.write(b'%s - %s\n' % (c, encoding.lower(t)))
                    r = ui.promptchoice(b'%s %s' % (difffiles, responses))
            if r == 0:  # yes
                pass
            elif r == 1:  # no
                continue
            elif r == 2:  # skip
                break

        curcmdline = formatcmdline(
            cmdline,
            repo_root,
            do3way=do3way,
            parent1=path1a,
            plabel1=label1a,
            parent2=path1b,
            plabel2=label1b,
            child=path2,
            clabel=label2,
        )

        if confirm or not guitool:
            # Run the comparison program and wait for it to exit
            # before we show the next file.
            # This is because either we need to wait for confirmation
            # from the user between each invocation, or because, as far
            # as we know, the tool doesn't have a GUI, in which case
            # we can't run multiple CLI programs at the same time.
            ui.debug(b'running %r in %s\n' %
                     (pycompat.bytestr(curcmdline), tmproot))
            ui.system(curcmdline, cwd=tmproot, blockedtag=b'extdiff')
        else:
            # Run the comparison program but don't wait, as we're
            # going to rapid-fire each file diff and then wait on
            # the whole group.
            ui.debug(b'running %r in %s (backgrounded)\n' %
                     (pycompat.bytestr(curcmdline), tmproot))
            proc = _systembackground(curcmdline, cwd=tmproot)
            waitprocs.append(proc)

    if waitprocs:
        with ui.timeblockedsection(b'extdiff'):
            for proc in waitprocs:
                proc.wait()
Exemplo n.º 14
0
    def fltr(x):
        ctx = repo[x]
        if matcher(encoding.lower(ctx.user())):
            return True

        return ircnick in parse_reviewers(ctx.description())