Commit Graph

73 Commits

Author SHA1 Message Date
Jun Wu
850022dd70 convert: drop cvs support
Summary:
The CVS branch support will break with the upcoming branchcache removal.
CVS repos are rare. Let's just remove the code.

Differential Revision: D14179863

fbshipit-source-id: 890ce34958d2efe4f2ef02b1d72cf92f6269378c
2019-02-22 21:02:41 -08:00
Mark Thomas
87ba57b104 doctest: use new package path
Reviewed By: DurhamG, ikostia

Differential Revision: D13932057

fbshipit-source-id: 3b7cb640c7c510bd60ee2a3d1de737743686878b
2019-02-01 17:53:22 -08:00
Durham Goode
3713a821f8 hggit: sort git-mapfile and use bisect to do git-getmeta
Summary:
Previously, git-getmeta would have to scan through the entire git map
file, which was extremely expensive. Let's shift this cost to write time by
sorting the map file before writing, then using bisect to lookup nodes.

A while ago we switch hggit to only serialize the mapfile every 100 commits or
so, so the additional time here shouldn't be excessive.

Reviewed By: quark-zju

Differential Revision: D10470293

fbshipit-source-id: 47e23d251adde5456e7b593bfcc5976259a497f2
2018-10-19 15:42:18 -07:00
Jun Wu
4337aee636 mq: remove the extension
Summary:
mq is already somehow problematic at D8907646. Without bandwidth supporting
it, let's remove it.

Alternative to mq would be rebase, shelve, unshelve, histedit.

Maintain "--config extensions.mq=" compatibility by marking it builtin so hg4idea
won't break by this change.

Reviewed By: phillco

Differential Revision: D9039741

fbshipit-source-id: a3a1e48a2a982ff8e8b6a6ce659c906a4e2b2b36
2018-07-30 08:49:26 -07:00
Jun Wu
1499191e20 template: add a utility function to render template
Summary:
The added method takes an environment (`props`), and a program written in
the template language, execute the program, and pass output to `ui.write`.

The API is similar to the upstream [1]. But it avoids `ctx` intentionally.
Since the "environment" should be more flexible than having to have a `ctx`.

[1]: aa32940279

Reviewed By: mitrandir77

Differential Revision: D8221079

fbshipit-source-id: 94ee5c563f943330ef91966a4883c5733cc8dac9
2018-06-06 15:43:25 -07:00
Lukasz Langa
dfda82e492 Upgrade to 18.5b1
Summary: Mostly empty lines removed and added.  A few bugfixes on excessive line splitting.

Reviewed By: quark-zju

Differential Revision: D8199128

fbshipit-source-id: 90c1616061bfd7cfbba0b75f03f89683340374d5
2018-05-30 02:23:58 -07:00
Jun Wu
584656dff3 codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).

Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.

Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.

An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.

As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.

Reviewed By: wez, phillco, simpkins, pkaush, singhsrb

Differential Revision: D8173629

fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-25 22:17:29 -07:00
Simon Farnsworth
c9914836f9 account for drawdag move in test-doctest.py
Summary:
D6827925 deletes drawdag.py from the tests directory; because the
tests in that revision were run on a repo with .pyc files left behind, the test
failure never happened. Move the test to the new location

Differential Revision: D6845181

fbshipit-source-id: 33c2836d81f66c9cc2a8e82a78b2d6835278a2ac
2018-04-13 21:51:00 -07:00
Yuya Nishihara
b0d1fec38b fancyopts: add early-options parser compatible with getopt()
The next patch will add a flag for strict parsing of early options, where
we'll have to parse all early options at once instead of processing them
one-by-one by dispatch._earlygetopt(). That's why I decided to hook
fancyopts().

