Commit Graph

29807 Commits

Author SHA1 Message Date
Yuya Nishihara
cbf8b420cf chgserver: switch to new forking service
Threading and complex classes are no longer necessary. _autoexitloop() has
been replaced by polling cycle in the main thread.
2016-05-22 13:36:37 +09:00
Yuya Nishihara
ad9977e54c chgserver: extract stub factory of service object
The class inheritance will be replaced by composition. See the next patch
for details.
2016-05-22 13:13:04 +09:00
Yuya Nishihara
692e073582 chgserver: reorder service classes to make future patches readable
Includes no functional change.
2016-05-22 13:08:30 +09:00
Yuya Nishihara
2857a87cb4 commandserver: add new forking server implemented without using SocketServer
SocketServer.ForkingMixIn of Python 2.x has a couple of issues, such as:

 - race condition that leads to 100% CPU usage (Python 2.6)
   https://bugs.python.org/issue21491
 - can't wait for children belonging to different process groups (Python 2.6)
 - leaves at least one zombie process (Python 2.6, 2.7)
   https://bugs.python.org/issue11109

The first two are critical because we do setpgid(0, 0) in child process to
isolate terminal signals. The last one isn't, but ForkingMixIn seems to be
doing silly. So there are two choices:

 a) backport and maintain SocketServer until we can drop support for Python 2.x
 b) replace SocketServer by simpler one and eliminate glue codes

I chose (b) because it's great time for getting rid of utterly complicated
SocketServer stuff, and preparing for future move towards prefork service.

New unixforkingservice is implemented loosely based on chg 531f8ef64be6. It
is monolithic but much simpler than SocketServer. unixservicehandler provides
customizing points for chg, and it will be shared with future prefork service.

Old unixservice class is still used by chgserver. It will be removed later.

Thanks to Jun Wu for investigating these issues.
2016-05-22 11:43:18 +09:00
Yuya Nishihara
d298dc2539 commandserver: extract function that serves for the current connection
This will be used by new server implementation.
2016-05-22 12:49:22 +09:00
Yuya Nishihara
be6319726b commandserver: manually create file objects from socket
Prepares for moving away from SocketServer. See the subsequent patches for
why.
2016-05-22 12:44:25 +09:00
Maciej Fijalkowski
04dfc79402 bdiff: split bdiff into cpy-aware and cpy-agnostic part 2016-07-13 10:46:26 +02:00
Maciej Fijalkowski
99c86205e7 bdiff: rename functions and structs to be amenable for later exporting 2016-07-13 10:07:17 +02:00
Maciej Fijalkowski
020e7f27ca bdiff: use ssize_t in favor of Py_ssize_t in cpython-unaware locations
This function and struct will be exposed via cffi, so we need to
remove the cpython API dependency they currently have.
2016-07-13 09:36:24 +02:00
Anton Shestakov
2f0cc33284 hgweb: enumerate lines in loop header, not before
Doing this will allow access to the lines in arbitrary order (because the
result of enumerate() is an iterator), and that will help calculating rowspan
for annotate blocks.
2016-07-14 12:33:44 +08:00
Gregory Szorc
9cc195a913 sslutil: add assertion to prevent accidental CA usage on Windows
Yuya suggested we add this check to ensure we don't accidentally try
to load user-writable paths on Windows if we change the control
flow of this function later.
2016-07-13 19:33:52 -07:00
Kostia Balytskyi
e27abece5f shelve: make unshelve be able to abort in any case 2016-07-13 16:16:18 +01:00
Augie Fackler
c36830f5df osx: explicitly build hg with /usr/bin/python2.7
This should help avoid creating a package that depends on a custom
Python, as happened when I built a package for 3.8.
2016-07-13 10:39:33 -04:00
Augie Fackler
ceba27d835 osx: correct comment about ordering of welcome page 2016-07-13 11:26:44 -04:00
Augie Fackler
7db40cdbbf osx: jettison outdated build instructions 2016-07-13 11:24:31 -04:00
Yuya Nishihara
53e19881da commandserver: extract _cleanup() hook to clarify chg is doing differently
This makes it clear that chg needs its own way to unlink closed socket file.
I made a mistake in draft patches without noting the difference.
2016-05-22 11:21:11 +09:00
Yuya Nishihara
278af8b465 chgserver: drop repo at chgunixservice.__init__()
Since it isn't expensive operation, we don't have to delay it to init().
2016-05-21 17:06:39 +09:00
Yuya Nishihara
9531323bdb chgserver: extract utility to bind unix domain socket to long path
This is common problem of using sockaddr_un.
2016-05-21 16:52:04 +09:00
Yuya Nishihara
e524ae5976 chgserver: narrow scope of chdir() to socket.bind()
This helps extracting a utility function.
2016-05-21 16:42:59 +09:00
Denis Laxalde
399b84e4b1 annotate: handle empty files earlier
Rather than looping on funcmap and then checking for non-zero `l`
continue if the result of fctx.annotate is empty.
2016-07-11 15:45:34 +02:00
Denis Laxalde
873ac38beb context: eliminate handling of linenumber being None in annotate
I could not find any use of this parameter value. And it arguably makes
understanding of the function more difficult. Setting the parameter default
value to False.
2016-07-11 14:44:19 +02:00
Gregory Szorc
a17406014b tests: regenerate x509 test certificates
The old x509 test certificates were using cryptographic settings
that are ancient by today's standards, namely 512 bit RSA keys.
To put things in perspective, browsers have been dropping support
for 1024 bit RSA keys.

