Commit Graph

31281 Commits

Author SHA1 Message Date
Jun Wu
6525da3ca6 histedit: add a method to cleanup nodes safely
The new method will decide between:

  - cleanupnode, which calls the unsafe repair.strip
  - create obsmarkers

Ideally, nobody calls "cleanupnode" directly except for "safecleanupnode".
2017-03-13 21:10:45 -07:00
Rishabh Madan
dad9bc22cf py3: prove hg status works 2017-03-21 07:22:13 +05:30
Augie Fackler
8e92fda6f8 localrepo: use node.hex instead of awkward .encode('latin1')
Spotted as an option by Yuya. Thanks!
2017-03-20 22:06:57 -04:00
Rishabh Madan
b77ef07817 py3: prove hg config works 2017-03-21 03:15:18 +05:30
Yuya Nishihara
32e72957d2 templater: make pad() strip color codes before computing width (issue5416)
Tested in ANSI mode. We might have to extend _ansieffectre to support
terminfo mode.
2017-03-18 21:02:20 +09:00
Yuya Nishihara
b5783c4070 templater: make pad() compute actual width
str.ljust() and .rjust() are based on byte length, which are valid only for
ASCII characters.
2017-03-18 20:50:15 +09:00
Yuya Nishihara
469d1e92a3 templater: reject bad fillchar argument passed to pad()
Otherwise TypeError would be raised.
2017-03-18 20:38:44 +09: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
Yuya Nishihara
264083dae7 debugtemplate: pass ui to templater so label() works
Follows up 64cf8f39aac2.
2017-03-18 19:59:47 +09:00
Durham Goode
30b5b6d685 merge: remove unnecessary matcher checks
As part of changing manifest.diff to accept a matcher, a previous patch added
matcher calls to each location in merge.manifestmerge that tested if 'x in mf'
to maintain the same behavior as before. After analyzing it further, this
matcher call isn't needed, and in fact hurts future patches ability to use the
matcher here.

Basically, all these 'if x in mf' checks were checking if a matched file's copy
source was in the matcher as well. This meant if you passed a matcher for just
file foo, it would not return file bar even if foo was a copy of bar. Since
manifestmerge cares about copy information, let's allow all lookups of copy
sources.

We also update one spot with a 'is not None' check, since it wasn't obvious that
the value could sometimes be None before, which broke when we called
matcher(None).

A future patch adds matcher optimizations to manifestmerge which causes this
code path to get covered by existing tests.
2017-03-19 11:42:17 -07:00
Durham Goode
c54132949d rebase: use one dirstateguard for entire rebase
Recently we switched rebases to run the entire rebase inside a single
transaction, which dramatically improved the speed of rebases in repos with
large working copies. Let's also move the dirstate into a single dirstateguard
to get the same benefits. This let's us avoid serializing the dirstate after
each commit.

In a large repo, rebasing 27 commits is sped up by about 20%.

I believe the test changes are because us touching the dirstate gave the
transaction something to actually rollback.
2017-03-19 11:54:15 -07:00
Durham Goode
6373006050 histedit: add histedit.singletransaction config option
This adds an option (which defaults to False) to run entire histedits in a
single transaction. This results in 20-25% faster histedits in large repos where
transaction startup cost is expensive.

I didn't want to enable this by default because it has some unfortunate side
effects. For instance, if a pretxncommit hook throws midway through the
histedit, it will rollback the entire histedit and lose any progress the user
had made. Same if the user aborts editting a commit message. It's still worth
turning this on for large repos, but probably not for normal sized repos.

Long term, once we have inmemory merging, we could do the entire histedit in
memory, without a transaction, then we could selectively rollback just parts of
it in the event of an exception.

Tested it by running the tests with
`--extra-config-opt=histedit.singletransaction=True`. The only failure was
related to the hook rollback issue I mention above.
2017-03-10 15:52:29 -08:00
Durham Goode
3b715e3357 histedit: pop action after the action is completed
We only want to pop the action after the action is completed, since if the
action aborts part way through we want it to remain at the front of the list so
continue/abort will start with it.