All dispatch._early*opt() functions is planned to be replaced with this
function. But in this stable series, only the strict mode will be handled
by fancyopts.earlygetopt().
2017-11-23 22:04:53 +09:00
Yuya Nishihara
d852dda377 doctest: drop hack to run py2/3 tests selectively
All doctests pass on Python 3.
2017-09-27 21:38:48 +09:00
Yuya Nishihara
e9abfd594c py3: work around bytes/unicode divergence in parsedate() 2017-09-27 19:27:41 +09:00
Yuya Nishihara
c94105ba63 py3: replace str(None) with literal in convcmd.py 2017-09-27 19:08:23 +09:00
Yuya Nishihara
e896c6e733 py3: remove use of str() in hgwebdir
'%d' can't be used here since port may be either integer or byte string.
2017-09-27 19:04:32 +09:00
Yuya Nishihara
407d4549be py3: convert system strings to bytes in doctest of formatter.py 2017-09-17 12:39:53 +09:00
Yuya Nishihara
50fbaed638 py3: use bytes os.sep in doctest of pathutil.py 2017-09-17 12:26:42 +09:00
Yuya Nishihara
012701ee30 py3: fix doctests in patch.py to be compatible with Python 3
We were lucky that parsepatch() could concatenate a character slice as if
it were a list of chunks.
2017-09-17 12:23:16 +09:00
Yuya Nishihara
0284e70ec0 py3: use 'surrogatepass' error handler to process U+DCxx transparently
It's disallowed by default on Python 3.

https://docs.python.org/3/library/codecs.html#error-handlers
2017-09-16 22:55:48 +09:00
Yuya Nishihara
cd2add86f9 py3: iterate bytes as a byte string in store.lowerencode() 2017-09-03 17:28:47 +09:00
Yuya Nishihara
8a515cf238 py3: iterate bytes as a byte string in dagparser.py 2017-09-03 15:32:45 +09:00
Yuya Nishihara
81c2aaf747 py3: convert function name to bytes in ui.configwith() 2017-09-03 17:47:21 +09:00
Augie Fackler
23df90a15a drawdag: add a couple of doctests to help with python3 porting 2017-08-23 10:51:26 -04:00
Yuya Nishihara
53d5208ef2 doctest: enable tests by default on Python 3
Still several tests fail mostly because of the string issues, sigh. I'll
fix them one by one.
2017-09-03 15:09:04 +09:00
Yuya Nishihara
b2d9e161ed doctest: normalize b'', u'' and exception output on Python 3
The idea is described in the following page.

https://dirkjan.ochtman.nl/writing/2014/07/06/single-source-python-23-doctests.html

# no-check-commit
2017-08-24 22:33:28 +09:00
Siddharth Agarwal
259f128038 annotate: add core algorithm to skip a rev
The core algorithm is inspired by git hyper-blame, implemented at
https://chromium.googlesource.com/chromium/tools/depot_tools.git/+/master/git_hyper_blame.py.

The heuristic is as documented in the comments.
2017-05-24 19:07:14 -07:00
Denis Laxalde
927c1336ab mdiff: add a hunkinrange helper function
This factors out hunk filtering logic by line range that is similar in
mdiff.blocksinrange() and hgweb.webutil.diffs().
2017-04-01 12:24:59 +02:00
Yuya Nishihara
5af4f5ecfd color: insert color code after every "\e[0m" (issue5413)
This assumes the last color wins, tested in ANSI mode. I guess terminfo mode
would work in the same way.
2017-03-18 20:11:15 +09:00
Jun Wu
3d8879dca9 ui: move configlist parser to config.py
The list parser is complex and reusable without ui. Let's move it to
config.py.

This allows us to parse a list from a "pure" config object without going
through ui. Like, we can make "_trustusers" calculated from raw configs,
instead of making sure it's synchronized by calling "fixconfig"s.
2017-03-17 09:19:56 -07:00
Yuya Nishihara
791afb08eb pycompat: add bytestr wrapper which mostly acts as a Python 2 str
This allows us to handle bytes in mostly the same manner as Python 2 str,
so we can get rid of ugly s[i:i + 1] hacks:

  s = bytestr(s)
  while i < len(s):
      c = s[i]
      ...

