tests/printrevset.py
author Joerg Sonnenberger <joerg@bec.de>
Sat, 07 Nov 2020 19:24:12 +0100
changeset 45885 a6f08085edfe
parent 45568 c1d0f83d62c4
child 48966 6000f5b25c9b
permissions -rw-r--r--
transaction: rename find to findoffset and drop backup file support transaction.find used to support access to both the regular file and backup file list. They have different formats, so any consumer has to be aware of the difference alredy. There is no in-core consumer for the backup file access, so don't provide it. Differential Revision: https://phab.mercurial-scm.org/D9276
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
39095
a271466cb53a tests: extract printrevset extension from test-glog-beautifygraph.t
Augie Fackler <augie@google.com>
parents:
diff changeset
     1
from __future__ import absolute_import
45568
c1d0f83d62c4 log: introduce struct that carries log traversal options
Yuya Nishihara <yuya@tcha.org>
parents: 45567
diff changeset
     2
from mercurial.thirdparty import attr
39095
a271466cb53a tests: extract printrevset extension from test-glog-beautifygraph.t
Augie Fackler <augie@google.com>
parents:
diff changeset
     3
from mercurial import (
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 39095
diff changeset
     4
    cmdutil,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 39095
diff changeset
     5
    commands,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 39095
diff changeset
     6
    extensions,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 39095
diff changeset
     7
    logcmdutil,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 39095
diff changeset
     8
    revsetlang,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 39095
diff changeset
     9
    smartset,
39095
a271466cb53a tests: extract printrevset extension from test-glog-beautifygraph.t
Augie Fackler <augie@google.com>
parents:
diff changeset
    10
)
a271466cb53a tests: extract printrevset extension from test-glog-beautifygraph.t
Augie Fackler <augie@google.com>
parents:
diff changeset
    11
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 39095
diff changeset
    12
from mercurial.utils import stringutil
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 39095
diff changeset
    13
39095
a271466cb53a tests: extract printrevset extension from test-glog-beautifygraph.t
Augie Fackler <augie@google.com>
parents:
diff changeset
    14
45568
c1d0f83d62c4 log: introduce struct that carries log traversal options
Yuya Nishihara <yuya@tcha.org>
parents: 45567
diff changeset
    15
def logrevset(repo, wopts):
c1d0f83d62c4 log: introduce struct that carries log traversal options
Yuya Nishihara <yuya@tcha.org>
parents: 45567
diff changeset
    16
    revs = logcmdutil._initialrevs(repo, wopts)
39095
a271466cb53a tests: extract printrevset extension from test-glog-beautifygraph.t
Augie Fackler <augie@google.com>
parents:
diff changeset
    17
    if not revs:
a271466cb53a tests: extract printrevset extension from test-glog-beautifygraph.t
Augie Fackler <augie@google.com>
parents:
diff changeset
    18
        return None
45568
c1d0f83d62c4 log: introduce struct that carries log traversal options
Yuya Nishihara <yuya@tcha.org>
parents: 45567
diff changeset
    19
    match, pats, slowpath = logcmdutil._makematcher(repo, revs, wopts)
c1d0f83d62c4 log: introduce struct that carries log traversal options
Yuya Nishihara <yuya@tcha.org>
parents: 45567
diff changeset
    20
    wopts = attr.evolve(wopts, pats=pats)
c1d0f83d62c4 log: introduce struct that carries log traversal options
Yuya Nishihara <yuya@tcha.org>
parents: 45567
diff changeset
    21
    return logcmdutil._makerevset(repo, wopts, slowpath)
39095
a271466cb53a tests: extract printrevset extension from test-glog-beautifygraph.t
Augie Fackler <augie@google.com>
parents:
diff changeset
    22
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 39095
diff changeset
    23
39095
a271466cb53a tests: extract printrevset extension from test-glog-beautifygraph.t
Augie Fackler <augie@google.com>
parents:
diff changeset
    24
