Mercurial > hg
annotate tests/printrevset.py @ 47072:4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Since the dawn of time, people have been forced to rely to lossy introspection
of the index filename to determine what the purpose and role of the revlog they
encounter is. This is hacky, error prone, inflexible, abstraction-leaky,
<insert-your-own-complaints-here>.
In f63299ee7e4d Raphaël introduced a new attribute to track this information:
`revlog_kind`. However it is initialized in an odd place and various instances
end up not having it set. In addition is only tracking some of the information
we end up having to introspect in various pieces of code.
So we add a new attribute that holds more data and is more strictly enforced.
This work is done in collaboration with Raphaël.
The `revlog_kind` one will be removed/adapted in the next changeset. We expect
to be able to clean up various existing piece of code and to simplify coming
work around the newer revlog format.
Differential Revision: https://phab.mercurial-scm.org/D10352
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Tue, 06 Apr 2021 05:20:24 +0200 |
parents | c1d0f83d62c4 |
children | 6000f5b25c9b |
rev | line source |
---|---|
39058
a271466cb53a
tests: extract printrevset extension from test-glog-beautifygraph.t
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
1 from __future__ import absolute_import |
45565
c1d0f83d62c4
log: introduce struct that carries log traversal options
Yuya Nishihara <yuya@tcha.org>
parents:
45564
diff
changeset
|
2 from mercurial.thirdparty import attr |
39058
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:
39058
diff
changeset
|
4 cmdutil, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39058
diff
changeset
|
5 commands, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39058
diff
changeset
|
6 extensions, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39058
diff
changeset
|
7 logcmdutil, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39058
diff
changeset
|
8 revsetlang, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39058
diff
changeset
|
9 smartset, |
39058
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:
39058
diff
changeset
|
12 from mercurial.utils import stringutil |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39058
diff
changeset
|
13 |
39058
a271466cb53a
tests: extract printrevset extension from test-glog-beautifygraph.t
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
14 |
45565
c1d0f83d62c4
log: introduce struct that carries log traversal options
Yuya Nishihara <yuya@tcha.org>
parents:
45564
diff
changeset
|
15 def logrevset(repo, wopts): |
c1d0f83d62c4
log: introduce struct that carries log traversal options
Yuya Nishihara <yuya@tcha.org>
parents:
45564
diff
changeset
|
16 revs = logcmdutil._initialrevs(repo, wopts) |
39058
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 |
45565
c1d0f83d62c4
log: introduce struct that carries log traversal options
Yuya Nishihara <yuya@tcha.org>
parents:
45564
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:
45564
diff
changeset
|
20 wopts = attr.evolve(wopts, pats=pats) |
c1d0f83d62c4
log: introduce struct that carries log traversal options
Yuya Nishihara <yuya@tcha.org>
parents:
45564
diff
changeset
|
21 return logcmdutil._makerevset(repo, wopts, slowpath) |
39058
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:
39058
diff
changeset
|
23 |
39058
a271466cb53a
tests: extract printrevset extension from test-glog-beautifygraph.t
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
24 def uisetup(ui): |
45565
c1d0f83d62c4
log: introduce struct that carries log traversal options
Yuya Nishihara <yuya@tcha.org>
parents:
45564
diff
changeset
|
25 def printrevset(orig, repo, wopts): |
c1d0f83d62c4
log: introduce struct that carries log traversal options
Yuya Nishihara <yuya@tcha.org>
parents:
45564
diff
changeset
|
26 revs, filematcher = orig(repo, wopts) |
c1d0f83d62c4
log: introduce struct that carries log traversal options
Yuya Nishihara <yuya@tcha.org>
parents:
45564
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:
45564
diff
changeset
|
28 expr = logrevset(repo, wopts) |
39058
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 |
45565
c1d0f83d62c4
log: introduce struct that carries log traversal options
Yuya Nishihara <yuya@tcha.org>
parents:
45564
diff
changeset
|
35 ui.write(b'%s\n' % stringutil.pprint(wopts.opts.get(b'rev', []))) |
39058
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:
39058
diff
changeset
|
40 |
39058
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:
39058
diff
changeset
|
43 entry[1].append( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39058
diff
changeset
|
44 ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39058
diff
changeset
|
45 b'', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39058
diff
changeset
|
46 b'print-revset', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39058
diff
changeset
|
47 False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39058
diff
changeset
|
48 b'print generated revset and exit (DEPRECATED)', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39058
diff
changeset
|
49 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39058
diff
changeset
|
50 ) |