This is the simpler version of the previous RFC patch which tried to preserve
the bytestr type if possible. New version simply drops the bytestr wrapping
so we aren't likely to pass a bytestr to a function that expects Python 3
bytes.
2017-03-08 22:48:26 +09:00
Yuya Nishihara
8b296e4cfa tests: allow running doctests selectively on Python 3
Currently most doctests fail on Python 3, but I want to add some.
2017-03-08 22:13:32 +09:00
Yuya Nishihara
b2229f5117 revset: split language services to revsetlang module (API)
New revsetlang module hosts parser, tokenizer, and miscellaneous functions
working on parsed tree. It does not include functions for evaluation such as
getset() and match().

  2288 mercurial/revset.py
   684 mercurial/revsetlang.py
  2972 total

get*() functions are aliased since they are common in revset.py.
2017-02-19 18:19:33 +09:00
Yuya Nishihara
2e50d5587f smartset: move set classes and related functions from revset module (API)
These classes are pretty large and independent from revset computation.

  2961 mercurial/revset.py
   973 mercurial/smartset.py
  3934 total

revset.prettyformatset() is renamed to smartset.prettyformat(). Smartset
classes are aliased since they are quite common in revset.py.
2016-10-16 17:28:51 +09:00
Yuya Nishihara
0a5e04d63d formatter: add overview of API and example as doctest 2016-10-22 15:02:11 +09:00
Pulkit Goyal
8c6c495c76 tests: make test-doctest use absolute_import 2016-04-16 03:38:23 +05:30
Augie Fackler
d33d6a0cb5 changegroup: introduce cg3, which has support for exchanging treemanifests
I'm not entirely happy with using a trailing / on a "file" entry for
transferring a treemanifest. We've discussed putting some flags on
each file header[0], but I'm unconvinced that's actually any better:
if we were going to add another feature to the cg format we'd still be
doing a version bump anyway to cg4, so I'm inclined to not spend time
coming up with a more sophisticated format until we actually know what
the next feature we want to stuff in a changegroup will be.

Test changes outside test-treemanifest.t are only due to the new CG3
bundlecap showing up in the wire protocol.

Many thanks to adgar@google.com and martinvonz@google.com for helping
me with various odd corners of the changegroup and treemanifest API.

0: It's not hard refactoring, nor is it a lot of work. I'm just
disinclined to do speculative work when it's not clear what the
customer would actually be.
2015-12-11 11:23:49 -05:00
Eugene Baranov
afafa68827 convert: use 'default' for specifying branch name in branchmap (issue4753)
A fix for issue2653 with f5abbf51a76e introduced a discrepancy how default
branch should be denoted when converting with branchmap from different SCM.
E.g. for Git and Mercurial you need to use 'default' whilst for Perforce and
SVN you had to use 'None'. This changeset unifies 'default' for such purposes
whilst falling back to 'None' when no 'default' mapping specified.
2015-07-14 14:40:56 +01:00
Eugene Baranov
39327b5b56 convert: unescape Perforce-escaped special characters in filenames 2015-07-14 16:23:57 +01:00
Yuya Nishihara
4444465461 templater: introduce one-pass parsing of nested template strings
Instead of re-parsing quoted strings as templates, the tokenizer can delegate
the parsing of nested template strings to the parser. It has two benefits:

 1. syntax errors can be reported with absolute positions
 2. nested template can use quotes just like shell: "{"{rev}"}"

It doesn't sound nice that the tokenizer recurses into the parser. We could
instead make the tokenize itself recursive, but it would be much more
complicated because we would have to adjust binding strengths carefully and
put dummy infix operators to concatenate template fragments.