def uisetup(ui):
45568
c1d0f83d62c4 log: introduce struct that carries log traversal options
Yuya Nishihara <yuya@tcha.org>
parents: 45567
diff changeset
    25
    def printrevset(orig, repo, wopts):
c1d0f83d62c4 log: introduce struct that carries log traversal options
Yuya Nishihara <yuya@tcha.org>
parents: 45567
diff changeset
    26
        revs, filematcher = orig(repo, wopts)
c1d0f83d62c4 log: introduce struct that carries log traversal options
Yuya Nishihara <yuya@tcha.org>
parents: 45567
diff changeset
    27
        if wopts.opts.get(b'print_revset'):
c1d0f83d62c4 log: introduce struct that carries log traversal options
Yuya Nishihara <yuya@tcha.org>
parents: 45567
diff changeset
    28
            expr = logrevset(repo, wopts)
39095
a271466cb53a tests: extract printrevset extension from test-glog-beautifygraph.t
Augie Fackler <augie@google.com>
parents:
diff changeset
    29
            if expr:
a271466cb53a tests: extract printrevset extension from test-glog-beautifygraph.t
Augie Fackler <augie@google.com>
parents:
diff changeset
    30
                tree = revsetlang.parse(expr)
a271466cb53a tests: extract printrevset extension from test-glog-beautifygraph.t
Augie Fackler <augie@google.com>
parents:
diff changeset
    31
                tree = revsetlang.analyze(tree)
a271466cb53a tests: extract printrevset extension from test-glog-beautifygraph.t
Augie Fackler <augie@google.com>
parents:
diff changeset
    32
            else:
a271466cb53a tests: extract printrevset extension from test-glog-beautifygraph.t
Augie Fackler <augie@google.com>
parents:
diff changeset
    33
                tree = []
a271466cb53a tests: extract printrevset extension from test-glog-beautifygraph.t
Augie Fackler <augie@google.com>
parents:
diff changeset
    34
            ui = repo.ui
45568
c1d0f83d62c4 log: introduce struct that carries log traversal options
Yuya Nishihara <yuya@tcha.org>
parents: 45567
diff changeset
    35
            ui.write(b'%s\n' % stringutil.pprint(wopts.opts.get(b'rev', [])))
39095
a271466cb53a tests: extract printrevset extension from test-glog-beautifygraph.t
Augie Fackler <augie@google.com>
parents:
diff changeset
    36
            ui.write(revsetlang.prettyformat(tree) + b'\n')
a271466cb53a tests: extract printrevset extension from test-glog-beautifygraph.t
Augie Fackler <augie@google.com>
parents:
diff changeset
    37
            ui.write(stringutil.prettyrepr(revs) + b'\n')
a271466cb53a tests: extract printrevset extension from test-glog-beautifygraph.t
Augie Fackler <augie@google.com>
parents:
diff changeset
    38
            revs = smartset.baseset()  # display no revisions
a271466cb53a tests: extract printrevset extension from test-glog-beautifygraph.t
Augie Fackler <augie@google.com>
parents:
diff changeset
    39
        return revs, filematcher
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 39095
diff changeset
    40
39095
a271466cb53a tests: extract printrevset extension from test-glog-beautifygraph.t
Augie Fackler <augie@google.com>
parents:
diff changeset
    41
    extensions.wrapfunction(logcmdutil, 'getrevs', printrevset)
a271466cb53a tests: extract printrevset extension from test-glog-beautifygraph.t
Augie Fackler <augie@google.com>
parents:
diff changeset
    42
    aliases, entry = cmdutil.findcmd(b'log', commands.table)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 39095
diff changeset
    43
    entry[1].append(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 39095
diff changeset
    44
        (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 39095
diff changeset
    45
            b'',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 39095
diff changeset
    46
            b'print-revset',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 39095
diff changeset
    47
            False,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 39095
diff changeset
    48
            b'print generated revset and exit (DEPRECATED)',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 39095
diff changeset
    49
        )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 39095
diff changeset
    50
    )