Commit Graph

30644 Commits

Author SHA1 Message Date
Jun Wu
863f8667b5 commandserver: handle backlog before exiting
Previously, when a chg server is exiting, it does not handle connected
clients so clients may get ECONNRESET and crash:

  1. client connect() # success
  2. server shouldexit = True and exit
  3. client recv() # ECONNRESET

297d89f2789e makes this race condition easier to reproduce if a lot of short
chg commands are started in parallel.

This patch fixes the above issue by unlinking the socket path to stop
queuing new connections and processing all pending connections before exit.
2017-02-08 14:45:30 -08:00
Jun Wu
59177ba177 commandserver: prevent unlink socket twice
This patch changes unixforkingservice so it only calls
`self._servicehandler.unlinksocket(self.address)` at most once.

This is needed by the next patch.
2017-02-08 14:37:38 -08:00
Jun Wu
1deb78100c runtests: check ports on IPv6 address
Previously, checkportisavailable only checks ports on the IPv4 address. This
patch makes it check IPv6 as well. It'll be useful if "localhost" does not
have an IPv4 address, or its IPv4 address does not exist somehow.
2017-02-09 05:57:54 -08:00
Simon Farnsworth
8a0451d60e zeroconf: fail nicely on IPv6 only system
zeroconf only knows how to deal with IPv4; I develop on a system where the only
IPv4 address is 127.0.0.1.

Teach zeroconf to ignore IPv6 addresses when looking for plausible IPv4
connectivity.
2017-02-08 08:08:41 -08:00
Jun Wu
bb3aea397e chg: verify XDG_RUNTIME_DIR
According to the specification [1], $XDG_RUNTIME_DIR should be ignored
unless:

  The directory MUST be owned by the user, and he MUST be the only one
  having read and write access to it. Its Unix access mode MUST be 0700.

This patch adds a check and ignores it if it does not meet part of the
criteria.

[1]: https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
2017-02-06 17:01:06 -08:00
Yedidya Feldblum
6a9ac1262a check-code: permit functools.reduce 2017-01-21 14:43:13 -08:00
Gregory Szorc
5c3d4574aa perf: split obtaining chunks from decompression
Previously, the code was similar to what revlog._chunks() was doing,
which took a raw data segment and delta chain, obtained buffers for
the raw revlog chunks within, and decompressed them.

This commit splits the "get raw chunks" action from "decompress." The
goal of this change is to more accurately measurely decompression
performance.

On a ~50k deltachain for a manifest in mozilla-central:

! full
! wall 0.430548 comb 0.440000 user 0.410000 sys 0.030000 (best of 24)
! deltachain
! wall 0.016053 comb 0.010000 user 0.010000 sys 0.000000 (best of 181)
! read
! wall 0.008078 comb 0.010000 user 0.000000 sys 0.010000 (best of 362)
! rawchunks
! wall 0.033785 comb 0.040000 user 0.040000 sys 0.000000 (best of 100)
! decompress
! wall 0.327126 comb 0.320000 user 0.320000 sys 0.000000 (best of 31)
! patch
! wall 0.032391 comb 0.030000 user 0.030000 sys 0.000000 (best of 100)
! hash
! wall 0.012587 comb 0.010000 user 0.010000 sys 0.000000 (best of 233)
2017-02-04 08:47:46 -08: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
e2db88af41 help: test if "hg help TOPIC" reference is valid
It's quite easy to make a reference invalid by mistake.
2017-01-25 22:39:17 +09:00
Yuya Nishihara
0e09faf65f help: uppercase command placeholder
'command' isn't a valid help topic but a placeholder text. Make it upper
case to avoid confusion.
2017-01-25 22:35:40 +09:00
Yuya Nishihara
da936af562 help: show section that couldn't be found
For better error indication.
2017-02-05 18:57:19 +09:00
Augie Fackler
5fd61fb005 cmdutil: remove forwarding methods per deprecation policy 2017-02-03 16:01:19 -05:00
Simon Farnsworth
6a6899c4d4 util: always force line buffered stdout when stdout is a tty (BC)
pager replaced stdout with a line buffered version to work around glibc
deciding on a buffering strategy on the first write to stdout. This is going
to make my next patch hard, as replacing stdout will make tracking time
spent blocked on it more challenging.

