comparison tests/printrevset.py @ 39058:a271466cb53a

tests: extract printrevset extension from test-glog-beautifygraph.t Differential Revision: https://phab.mercurial-scm.org/D4251
author Augie Fackler <augie@google.com>
date Fri, 10 Aug 2018 02:02:40 -0400
parents
children 2372284d9457
comparison
equal deleted inserted replaced
39057:850fe0b9c0c0 39058:a271466cb53a
1 from __future__ import absolute_import
2 from mercurial import (
3 cmdutil,
4 commands,
5 extensions,
6 logcmdutil,
7 revsetlang,
8 smartset,
9 )
10
11 from mercurial.utils import (
12 stringutil,
13 )
14
15 def logrevset(repo, pats, opts):
16 revs = logcmdutil._initialrevs(repo, opts)
17 if not revs:
18 return None
19 match, pats, slowpath = logcmdutil._makematcher(repo, revs, pats, opts)
20 return logcmdutil._makerevset(repo, match, pats, slowpath, opts)
21
22 def uisetup(ui):
23 def printrevset(orig, repo, pats, opts):
24 revs, filematcher = orig(repo, pats, opts)
25 if opts.get(b'print_revset'):
26 expr = logrevset(repo, pats, opts)
27 if expr:
28 tree = revsetlang.parse(expr)
29 tree = revsetlang.analyze(tree)
30 else:
31 tree = []
32 ui = repo.ui
33 ui.write(b'%s\n' % stringutil.pprint(opts.get(b'rev', [])))
34 ui.write(revsetlang.prettyformat(tree) + b'\n')
35 ui.write(stringutil.prettyrepr(revs) + b'\n')
36 revs = smartset.baseset() # display no revisions
37 return revs, filematcher
38 extensions.wrapfunction(logcmdutil, 'getrevs', printrevset)
39 aliases, entry = cmdutil.findcmd(b'log', commands.table)
40 entry[1].append((b'', b'print-revset', False,
41 b'print generated revset and exit (DEPRECATED)'))