Now "string" token without r"" never appears. It will be removed by the next
patch.
2015-06-15 23:11:35 +09:00
Yuya Nishihara
ca51f820ee parser: add helper to reduce nesting of chained infix operations
This will be used to avoid stack overflow caused by chained 'or' operations
in revset.
2015-04-26 18:05:23 +09:00
Siddharth Agarwal
3aa3a9554f patch.pathtransform: add doctests
In upcoming patches we're going to make this function more complex, so add some
unit tests for it.
2015-03-06 21:48:40 -08:00
Mads Kiilerich
44bd94dc4e mq: refactor patchheader header ordering to match export (BC)
The refactoring also gives more robust and extendable handling of other HG
headers.
2014-09-24 02:41:11 +02:00
FUJIWARA Katsunori
85d651396d subrepo: normalize path in the specific way for problematic encodings
Before this patch, "reporelpath()" uses "rstrip(os.sep)" to trim
"os.sep" at the end of "parent.root" path.

But it doesn't work correctly with some problematic encodings on
Windows, because some multi-byte characters in such encodings contain
'\\' (0x5c) as the tail byte of them.

In such cases, "reporelpath()" leaves unexpected '\\' at the beginning
of the path returned to callers.

"lcalrepository.root" seems not to have tail "os.sep", because it is
always normalized by "os.path.realpath()" in "vfs.__init__()", but in
fact it has tail "os.sep", if it is a root (of the drive): path
normalization trims tail "os.sep" off "/foo/bar/", but doesn't trim
one off "/".

So, just avoiding "rstrip(os.sep)" in "reporelpath()" causes
regression around issue3033 fixed by e3dfde137fa5.

This patch introduces "pathutil.normasprefix" to normalize specified
path in the specific way for problematic encodings without regression
around issue3033.
2014-05-08 19:03:00 +09:00
Siddharth Agarwal
cb8e8f55a1 subrepo: factor out Git version check to add doctests
Followup to 80233b59577b::49a2288fb74f.
2014-03-21 16:09:17 -07:00
Yuya Nishihara
b9bc586fe9 clone: add doctest for default destination 2014-03-22 00:46:08 +09:00
Mads Kiilerich
17aeb0d9e4 convert: make subversion revsplit more stable when meeting revisions without @
revsplit would crash for instance if given a subversion string without @ ...
and that could somehow happen when playing around with convert.
2014-02-07 17:28:37 +01:00
Mads Kiilerich
b0ab086db9 convert: readability and test of rpairs function 2013-11-17 11:18:39 -05:00
Mads Kiilerich
18b361e0b2 tests: make doctest test runner less verbose 2013-11-17 11:16:59 -05:00
Bryan O'Sullivan
6ad1b7d190 dispatch: add doctests for _earlygetopt 2013-04-29 14:14:41 -07:00
Remy Blank
77663c5e65 posix: fix split() for the case where the path is at the root of the filesystem
posixpath.split() strips '/' from the dirname *unless it is the root*. This
patch reproduces this behavior in posix.split(). The old behavior causes a
crash when creating a file at the root of the repo with localrepo.wfile()
when the repo is at the root of the filesystem.
2013-01-09 20:27:17 +01:00
Yann E. MORIN
e24b85ec3e templates/filters: add doctest to the 'person' filter
Add a doctest with an hopefuly-comprehensive list of combinations
we can expect in real-life situations.

This does not cover corner cases, for example when a CR or LF is
embedded in the name (allowed by RFC 5322!).

Code in tests/test-doctest.py contributed by:
    Martin Geisler <mg@aragost.com>
Thanks!

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
2012-03-07 01:02:12 +01:00
FUJIWARA Katsunori
f6b7a91d98 minirst: use unicode string as intermediate form for replacement
# this change redones part of e0051068893a, backed out by 38c00c035629

Some character encodings use ASCII characters other than
control/alphabet/digit as a part of multi-bytes characters, so direct
replacing with such characters on strings in local encoding causes
invalid byte sequences.

[mpm: test changed to simple doctest]
2011-10-31 21:06:18 +09:00