Move the line buffering requirement to util.py, and remove it from pager.
This means that the abuse of ui.formatted=True and pager set to cat or equivalent
no longer results in a line-buffered output to a pipe, hence (BC), although
I don't expect anyone to be affected
2017-02-03 15:10:27 -08:00
Stanislau Hlebik
1ea3a2dcdf localrepo: avoid unnecessary conversion from node to rev
changelog.heads() first calls headrevs then converts them to nodes.
localrepo.heads() then sorts them using self.changelog.rev function and makes
useless conversion back to revs. Instead let's call changelog.headrevs() from
localrepo.heads(), sort the output and then convert to nodes. Because headrevs
does not support start parameter this optimization only works if start is None.
2017-02-02 02:56:38 -08:00
Pierre-Yves David
683feeeddd bundle2: implement a basic __repr__ for bundle2 part
We display basic data as the part id and part type. This make debugging bundle2
related code friendlier.
2017-02-02 14:19:48 +01:00
Pierre-Yves David
24dbeff39a bundle2: drop an outdated comment
The function is no longer in "early" stage and have been used in production for
years. We can probably drop that part of the docstring...
2017-02-02 11:03:41 +01:00
Pierre-Yves David
d10a1ec092 unbundle: swap conditional branches for clarity
This is a small style update for clarity. The previous situation was:

  if foo:
    50 lines
  else:
    2 lines

In such case I tend to invert these to get the simpler branch out of the way
earlier:

  if not foo:
    2 lines
  else:
    50 lines

This makes the conditional and various alternatives fit on the same screen,
simpler to read overall.
2017-02-02 10:53:55 +01:00
Pierre-Yves David
354f9b4dae unbundle: add a small comment to tag the bundle1 case as such
This makes the code clearer to understand for someone new to it (or rusted)
2017-02-02 10:55:38 +01:00
Pierre-Yves David
433e331144 unbundle: add a small comment to clarify the 'check_heads' call
Bundle2 has its own mechanisms to check for heads (and other) changes, so push
using bundle2 is relying on the "check:heads" bundle part of unbundle and the
'check_heads' call is not checking anything. We add a small comment to make
this clearer.
2017-02-02 10:51:04 +01:00
Simon Farnsworth
591b9bb95d pager: don't terminate with extreme prejudice on SIGPIPE (BC)
The default SIGPIPE handler causes Mercurial to exit immediately, without
running any Python cleanup code (except and finally blocks, atexit handlers
etc). This creates problems if you want to do something at exit.

If we need a different exit code for broken pipe from pager, then we should
code that ourselves in Python; this appears to have been cargo-culted from
the fork implementation of pager that's no longer used, where it was needed
to stop Broken Pipe errors appearing on the user's terminal.
2017-02-02 11:17:36 -08:00
Martin von Zweigbergk
f225c55b2a verify: replace _validpath() by matcher
The verifier calls out to _validpath() to check if it should verify
that path and the narrowhg extension overrides _validpath() to tell
the verifier to skip that path. In treemanifest repos, the verifier
calls the same method to check if it should visit a
directory. However, the decision to visit a directory is different
from the condition that it's a matching path, and narrowhg was working
around it by returning True from its _validpath() override if *either*
was true.

Similar to how one can do "hg files -I foo/bar/ -X foo/" (making the
include pointless), narrowhg can be configured to track the same
paths. In that case match("foo/bar/baz") would be false, but
match.visitdir("foo/bar/baz") turns out to be true, causing verify to
fail. This may seem like a bug in visitdir(), but it's explicitly
documented to be undefined for subdirectories of excluded
directories. When using treemanifests, the walk would not descend into
foo/, so verification would pass. However, when using flat manifests,
there is no recursive directory walk and the file path "foo/bar/baz"
would be passed to _validpath() without "foo/" (actually without the
slash) being passed first. As explained above, _validpath() would
return true for the file path and "hg verify" would fail.

Replacing the _validpath() method by a matcher seems like the obvious
fix. Narrowhg can then pass in its own matcher and not have to
conflate the two matching functions (for dirs and files). I think it
also makes the code clearer.
2017-01-23 10:48:55 -08:00
Martin von Zweigbergk
35aa8c2fe5 rebase: fix code comment to refer to right issue (4504, not 4505)
The comment was introduced in 0a14c8556910 (rebase: ensure rebase
revision remains visible (issue4504), 2015-01-27), which mentions the
right issue in the description.
2017-02-01 08:47:27 -08:00
Kevin Bullock
6e8b8470cf Added signature for changeset 54d689c5e2bd 2017-02-01 10:19:49 -06:00
Kevin Bullock
6e8af72bda merge with i18n 2017-02-01 10:15:10 -06:00
Wagner Bruna
7bddc427a8 i18n-pt_BR: synchronized with 9495fca182d9 2017-02-01 08:47:11 -02:00
Mads Kiilerich
6945cf0f5b merge: more safe detection of criss cross merge conflict between dm and r
0b5f1f2efc77 introduced handling of a crash in this case. A review comment
suggested that it was not entirely obvious that a 'dm' always would have a 'r'
for the source file.