I think it is important that tests match the realities of the times.
And 2048 bit RSA keys with SHA-2 hashing are what the world is
moving to.

This patch replaces all the x509 certificates with new versions using
modern best practices. In addition, the docs for generating the
keys have been updated, as the existing docs left out a few steps,
namely how to generate certs that were not active yet or expired.
2016-07-12 22:26:04 -07:00
Denis Laxalde
349c6778aa hgweb: add a link on node id in annotate hover-box
The link pointing the annotate view at this revision, just like the one in the
left-column but accessible from anywhere.
2016-07-12 15:09:07 +02:00
Denis Laxalde
0986e60532 hgweb: move author information from left-column to hover-box in annotate view
And display the full author information since there is enough space there.
2016-07-12 15:07:37 +02:00
Denis Laxalde
81b6a5375a hgweb: add links to diff and changeset in hover-box on annotate view 2016-06-14 11:01:30 +02:00
Denis Laxalde
07a35f6357 hgweb: add link to parents of annotated revision in annotate view
The link is embedded into a div with class="annotate-info" that only shows up
upon hover of the annotate column. To avoid duplicate hover-overs (this new
one and the one coming from link's title), drop "title" attribute from a
element and put it in the annotate-info element.
2016-06-28 11:42:42 +02:00
Maciej Fijalkowski
99f034fe89 compat: provide a declaration of ssize_t, for MS windows 2016-07-11 13:53:35 +02:00
Augie Fackler
917aac8fd9 check-code: enforce (glob) on output lines containing 127.0.0.1 2016-07-09 23:04:03 -04:00
Augie Fackler
a746cac8cc tests: add (glob) annotations to output lines with 127.0.0.1 2016-07-09 23:03:45 -04:00
Augie Fackler
2356a5286e run-tests: add support for using 127.0.0.1 as a glob
Some systems don't have a 127/8 address for localhost (I noticed this
on a FreeBSD jail). In order to work around this, use 127.0.0.1 as a
glob pattern. A future commit will update needed output lines and add
a requirement to check-code.py.
2016-07-09 23:01:02 -04:00
Augie Fackler
2bd6c4334d check-code: only treat a # as a line in a t-test if it has a space before it
Prior to this, check-code wouldn't notice things like (glob)
annotations or similar in a test if they were after a # anywhere in
the line. This resolves a defect in a future change, and also exposed
a couple of small spots that needed some attention.
2016-07-12 15:34:17 -04:00
Augie Fackler
a03c51a052 test-export: be more aggressive about quoting ^
An upcoming change to check-code will notice this isn't quoted
enough. Presumably it's been fine by luck all this time.
2016-07-12 15:41:38 -04:00
Augie Fackler
f5ff8e7bc2 test-check-shbang: work around check-code not wanting hardcoded paths
I'm about to fix a bug in check-code that a # anywhere on a line
treated the rest of the line as a comment, even if it was
meaningful. This test is the one place we explicitly *do* want
hardcoded paths referenced, but we can work around that by specifying
bin as a regular expression.
2016-07-12 15:32:24 -04:00
Augie Fackler
6e00945221 tests: relax "Connection refused" match
We already had the match relaxed on Windows, but on Google Compute
Engine VMs I'm seeing "Network is unreachable" instead of "Connection
refused". At this point, just give up and make sure we get an error back.
2016-07-12 11:20:30 -04:00
Yuya Nishihara
bfbe03d5c2 commandserver: backport handling of forking server from chgserver
This is common between chg and vanilla forking server, so move it to
commandserver and unify handle().

It would be debatable whether we really need gc.collect() or not, but that
is beyond the scope of this series. Maybe we can remove gc.collect() once
all resource deallocations are switched to context manager.
2016-05-21 15:23:21 +09:00
Yuya Nishihara
b7be4fa70f commandserver: promote .cleanup() hook from chgserver
This allows us to unify _requesthandler.handle().
2016-05-21 15:18:23 +09:00
Yuya Nishihara
3f1513d0b9 commandserver: extract method to create commandserver instance per request
This is a step toward merging chgserver._requesthandler with commandserver's.
2016-05-21 15:12:19 +09:00
Yuya Nishihara
2e776c55f7 error: make hintable exceptions reject unknown keyword arguments (API)
Previously they would accept any typos of the hint keyword.
2016-07-11 21:40:02 +09:00
Yuya Nishihara
348d73cc98 error: make HintException a mix-in class not derived from BaseException (API)
HintException is unrelated to the hierarchy of errors. It is an implementation
detail whether a class inherits from HintException or not, a sort of "private
inheritance" in C++.

