Mercurial > hg
annotate tests/printrevset.py @ 45023:e54c3cafda15 stable
convert: convert URLs to UTF-8 for Subversion
Preamble: for comprehension, note that the `path` of geturl() would better be
called `path_or_url` (the argument of the call of getsvn() is called `url`).
For HTTP(S) URLs, the changes don’t make a difference, as they are restricted to
ASCII.
For file URLs, the reasoning is the same as for paths: we have to roundtrip with
what Subversion is doing.
When the locale encoding is ISO-8859-15, trying to convert a SVN repo
`file:///tmp/a€` failed before like this:
file:///tmp/a%A4 does not look like a Subversion repository to libsvn version 1.14.0
Decoding the path using the locale encoding can fail. In this case, we have to
bail out, as Subversion won’t be able to do anything useful with the path.
author | Manuel Jacob <me@manueljacob.de> |
---|---|
date | Tue, 30 Jun 2020 05:30:47 +0200 |
parents | 2372284d9457 |
children | a717de1cb624 |
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 |
a271466cb53a
tests: extract printrevset extension from test-glog-beautifygraph.t
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
2 from mercurial import ( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39058
diff
changeset
|
3 cmdutil, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39058
diff
changeset
|
4 commands, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39058
diff
changeset
|
5 extensions, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39058
diff
changeset
|
6 logcmdutil, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39058
diff
changeset
|
7 revsetlang, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39058
diff
changeset
|
8 smartset, |
39058
a271466cb53a
tests: extract printrevset extension from test-glog-beautifygraph.t
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
9 ) |
a271466cb53a
tests: extract printrevset extension from test-glog-beautifygraph.t
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
10 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39058
diff
changeset
|
11 from mercurial.utils import stringutil |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39058
diff
changeset
|
12 |
39058
a271466cb53a
tests: extract printrevset extension from test-glog-beautifygraph.t
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
13 |
a271466cb53a
tests: extract printrevset extension from test-glog-beautifygraph.t
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
14 def logrevset(repo, pats, opts): |
a271466cb53a
tests: extract printrevset extension from test-glog-beautifygraph.t
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
15 revs = logcmdutil._initialrevs(repo, opts) |
a271466cb53a
tests: extract printrevset extension from test-glog-beautifygraph.t
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
16 if not revs: |
a271466cb53a
tests: extract printrevset extension from test-glog-beautifygraph.t
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
17 return None |
a271466cb53a
tests: extract printrevset extension from test-glog-beautifygraph.t
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
18 match, pats, slowpath = logcmdutil._makematcher(repo, revs, pats, opts) |
a271466cb53a
tests: extract printrevset extension from test-glog-beautifygraph.t
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
19 return logcmdutil._makerevset(repo, match, pats, slowpath, opts) |
a271466cb53a
tests: extract printrevset extension from test-glog-beautifygraph.t
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
20 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39058
diff
changeset
|
21 |
39058
a271466cb53a
tests: extract printrevset extension from test-glog-beautifygraph.t
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
22 def uisetup(ui): |
a271466cb53a
tests: extract printrevset extension from test-glog-beautifygraph.t
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
23 def printrevset(orig, repo, pats, opts): |
a271466cb53a
tests: extract printrevset extension from test-glog-beautifygraph.t
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
24 revs, filematcher = orig(repo, pats, opts) |
a271466cb53a
tests: extract printrevset extension from test-glog-beautifygraph.t
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
25 if opts.get(b'print_revset'): |
a271466cb53a
tests: extract printrevset extension from test-glog-beautifygraph.t
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
26 expr = logrevset(repo, pats, opts) |
a271466cb53a
tests: extract printrevset extension from test-glog-beautifygraph.t
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
27 if expr: |
a271466cb53a
tests: extract printrevset extension from test-glog-beautifygraph.t
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
28 tree = revsetlang.parse(expr) |
a271466cb53a
tests: extract printrevset extension from test-glog-beautifygraph.t
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
29 tree = revsetlang.analyze(tree) |
a271466cb53a
tests: extract printrevset extension from test-glog-beautifygraph.t
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
30 else: |
a271466cb53a
tests: extract printrevset extension from test-glog-beautifygraph.t
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
31 tree = [] |
a271466cb53a
tests: extract printrevset extension from test-glog-beautifygraph.t
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
32 ui = repo.ui |
a271466cb53a
tests: extract printrevset extension from test-glog-beautifygraph.t
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
33 ui.write(b'%s\n' % stringutil.pprint(opts.get(b'rev', []))) |
a271466cb53a
tests: extract printrevset extension from test-glog-beautifygraph.t
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
34 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
|
35 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
|
36 revs = smartset.baseset() # display no revisions |
a271466cb53a
tests: extract printrevset extension from test-glog-beautifygraph.t
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
37 return revs, filematcher |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39058
diff
changeset
|
38 |
39058
a271466cb53a
tests: extract printrevset extension from test-glog-beautifygraph.t
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
39 extensions.wrapfunction(logcmdutil, 'getrevs', printrevset) |
a271466cb53a
tests: extract printrevset extension from test-glog-beautifygraph.t
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
40 aliases, entry = cmdutil.findcmd(b'log', commands.table) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39058
diff
changeset
|
41 entry[1].append( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39058
diff
changeset
|
42 ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39058
diff
changeset
|
43 b'', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39058
diff
changeset
|
44 b'print-revset', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39058
diff
changeset
|
45 False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39058
diff
changeset
|
46 b'print generated revset and exit (DEPRECATED)', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39058
diff
changeset
|
47 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39058
diff
changeset
|
48 ) |