To mitigate that risk, make the code more conservative and make less
assumptions.
2017-02-01 02:10:30 +01:00
Augie Fackler
4b376468c2 tests: correct (I think) command in test-largefiles-update
When this test was introduced, it used the short-form of all the flags
on this update invocation. I suspect, based on the "start with clean
dirstates" comment and the fact that the no-exec branch of the #if
guard leaves dirstate clean, that this should have been 'update -qCr'
instead of 'update -qcr', but that a bug in largefiles --check
handling left this problem unnoticed.

I'll leave a breadcrumb further up about the current failure mode in
the hopes that we can fix this some day.

This was previously discussed in [0] but the trail in that thread goes
cold after a few replies. Given that this is still a flaky test, that
appears to only be passing by bad fortune, I think it's worth
correcting the code of the test to make a correct assertion, and to
keep track of the suspected bug with some other mechanism than an
invalid test (if we had support for "expected failure" blocks this
might be a worthwhile use of them?).

0: https://www.mercurial-scm.org/pipermail/mercurial-devel/2016-October/089501.html
2017-01-30 18:03:17 -05:00
Augie Fackler
a2d475a89c tests: expand flags to long form in test-largefiles-update.t
I spent some time confused by this test. I'm pretty sure that this
line intends to be cleaning the dirstate, not checking that it's clean
before updating: the preceding #if block leaves the dirstate clean in
the noexec case, and dirty in the exec case, so we can't expect
consistent behavior across that platform variation. A subsequent patch
will modify this command to use --clean instead of --check.

I'll elaborate in that patch about the hypothetical bug here.
2017-01-30 17:57:21 -05:00
Mads Kiilerich
120b66d101 merge: fix crash on criss cross merge with dir move and delete (issue5020)
Work around that 'dm' in the data model only can have one operation for the
target file, but still can have multiple and conflicting operations on the
source file where the other operation is a 'rm'. The move would thus fail with
'abort: No such file or directory'.

In this case it is "obvious" that the file should be removed, either before or
after moving it. We thus keep the 'rm' of the source file but drop the 'dm'.

This is not a pretty fix but quite "obviously" safe (famous last words...) as
it only touches a rare code path that used to crash. It is possible that it
would be better to swap the files for 'dm' as suggested on
https://bz.mercurial-scm.org/show_bug.cgi?id=5020#c13 but it is not entirely
obvious that it not just would create conflicts on the other file. That can be
revisited later.
2017-01-31 03:25:59 +01:00
Mads Kiilerich
c69f200750 tests: use 'f' in test-merge-criss-cross.t to prepare for recursive dumping
Prepare for adding a test case with files in a directory.
2017-01-31 03:20:07 +01:00
Martin von Zweigbergk
06f115a93e util: make sortdict.keys() return a copy
dict.keys() is documented to return a copy, so it's surprising that
sortdict.keys() did not. I noticed this because we have an extension
that calls readlocaltags(). That method tries to remove any tags that
point to non-existent revisions (most likely stripped). However, since
it's unintentionally working on the instance it's modifying, it
sometimes fails to remove tags when there are multiple bad tags in a
row. This was not caught because localrepo.tags() does an additional
layer of filtering.

sortdict is also used in other places, but I have not checked whether
its keys() and/or __delitem__() methods are used there.
2017-01-30 22:58:56 -08:00
Yuya Nishihara
8d8a7da758 test-highlight: add normalization rule for Pygments 2.2
The test failed on Debian sid because of new class="vm".
2017-01-30 22:50:20 +09:00
Danek Duvall
058972ca52 tests: account for different newline behavior between Solaris and GNU grep
GNU grep, when emitting a matching line that doesn't have a terminating
newline, will add an extra newline.  Solaris grep passes the original line
through without the newline.  This causes differences in test output when
looking at the last line of the output of get-with-headers.py, which
doesn't usually emit (and certainly doesn't guarantee) a terminating
newline.

Both grep implementations succeed in matching the requested pattern,
though, so rely on specifying the full pattern on grep's commandline
instead of expecting it in the output, and send the output to /dev/null.
2017-01-29 12:40:56 -08:00
Augie Fackler
bd1329004e tests: also allow "Protocol not supported" in test-http-proxy error
I've seen this in a (misconfigured) FreeBSD jail which has ::1 as an
entry for localhost, but IPv6 support is disabled in the jail. It took
me months to figure out what was going on (and I only figured it out
when tinyproxy.py got confused by similar IPv4-level misconfiguration
of the localhost domain in /etc/hosts.)