New Hint isn't an exception class, which prevents catching error by its type:

    try:
        dosomething()
    except error.Hint:
        pass

Unfortunately, this passes on PyPy 5.3.1, but not on Python 2, and raises more
detailed TypeError on Python 3.
2016-07-09 14:28:30 +09:00
Gregory Szorc
8417644a05 sslutil: move context options flags to _hostsettings
Again, moving configuration determination to a single location.
2016-07-06 22:53:22 -07:00
Gregory Szorc
8d840bafa6 sslutil: move protocol determination to _hostsettings
Most of the logic for configuring TLS is now in this function.
Let's move protocol determination code there as well.
2016-07-06 22:47:24 -07:00
Durham Goode
3d4a2a798a share: don't recreate the source repo each time
Previously, every time you asked for the source repo of a shared working copy it
would recreate the repo object, which required calling reposetup. With certain
extension enabled, this can be quite expensive, and it can happen many times
(for instance, share attaches a post transaction hook to update bookmarks that
triggers this).

The fix is to just cache the repo object instead of constantly recreating it.
2016-07-11 13:40:02 -07:00
Maciej Fijalkowski
b3d62e8a18 setup: prepare for future cffi modules by adding placeholder in setup 2016-07-11 10:44:18 +02:00
Martijn Pieters
70f47c8885 journal: add support for seaching by pattern
If a pattern is used, include the entry name in the output, to make it clear
what name was matched.
2016-07-08 16:48:38 +01:00
Martijn Pieters
a0e514f821 journal: add share extension support
Rather than put everything into one journal file, split entries up in *shared*
and *local* entries. Working copy changes are local to a specific working copy,
so should remain local only. Other entries are shared with the source if so
configured when the share was created.

When unsharing, any shared journale entries are copied across.
2016-07-11 14:45:41 +01:00
Martijn Pieters
c699263458 journal: add dirstate tracking
Note that now the default action for `hg journal` is to list the working copy
history, not all bookmarks. In its place is the `--all` switch which lists all
name changes recorded, including the name for which the change was recorded on
each line.

Locking is switched to using a dedicated lock to avoid issues with the dirstate
being written during wlock unlocking (you can't re-lock during that process).
2016-07-11 13:39:24 +01:00
Matt Mackall
242c882fcb merge with stable 2016-07-11 08:54:13 -05:00
Gregory Szorc
0786299e33 sslutil: try to find CA certficates in well-known locations
Many Linux distros and other Nixen have CA certificates in well-defined
locations. Rather than potentially fail to load any CA certificates at
all (which will always result in a certificate verification failure),
we scan for paths to known CA certificate files and load one if seen.
Because a proper Mercurial install will have the path to the CA
certificate file defined at install time, we print a warning that
the install isn't proper and provide a URL with instructions to
correct things.

We only perform path-based fallback on Pythons that don't know
how to call into OpenSSL to load the default verify locations. This
is because we trust that Python/OpenSSL is properly configured
and knows better than Mercurial. So this new code effectively only
runs on Python <2.7.9 (technically Pythons without the modern ssl
module).
2016-07-06 21:16:00 -07:00
Gregory Szorc
0ede6720a7 sslutil: issue warning when unable to load certificates on OS X
Previously, failure to load system certificates on OS X would lead
to a certificate verify failure and that's it. We now print a warning
message with a URL that will contain information on how to configure
certificates on OS X.

As the inline comment states, there is room to improve here. I think
we could try harder to detect Homebrew and MacPorts installed
certificate files, for example. It's worth noting that Homebrew's
openssl package uses `security find-certificate -a -p` during package
installation to export the system keychain root CAs to
etc/openssl/cert.pem. This is something we could consider adding
to setup.py. We could also encourage packagers to do this. For now,
I'd just like to get this warning (which matches Windows behavior)
landed. We should have time to improve things before release.
2016-07-06 20:46:05 -07:00
Gregory Szorc
4e0e490a01 sslutil: don't access message attribute in exception (issue5285)
I should have ran the entire test suite on Python 2.6. Since the
hostname matching tests are implemented in Python (not .t tests),
it didn't uncover this warning. I'm not sure why - warnings should
be printed regardless. This is possibly a bug in the test runner.
But that's for another day...
2016-07-02 09:41:40 -07:00