printrevset.py
50 lines
| 1.4 KiB
| text/x-python
|
PythonLexer
/ tests / printrevset.py
Augie Fackler
|
r39093 | from __future__ import absolute_import | ||
Yuya Nishihara
|
r46139 | from mercurial.thirdparty import attr | ||
Augie Fackler
|
r39093 | from mercurial import ( | ||
Augie Fackler
|
r43346 | cmdutil, | ||
commands, | ||||
extensions, | ||||
logcmdutil, | ||||
revsetlang, | ||||
smartset, | ||||
Augie Fackler
|
r39093 | ) | ||
Augie Fackler
|
r43346 | from mercurial.utils import stringutil | ||
Augie Fackler
|
r39093 | |||
Yuya Nishihara
|
r46139 | def logrevset(repo, wopts): | ||
revs = logcmdutil._initialrevs(repo, wopts) | ||||
Augie Fackler
|
r39093 | if not revs: | ||
return None | ||||
Yuya Nishihara
|
r46139 | match, pats, slowpath = logcmdutil._makematcher(repo, revs, wopts) | ||
wopts = attr.evolve(wopts, pats=pats) | ||||
return logcmdutil._makerevset(repo, wopts, slowpath) | ||||
Augie Fackler
|
r39093 | |||
Augie Fackler
|
r43346 | |||
Augie Fackler
|
r39093 | def uisetup(ui): | ||
Yuya Nishihara
|
r46139 | def printrevset(orig, repo, wopts): | ||
revs, filematcher = orig(repo, wopts) | ||||
if wopts.opts.get(b'print_revset'): | ||||
expr = logrevset(repo, wopts) | ||||
Augie Fackler
|
r39093 | if expr: | ||
tree = revsetlang.parse(expr) | ||||
tree = revsetlang.analyze(tree) | ||||
else: | ||||
tree = [] | ||||
ui = repo.ui | ||||
Yuya Nishihara
|
r46139 | ui.write(b'%s\n' % stringutil.pprint(wopts.opts.get(b'rev', []))) | ||
Augie Fackler
|
r39093 | ui.write(revsetlang.prettyformat(tree) + b'\n') | ||
ui.write(stringutil.prettyrepr(revs) + b'\n') | ||||
revs = smartset.baseset() # display no revisions | ||||
return revs, filematcher | ||||
Augie Fackler
|
r43346 | |||
Augie Fackler
|
r39093 | extensions.wrapfunction(logcmdutil, 'getrevs', printrevset) | ||
aliases, entry = cmdutil.findcmd(b'log', commands.table) | ||||
Augie Fackler
|
r43346 | entry[1].append( | ||
( | ||||
b'', | ||||
b'print-revset', | ||||
False, | ||||
b'print generated revset and exit (DEPRECATED)', | ||||
) | ||||
) | ||||