Previously we relied on the fact that we only serialized the state file at the
beginning of the action, so the pop wasn't serialized until the next iteration
of the loop. In a future patch we will be adding a large transaction around this
area, which means if we pop the list early it might get serialized if the action
throws a user InterventionRequired error, at which point the action is not in
the list anymore. So let's only pop it once the action is really truly done.
2017-03-10 15:43:31 -08:00
Durham Goode
6cd32520b1 histedit: add transaction support to writing the state file
This will be used in a future diff to enable a single transaction around an
entire histedit.
2017-03-10 15:43:31 -08:00
Augie Fackler
18340f960e localrepo: forcibly copy list of filecache keys
On Python 3, keys() is more like iterkeys(), so we got in trouble for
mutating the dict while we're iterating here. Since the list of caches
should be relatively small, work around this difference by just
forcing a copy of the key list.
2017-03-19 01:11:00 -04:00
Augie Fackler
00cba0f12b localrepo: turn hook kwargs back into strs before calling hook
It might be better to ensure that the hook kwargs dict only has str
keys on Python 3. I'm torn.
2017-03-19 01:10:02 -04:00
Augie Fackler
092cc849d4 localrepo: ensure transaction id is fully bytes on py3 2017-03-19 01:08:59 -04:00
Augie Fackler
4ee50ed840 dirstate: use future-proof next(iter) instead of iter.next
The latter has been removed in Python 3.
2017-03-19 01:08:17 -04:00
Augie Fackler
297b49fbca posix: tiptoe around tempfile module more delicately
Some of the values inside the tempfile calls here are str on Python 3,
so we've got to pass str in. Use fsdecode to work around the issue.
2017-03-19 01:06:47 -04:00
Augie Fackler
e5b22f1ea6 posix: use open() instead of file() 2017-03-19 01:05:48 -04:00
Augie Fackler
e0f1b901d8 revlog: use int instead of long
By my reading of PEP 237[0], this is completely safe and has been
since Python 2.2.

0: https://www.python.org/dev/peps/pep-0237/
2017-03-19 01:05:28 -04:00
Augie Fackler
67b9f85199 error: use r-string to properly pop hints from **kw
Fixes the hint mixin on Python 3.
2017-03-19 01:02:42 -04:00
Augie Fackler
7a3b5c3c7d dispatch: use pycompat.maplist to allow summing with args 2017-03-19 14:17:07 -04:00
Augie Fackler
2c48d16072 pycompat: add maplist alias for old map behavior 2017-03-19 14:12:38 -04:00
Augie Fackler
f1710548b8 dispatch: replace mayberepr with shellquote
The quoting logic here was actually insufficient, and would have had
bogus b-prefixes on Python 3. shellquote seems more appropriate
anyway. Surprisingly, only two tests have output changes, and both of
them look reasonable to me (both are in blackbox logs).

Spotted by Yuya during review.
2017-03-19 14:23:30 -04:00
Matt Harbison
e8a2cad68d color: sync text attributes and buffered text output on Windows (issue5508)
I originally noticed that log output wasn't being colored after 348863ccec7e,
but there were other complications too.  With a bunch of untracked files, only
the first 1K of characters were colored pink, and the rest were normal white.  A
single modified file at the top would also be colored pink.

Line buffering and full buffering are treated as the same thing in Windows [1],
meaning the stream is either buffered or not.  I can't find any explicit
documentation to say stdout is unbuffered by default when attached to a console
(but some internet postings indicated that is the case[2]).  Therefore, it seems
that explicit flushes are better than just not reopening stdout.

NB: pager is now on by default, and needs to be disabled to see any color on
Windows.

[1] https://msdn.microsoft.com/en-us/library/86cebhfs(v=vs.140).aspx
[2] https://sourceforge.net/p/mingw/mailman/message/27121137/
2017-03-19 12:44:45 -04:00
Matt Harbison
5c542a74e6 test-check-help: fix to work on Windows
The initial problem was `hg files` prints paths with '\', which gets removed
when piped (scanhelptopics.py failed to open 'hgext__init__.py').  Then, xargs
was invoking `hg help` with 'backout\r (esc)', which setting binary mode
prevents.
2017-03-19 14:42:45 -04:00
Augie Fackler
be6b2aa4cc branchmap: be more careful about using %d on ints
Not doing so breaks Python 3.
2017-03-19 01:01:25 -04:00
Augie Fackler
c476b55519 util: use bytes re on bytes input in fspath
Fixes `hg add` on Python 3.
2017-03-19 00:16:39 -04:00
Augie Fackler
585f46ae2f util: use pycompat.bytestr in checkwinfilename
Fixes `hg add` on python3.
2017-03-19 00:16:08 -04:00
Augie Fackler
4eeee9b0e9 dispatch: ensure repr is bytes in _mayberepr
Fixes command line arguments containing spaces on Python 3.
2017-03-19 00:22:04 -04:00
Augie Fackler
ecf3381175 dispatch: extract maybe-use-repr formatting to helper function
I think this makes the code much clearer. I had to think for a bit to
unpack the old-school `condition and if-true or if-false` dance, and
formatting argument lists here shouldn't be performance critical.
2017-03-19 00:21:26 -04:00
Augie Fackler
956c1da8ce dispatch: consolidate formatting of arguments
This was getting done twice, and it's clever enough I'm about to split
it apart and then fix it for Python 3.
2017-03-19 00:18:53 -04:00
Pulkit Goyal
03903626e4 py3: make the regular expression bytes to prevent TypeError 2017-03-17 05:10:58 +05:30
Yuya Nishihara
7701e518b5 pager: flush outputs before firing pager process
So that buffered outputs are always sent to the console.
2017-02-25 17:29:30 +09:00
Yuya Nishihara
21edd5907a patchbomb: use modern pager to display -n/--test result (BC)
This should provide more consistent UX, but is a BC because the pager will
no longer be fired up for each message.
2017-02-25 17:27:48 +09:00
Yuya Nishihara
e780f7677e httpconnection: make sure to clear progress of httpsendfile at EOF
read() should never raise EOFError. If it did, UnboundLocalError would occur
due to unassigned 'ret' variable.