I don't feel strongly about this patch: on the one hand, it's papering
over a host-level misconfiguration, but on the other it avoids some
weird and hard to diagnose problems that can occur in weirdly
restricted environments.
2017-01-20 10:17:34 -05:00
Yuya Nishihara
74023f2b13 revset: prevent using outgoing() and remote() in hgweb session (BC)
outgoing() and remote() may stall for long due to network I/O, which seems
unsafe per definition, "whether a predicate is safe for DoS attack." But I'm
not 100% sure about this. If our concern isn't elapsed time but CPU resource,
these predicates are considered safe. Perhaps that would be up to the
web/application server configuration?

Anyway, outgoing() and remote() wouldn't be useful in hgweb, so I think
it's okay to ban them.
2017-01-20 21:33:18 +09:00
Augie Fackler
e144629692 tests: use an absolute path to get around '..' being invalid on a dead CWD
Only FreeBSD seems to be this picky. Note that this explicit
absolute-path `cd` exposes a defect in the test, in that we end up
still inside the cwd-vanish repository, but that's not a regression in
this change. Since we're in a code freeze, I'm doing the smallest
thing possible to try and fix bugs on FreeBSD, rather than cleaning up
the entire problem. I'll follow up with a more complete fix after the
freeze.
2017-01-19 16:23:49 -05:00
Sean Farley
e145fc2df7 ui: rename tmpdir parameter to more specific repopath
This was requested by Augie and I agree that repopath is more
descriptive.
2017-01-18 18:25:51 -08:00
Yuya Nishihara
9979640f1d pager: wrap _runcommand() no matter if stdout is redirected
We've made chg utilize the common code path implemented in pager.py (by
e8fb65f5e551 and e97133c7a9dc), but the chg server does not always start
with a tty. Because of this, uisetup() of the pager extension could be
skipped on the chg server.

Kudos given to Sean Farley for dogfooding new chg and spotting this problem.
2017-01-19 23:01:32 +09:00
Kostia Balytskyi
bc104f588e shelve: make unshelve not crash when there are missing files (issue4176)
This patch makes it possible to unshelve while having missing files
in your repo as long as shelved changes don't touch those missing files.
It also makes error message better otherwise.
2017-01-19 09:48:40 -08:00
Gregory Szorc
9c03a7696d statprof: require input file
statprof has a __main__ handler that allows viewing of previously
written data files. As Yuya pointed out during review, 82ee01726a77
broke this. This patch fixes that.
2017-01-18 22:45:07 -08:00
Augie Fackler
a0c4b1e6da tests: work around FreeBSD's unzip having slightly different output
According to man 1 unzip, this unzip appeared in FreeBSD 8.0. It's
what comes as /usr/bin/unzip, so we may as well cater to it since it's
easy.
2017-01-18 23:43:41 -05:00
Augie Fackler
cde5195cd5 contrib: fix check-commit to not reject commits from hg sign and hg tag
I'm tired of having a spurious red build every time we do a
release. Fix it once and for all.
2017-01-18 23:34:35 -05:00
Augie Fackler
f5af5e9bba Added signature for changeset c00c73271d0f 2017-01-18 20:03:00 -05:00
Augie Fackler
899d0275a8 tests: fix up some http tests for no-zstd case 2017-01-18 11:54:51 -05:00
Sean Farley
934f476aec patchbomb: add tmpdir parameter to ui.edit call 2017-01-16 21:17:39 -08:00
Sean Farley
df48d2115f histedit: add tmpdir parameter to ui.edit call 2017-01-16 21:15:57 -08:00
Sean Farley
a405503f7a cmdutil: add tmpdir parament to ui.edit calls 2017-01-16 21:15:21 -08:00
Sean Farley
9280f19af2 ui: add a parameter to set the temporary directory for edit
Until callsites are updated, this will have no effect. Once callsites
are updated, specifying experimental.editortmpinhg will create editor
temporary files in a subdirectory of .hg, which will make it easier
for tool integrations to determine what repository is in play when
they're asked to edit an hg-related file.
2017-01-16 21:05:22 -08:00
Pulkit Goyal
f38d10e539 help: update help for hg update which was misleading (issue5427) 2017-01-18 03:44:19 +05:30
Matt Harbison
511b164fad templater: add '{envvars}' to access environment variables
Since the option for ui.exportableenviron is experimental, so is this template
until the underlying API is sorted out.
2017-01-17 23:12:54 -05:00