| 1 |
from mercurial.thirdparty import attr |
| 2 |
from mercurial import ( |
| 3 |
commands, |
| 4 |
extensions, |
| 5 |
logcmdutil, |
| 6 |
revsetlang, |
| 7 |
smartset, |
| 8 |
) |
| 9 |
|
| 10 |
from mercurial.main_script import cmd_finder |
| 11 |
from mercurial.utils import stringutil |
| 12 |
|
| 13 |
|
| 14 |
def logrevset(repo, wopts): |
| 15 |
revs = logcmdutil._initialrevs(repo, wopts) |
| 16 |
if not revs: |
| 17 |
return None |
| 18 |
match, pats, slowpath = logcmdutil._makematcher(repo, revs, wopts) |
| 19 |
wopts = attr.evolve(wopts, pats=pats) |
| 20 |
return logcmdutil._makerevset(repo, wopts, slowpath) |
| 21 |
|
| 22 |
|
| 23 |
def uisetup(ui): |
| 24 |
def printrevset(orig, repo, wopts): |
| 25 |
revs, filematcher = orig(repo, wopts) |
| 26 |
if wopts.opts.get(b'print_revset'): |
| 27 |
expr = logrevset(repo, wopts) |
| 28 |
if expr: |
| 29 |
tree = revsetlang.parse(expr) |
| 30 |
tree = revsetlang.analyze(tree) |
| 31 |
else: |
| 32 |
tree = [] |
| 33 |
ui = repo.ui |
| 34 |
ui.write(b'%s\n' % stringutil.pprint(wopts.opts.get(b'rev', []))) |
| 35 |
ui.write(revsetlang.prettyformat(tree) + b'\n') |
| 36 |
ui.write(stringutil.prettyrepr(revs) + b'\n') |
| 37 |
revs = smartset.baseset() # display no revisions |
| 38 |
return revs, filematcher |
| 39 |
|
| 40 |
extensions.wrapfunction(logcmdutil, 'getrevs', printrevset) |
| 41 |
aliases, entry = cmd_finder.find_cmd(b'log', commands.table) |
| 42 |
entry[1].append( |
| 43 |
( |
| 44 |
b'', |
| 45 |
b'print-revset', |
| 46 |
False, |
| 47 |
b'print generated revset and exit (DEPRECATED)', |
| 48 |
) |
| 49 |
) |