##// END OF EJS Templates
tests: extract printrevset extension from test-glog-beautifygraph.t...
Augie Fackler -
r39093:a271466c default
parent child Browse files
Show More
@@ -0,0 +1,41 b''
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)'))
@@ -80,52 +80,8 b' o (0) root'
80 > hg commit -Aqd "$rev 0" -m "($rev) $msg"
80 > hg commit -Aqd "$rev 0" -m "($rev) $msg"
81 > }
81 > }
82
82
83 $ cat > printrevset.py <<EOF
84 > from __future__ import absolute_import
85 > from mercurial import (
86 > cmdutil,
87 > commands,
88 > extensions,
89 > logcmdutil,
90 > revsetlang,
91 > smartset,
92 > )
93 >
94 > from mercurial.utils import (
95 > stringutil,
96 > )
97 >
98 > def logrevset(repo, pats, opts):
99 > revs = logcmdutil._initialrevs(repo, opts)
100 > if not revs:
101 > return None
102 > match, pats, slowpath = logcmdutil._makematcher(repo, revs, pats, opts)
103 > return logcmdutil._makerevset(repo, match, pats, slowpath, opts)
104 >
105 > def uisetup(ui):
106 > def printrevset(orig, repo, pats, opts):
107 > revs, filematcher = orig(repo, pats, opts)
108 > if opts.get(b'print_revset'):
109 > expr = logrevset(repo, pats, opts)
110 > if expr:
111 > tree = revsetlang.parse(expr)
112 > tree = revsetlang.analyze(tree)
113 > else:
114 > tree = []
115 > ui = repo.ui
116 > ui.write(b'%s\n' % stringutil.pprint(opts.get(b'rev', [])))
117 > ui.write(revsetlang.prettyformat(tree) + b'\n')
118 > ui.write(stringutil.prettyrepr(revs) + b'\n')
119 > revs = smartset.baseset() # display no revisions
120 > return revs, filematcher
121 > extensions.wrapfunction(logcmdutil, 'getrevs', printrevset)
122 > aliases, entry = cmdutil.findcmd(b'log', commands.table)
123 > entry[1].append((b'', b'print-revset', False,
124 > b'print generated revset and exit (DEPRECATED)'))
125 > EOF
126
127 $ echo "[extensions]" >> $HGRCPATH
83 $ echo "[extensions]" >> $HGRCPATH
128 $ echo "printrevset=`pwd`/printrevset.py" >> $HGRCPATH
84 $ echo "printrevset=$TESTDIR/printrevset.py" >> $HGRCPATH
129 $ echo "beautifygraph=" >> $HGRCPATH
85 $ echo "beautifygraph=" >> $HGRCPATH
130
86
131 Set a default of narrow-text UTF-8.
87 Set a default of narrow-text UTF-8.
General Comments 0
You need to be logged in to leave comments. Login now