This issue was originally reported to TortoiseHg:
https://bitbucket.org/tortoisehg/thg/issues/4707/
2017-03-18 16:02:14 +09:00
Yuya Nishihara
7e7dd65819 py3: convert log opts to bytes-key dict
Now simple log command works.
2017-03-14 18:23:59 +09:00
Yuya Nishihara
2b0fe29f27 graphlog: pass function arguments without expansion
It's annoying on Python 3 because keys must be unicode type. Let's stop using
**opts expansion when not necessary.
2017-03-14 18:16:13 +09:00
Yuya Nishihara
687bfe4011 py3: call codecs.escape_decode() directly
The same rule as 9ecf9a0c9837 applies.
2017-03-17 23:48:22 +09:00
Yuya Nishihara
dc88179a4e util: wrap s.decode('string_escape') calls for future py3 compatibility 2017-03-17 23:42:46 +09:00
Augie Fackler
b35d966e25 merge with stable 2017-03-18 12:27:52 -04:00
Gregory Szorc
aff9286eb0 exchange: use v2 bundles for modern compression engines (issue5506)
Previously, `hg bundle zstd` on a non-generaldelta repo would
attempt to use a v1 bundle. This would fail because zstd is not
supported on v1 bundles.

This patch changes the behavior to automatically use a v2 bundle
when the user explicitly requests a bundlespec that is a compression
engine not supported on v1. If the bundlespec is <engine>-v1, it is
still explicitly rejected because that request cannot be fulfilled.
2017-03-16 12:33:15 -07:00
Gregory Szorc
3bbb6e2c52 exchange: reject new compression engines for v1 bundles (issue5506)
Version 1 bundles only support a fixed set of compression engines.
Before this change, we would accept any compression engine for v1
bundles, even those that may not work on v1. This could lead to
an error.

We define a fixed set of compression engines known to work with v1
bundles and we add checking to ensure a newer engine (like zstd)
won't work with v1 bundles.

I also took the liberty of adding test coverage for unknown compression
names because I noticed we didn't have coverage of it before.
2017-03-16 12:23:56 -07:00
Augie Fackler
5811358454 pycompat: verify sys.argv exists before forwarding it (issue5493)
ISAPI_WSGI doesn't set up sys.argv, so we have to look for the
attribute before assuming it exists.
2017-03-07 13:24:24 -05:00
Matt Harbison
27ca0a8a5b hgwebdir: add support for explicit index files
This is useful for when repositories are nested in --web-conf, and in the future
with hosted subrepositories.  The previous behavior was only to render an index
at each virtual directory.  There is now an explicit 'index' child for each
virtual directory.  The name was suggested by Yuya, for consistency with the
other method names.

Additionally, there is now an explicit 'index' child for every repository
directory with a nested repository somewhere below it.  This seems more
consistent with each virtual directory hosting an index, and more discoverable
than to only have an index for a directory that directly hosts a nested
repository.  I couldn't figure out how to close the loop and provide one in each
directory without a deeper nested repository, without blocking a committed
'index' file.  Keeping that seems better than rendering an empty index.
2017-03-05 22:22:32 -05: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
Martin von Zweigbergk
c56b4f93aa tests: allow ModuleNotFoundError in addition to ImportError
My environment (Python version? PYTHONPATH? something else?) raises
ModuleNotFoundError in test-check-py3-compat.t. This patch allows any
"*Error". The error string contains "error importing", so it seems
specific enough even after.
2017-03-17 09:58:49 -07:00
Augie Fackler
3839a3e429 pager: skip running the pager if it's set to 'cat'
Avoid useless uses of cat.
2017-03-15 20:34:26 -04:00
Augie Fackler
dd0af0f250 pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
man(1) behaves as poorly as Mercurial without this change. This cribs
from git's run-command[0], which has a list of characters that imply a
string that needs to be run using 'sh -c'. If none of those characters
are present in the command string, we can use shell=False mode on
subprocess and get significantly better error messages (see the test)
when the pager process is invalid. With a complicated pager command
(that contains one of the unsafe characters), we behave as we do today
(which is no worse than git manages.)

I briefly tried tapdancing in a thread to catch early pager exits, but
it's just too perilous: you get races between fd duping operations and
a bad pager exiting, and it's too hard to differentiate between a
slow-bad-pager result and a fast-human-quit-pager-early result.

I've observed some weird variation in exit code handling in the "bad
experience" case in test-pager.t: on my Mac hg predictably exits
nonzero, but on Linux hg always exits zero in that case. For now,
we'll work around it with || true. :(

0: cddbda4bc8/run-command.c (L201)
2017-03-15 20:33:47 -04:00