Gregory Szorc <gregory.szorc@gmail.com> [Sat, 10 Mar 2018 10:20:51 -0800] rev 36814
hgweb: parse WSGI request into a data structure
Currently, our WSGI applications (hgweb_mod and hgwebdir_mod) process
the raw WSGI request instance themselves. This means they have to
talk in terms of system strings. And they need to know details
about what's in the WSGI request. And in the case of hgweb_mod, it
is doing some very funky things with URL parsing to impact
dispatching. The code is difficult to read and maintain.
This commit introduces parsing of the WSGI request into a higher-level
and easier-to-reason-about data structure.
To prove it works, we hook it up to hgweb_mod and use it for populating
the relative URL on the request instance.
We hold off on using it in more places because the logic in hgweb_mod
is crazy and I don't want to involve those changes with review of
the parsing code.
The URL construction code has variations that use the HTTP: Host header
(the canonical WSGI way of reconstructing the URL) and with the use
of SERVER_NAME. We need to differentiate because hgweb is currently
using SERVER_NAME for URL construction.
Differential Revision: https://phab.mercurial-scm.org/D2734
Gregory Szorc <gregory.szorc@gmail.com> [Thu, 08 Mar 2018 15:14:32 -0800] rev 36813
hgweb: always use "?" when writing session vars
This code resolves a string to insert in URLs as part of a
query string. Essentially, it resolves the {sessionvars}
template keyword, which is used by hgweb templates to build
a URL as a string.
The whole approach here feels wrong because there's no way of
knowing when this code runs how the final URL will look. There
could be additional URL fragments added before this template
keyword that add a query string component.
Furthermore, I don't think there's *any* for req.url to have
a query string. That's because the code that populates this
variable only takes SCRIPT_NAME and REPO_NAME into account. The
"?" character it is searching for would only be added if some
code attempted to add QUERY_STRING to the URL. Hacking the code
up to raise if "?" is present in the URL yields a clean test
suite run. I'm not sure if we broke this code or if it has
always been broken.
Anyway, this commit removes support for emitting "&" as the
first character in {sessionvars} and makes it always emit "?",
which is what it was always doing before AFAICT.
Differential Revision: https://phab.mercurial-scm.org/D2733
Gregory Szorc <gregory.szorc@gmail.com> [Thu, 08 Mar 2018 15:15:59 -0800] rev 36812
hgweb: rename req to wsgireq
We will soon introduce a parsed WSGI request object so we don't
have to concern ourselves with low-level WSGI matters. Prepare
for multiple request objects by renaming the existing one so it
is clear it deals with WSGI.
We also remove a symbol import to avoid even more naming confusion.
# no-check-commit because of some new foo_bar naming that's required
Differential Revision: https://phab.mercurial-scm.org/D2732
Gregory Szorc <gregory.szorc@gmail.com> [Thu, 08 Mar 2018 09:44:27 -0800] rev 36811
hgweb: validate WSGI environment dict
The wsgiref.validate module contains useful functions for validating
that various WSGI data structures are proper.
This commit adds validation of the environment dict to our built-in
HTTP server, which turns an HTTP request into an environment dict.
The check discovered that we weren't always setting QUERY_STRING,
which would cause the cgi module to fall back to sys.argv. So we
change things to always set QUERY_STRING.
The check passes on Python 2 and 3.
Differential Revision: https://phab.mercurial-scm.org/D2731
Gregory Szorc <gregory.szorc@gmail.com> [Thu, 08 Mar 2018 09:26:51 -0800] rev 36810
hgweb: ensure all wsgi environment values are str
Previously, we had a few entries that were bytes on Python 3.
PEP-0333 states that all entries must be the native str type
(bytes on Python 2, str on Python 3).
This required a number of changes to hgweb_mod to unbreak
things on Python 3. I suspect there still may be some regressions.
I'm going to introduce a data structure that represents a parsed
WSGI request in upcoming commits. This will hold bytes and will
allow us to stop using raw literals throughout the WSGI code.
Differential Revision: https://phab.mercurial-scm.org/D2730
Gregory Szorc <gregory.szorc@gmail.com> [Wed, 07 Mar 2018 16:18:52 -0800] rev 36809
wireproto: formalize permissions checking as part of protocol interface
Per the inline comment desiring to formalize permissions checking
in the protocol interface, we do that.
I'm not convinced this is the best way to go about things. I would love
for there to e.g. be a better exception for denoting permissions
problems. But it does feel strictly better than snipping attributes
on the proto instance.
Differential Revision: https://phab.mercurial-scm.org/D2719
Gregory Szorc <gregory.szorc@gmail.com> [Wed, 07 Mar 2018 16:02:24 -0800] rev 36808
wireproto: declare permissions requirements in @wireprotocommand (API)
With the security patches from 4.5.2 merged into default, we now
have a per-command attribute defining what permissions are needed
to run that command. We now have a richer @wireprotocommand that
can be extended to record additional command metadata. So we
port the permissions mechanism to be based on @wireprotocommand.
.. api::
hgweb_mod.perms and wireproto.permissions have been removed. Wire
protocol commands should declare their required permissions in the
@wireprotocommand decorator.
Differential Revision: https://phab.mercurial-scm.org/D2718
Gregory Szorc <gregory.szorc@gmail.com> [Tue, 06 Mar 2018 15:08:33 -0800] rev 36807
wireprotoserver: check permissions in main dispatch function
The permissions checking code merged from stable is out of place
in the refactored hgweb_mod module.
This commit moves the main call to wireprotoserver. We still have
some lingering code in hgweb_mod. This will get addressed later.
Differential Revision: https://phab.mercurial-scm.org/D2717
Gregory Szorc <gregory.szorc@gmail.com> [Tue, 06 Mar 2018 15:02:53 -0800] rev 36806
wireprotoserver: check if command available before calling it
The previous behavior was just plain wrong. I have no clue how it
landed. My guess is a merge conflict resolution gone wrong on my
end a few weeks ago.
Differential Revision: https://phab.mercurial-scm.org/D2716
Yuya Nishihara <yuya@tcha.org> [Tue, 06 Mar 2018 02:43:17 -0600] rev 36805
py3: drop encoding.strio()
Its buffered nature makes TextIOWrapper unsuitable for temporarily wrapping
bytes I/O.
Yuya Nishihara <yuya@tcha.org> [Tue, 06 Mar 2018 02:42:37 -0600] rev 36804
ui: adjust Windows workaround to new _readline() code
It's only needed when rawinput() is called. Also made it Py3 compatible.
Yuya Nishihara <yuya@tcha.org> [Tue, 06 Mar 2018 02:38:53 -0600] rev 36803
ui: do not use rawinput() when we have to replace sys.stdin/stdout
See the inline comment for why. The current Python3 hack doesn't work if
more than one user inputs are expected because TextIOWrapper fills its
internal buffer at the first read() request.
Maybe we could write an unbuffered TextIOWrapper, but I don't want to make
things more complicated. Instead, this patch reinvents raw_input(' ') of
no readline support.
Yuya Nishihara <yuya@tcha.org> [Tue, 06 Mar 2018 02:32:26 -0600] rev 36802
ui: do not try readline support if fin/fout aren't standard streams
It's unlikely for a non-stdio stream to be a tty. Minimizing readline support
makes it much simpler to work around the unicode input() function of Python 3.
This also works on chg which duplicates client's tty to stdio fds.
Yuya Nishihara <yuya@tcha.org> [Tue, 06 Mar 2018 02:28:59 -0600] rev 36801
util: add public isstdin/isstdout() functions
Yuya Nishihara <yuya@tcha.org> [Tue, 06 Mar 2018 03:05:49 -0600] rev 36800
ui: add debug commands to test interactive prompt
Interactive operations aren't easily covered by tests. So let's add commands
to test them manually.
Yuya Nishihara <yuya@tcha.org> [Tue, 06 Mar 2018 02:14:11 -0600] rev 36799
ui: inline util.bytesinput() into ui._readline()
Prepares for rework of Python 3 support, which is currently broken due to
read-ahead buffer of TextIOWrapper.
Yuya Nishihara <yuya@tcha.org> [Tue, 06 Mar 2018 02:05:25 -0600] rev 36798
hgk: stop using util.bytesinput() to read a single line from stdin
Appears that the stdio here is an IPC channel between hg and hgk (tk)
processes, which shouldn't need a fancy readline support.
Augie Fackler <augie@google.com> [Mon, 29 Aug 2016 10:42:58 -0400] rev 36797
bookmarks: test for exchanging long bookmark names (issue5165)
As far as I can tell a test for a long bookmark name never actually
got added when this was fixed. Let's document that a 300 byte bookmark
is something we're supporting (this patch started out life over a year
ago as a way for me to validate the problem, and I recently found it.)
I think the nonzero exits from the push operations are only because no
new changesets get exchanged. Please correct me if I'm wrong on that. :)
Differential Revision: https://phab.mercurial-scm.org/D2727
Augie Fackler <augie@google.com> [Sun, 04 Mar 2018 11:46:03 -0500] rev 36796
phabricator: follow-up phab auth improvements with backwards compat mode
We'll rip this out before we ship 4.6, but this gives people a window
to migrate.
Differential Revision: https://phab.mercurial-scm.org/D2703
Tom Prince <mozilla@hocat.ca> [Sat, 20 Jan 2018 02:41:10 -0700] rev 36795
phabricator: specify API tokens per host, rather than per repo
Differential Revision: https://phab.mercurial-scm.org/D1919
Yuya Nishihara <yuya@tcha.org> [Sun, 04 Mar 2018 18:47:07 -0500] rev 36794
py3: drop b'' from generate-working-copy-states.py output
I could make everything bytes, but decoding filename seemed easier and we
don't have to worry about non-ascii filenames here.
Yuya Nishihara <yuya@tcha.org> [Sun, 04 Mar 2018 18:41:09 -0500] rev 36793
py3: make test-commit-multiple.t byte-safe
Yuya Nishihara <yuya@tcha.org> [Sun, 04 Mar 2018 18:34:46 -0500] rev 36792
py3: fix type of default username
Yuya Nishihara <yuya@tcha.org> [Sun, 04 Mar 2018 18:21:16 -0500] rev 36791
py3: read/write plain lock file in binary mode
A lock file shouldn't contain '\n', so this isn't a BC.
Augie Fackler <augie@google.com> [Mon, 05 Mar 2018 12:31:08 -0500] rev 36790
util: stop calling os.stat_float_times()
It had Python-wide side effects, and it disappears in 3.7.0.
As of this change, we're mostly working on 3.7.0b2. There are a few
worrying failures, mostly around regular expressions, but we'll have
to tackle those separately.
Differential Revision: https://phab.mercurial-scm.org/D2697
Augie Fackler <augie@google.com> [Mon, 05 Mar 2018 12:30:20 -0500] rev 36789
cleanup: use stat_result[stat.ST_MTIME] instead of stat_result.st_mtime
The latter is floating point by default, and we've been doing
os.stat_float_times(False). Unfortunately, os.stat_float_times was
removed between Python 3.7.0a1 and 3.7.0b2, so we have to stop using
it.
Differential Revision: https://phab.mercurial-scm.org/D2696
Augie Fackler <augie@google.com> [Mon, 05 Mar 2018 15:07:32 -0500] rev 36788
osutil: implement minimal __getitem__ compatibility on our custom listdir type
We previously declined to do this, but the removal of the deprecated
os.stat_float_times() method in Python 3.7 forces our hand.
Differential Revision: https://phab.mercurial-scm.org/D2695
Augie Fackler <augie@google.com> [Sun, 04 Mar 2018 21:14:24 -0500] rev 36787
hgweb: adapt to socket._fileobject changes in Python 3
Differential Revision: https://phab.mercurial-scm.org/D2688
Augie Fackler <augie@google.com> [Sun, 04 Mar 2018 16:20:24 -0500] rev 36786
debugcommands: fix some %r output with bytestr() wrappers
Almost fixes test-merge-tools.t. I think the remaining failure there
is due to some overspecified tempfile names.
Differential Revision: https://phab.mercurial-scm.org/D2675
Martin von Zweigbergk <martinvonz@google.com> [Wed, 07 Mar 2018 11:00:17 -0800] rev 36785
tests: add test for issue 5494 but with --collapse
This was not fixed, so the test case currently demonstrates the
breakage.
Differential Revision: https://phab.mercurial-scm.org/D2714
Martin von Zweigbergk <martinvonz@google.com> [Wed, 07 Mar 2018 10:55:57 -0800] rev 36784
tests: .hg/merge is a directory, so use `test -d`
This part of test-rebase-interrupts.t would have passed before the fix
in a580b2d65ded (rebase: make sure merge state is cleaned up for no-op
rebases (issue5494), 2017-05-18).
Differential Revision: https://phab.mercurial-scm.org/D2713
Martin von Zweigbergk <martinvonz@google.com> [Tue, 06 Mar 2018 14:29:20 -0800] rev 36783
rebase: only store collapse message once
The message is determined by the user passing --message or --log when
the rebase is started. There's no need to write it to a file for each
rebased commit; writing it once at the start of the rebase is enough.
Differential Revision: https://phab.mercurial-scm.org/D2712
Martin von Zweigbergk <martinvonz@google.com> [Tue, 06 Mar 2018 09:39:24 -0800] rev 36782
rebase: collapse two nested if-conditions
Also change the order since it feel to me like it's more about
--collapse than it is about --keep.
Differential Revision: https://phab.mercurial-scm.org/D2711
Martin von Zweigbergk <martinvonz@google.com> [Thu, 01 Mar 2018 20:12:25 -0800] rev 36781
rebase: reduce scope of "dsguard" variables a bit
Differential Revision: https://phab.mercurial-scm.org/D2710
Martin von Zweigbergk <martinvonz@google.com> [Wed, 07 Mar 2018 09:46:53 -0800] rev 36780
rebase: remove unused argument "state" from rebasenode()
Differential Revision: https://phab.mercurial-scm.org/D2709
Martin von Zweigbergk <martinvonz@google.com> [Wed, 07 Mar 2018 10:31:01 -0800] rev 36779
rebase: delete obsolete internal "keepopen" option
The option was apparently introduced for use by the "pbranch"
extension, see f2558a8228be (rebase: add option to not commit after a
collapsing, 2010-02-07). However, it doesn't seem like it was ever
used by that extension (according to `hg grep` in a clone of
https://bitbucket.org/parren/hg-pbranch/), so let's delete it.
Differential Revision: https://phab.mercurial-scm.org/D2708
Rishabh Madan <rishabhmadan96@gmail.com> [Sun, 04 Mar 2018 00:25:58 +0530] rev 36778
releasenotes: allow notes for multiple directives in a single changeset
This problem was caught in da91e7309daf8ffc51bf3e6f4b2d8a16ef5af95a. This patch just makes sure there is no warning when we
encounter such a case.
Differential Revision: https://phab.mercurial-scm.org/D2254
Rishabh Madan <rishabhmadan96@gmail.com> [Sun, 04 Mar 2018 00:15:35 +0530] rev 36777
releasenotes: mention changeset with warning and abort
Output the changeset hash with the warning/abort message just to know where things messed up.
Differential Revision: https://phab.mercurial-scm.org/D2253
Rishabh Madan <rishabhmadan96@gmail.com> [Sat, 03 Mar 2018 23:47:22 +0530] rev 36776
releasenotes: replace abort with warning while parsing (issue5775)
During the 4.5 development cycle, the extension broke on two different changesets.
This fixes the issue by ensuring that it just throws a warning when it encounters
unexpected behaviour, instead of aborting.
Differential Revision: https://phab.mercurial-scm.org/D2255
Vincent Parrett <vincent@finalbuilder.com> [Wed, 07 Mar 2018 09:07:34 +1100] rev 36775
archival: fileit should not use atomictemp, causes performance regression
Differential Revision: https://phab.mercurial-scm.org/D2704
Gregory Szorc <gregory.szorc@gmail.com> [Sat, 03 Mar 2018 18:55:43 -0500] rev 36774
perf: teach perfbdiff to call blocks() and to use xdiff
Differential Revision: https://phab.mercurial-scm.org/D2624
Jun Wu <quark@fb.com> [Tue, 06 Mar 2018 19:31:17 -0800] rev 36773
fuzz: fix xdiff build
Recent xdiff code cleanups removed some files and changed some structures.
Update fuzz code.
Differential Revision: https://phab.mercurial-scm.org/D2707
Jun Wu <quark@fb.com> [Tue, 06 Mar 2018 18:51:11 -0800] rev 36772
xdiff: remove xmerge related logic
hg has its own merge algorithm with flexible config options.
Differential Revision: https://phab.mercurial-scm.org/D2706
Jun Wu <quark@fb.com> [Tue, 06 Mar 2018 18:41:08 -0800] rev 36771
xdiff: remove xemit related logic
xemit handles "diff formatting and output" with options like context lines,
whether show function names, etc. That is handled more cleanly at a higher
level in hg.
Removing context line parameters would also make the trimming logic (D2686)
cleaner and more confident. See [1].
[1]: https://github.com/git/git/commit/d2f82950a9226ae1102a7a97f03440a4bf8c6c09
Differential Revision: https://phab.mercurial-scm.org/D2705
Jun Wu <quark@fb.com> [Sun, 04 Mar 2018 00:17:49 -0800] rev 36770
xdiff: remove unused structure, functions, and constants
`bdiffparam_t` is unused. `xdl_fall_back_diff` is no longer used after
D2573. `XDL_MMB_READONLY`, `XDL_MMF_ATOMIC` are unused. `XDL_BDOP*` are
unused since there is no xdiff binary diff algorithm. `anchors` feature is
not used. It's also relatively new in git.
Differential Revision: https://phab.mercurial-scm.org/D2684
Jun Wu <quark@fb.com> [Sun, 04 Mar 2018 00:07:04 -0800] rev 36769
xdiff: remove whitespace related feature
In Mercurial, whitespace related handling are done at a higher level than
the low-level diff algorithm so "ignore spaces". So it's not used by mdiff.
Some of the upcoming optimizations would be more difficult with whitespace
related features kept. So let's remove them.
Differential Revision: https://phab.mercurial-scm.org/D2683
Gregory Szorc <gregory.szorc@gmail.com> [Tue, 06 Mar 2018 14:32:14 -0800] rev 36768
merge with stable
There were a handful of merge conflicts in the wire protocol code due
to significant refactoring in default. When resolving the conflicts,
I tried to produce the minimal number of changes to make the incoming
security patches work with the new code.
I will send some follow-up commits to get the security patches better
integrated into default.
Augie Fackler <augie@google.com> [Sun, 04 Mar 2018 21:16:36 -0500] rev 36767
sslutil: some more forcebytes() on some exception messages
At this point, test-https.t no longer dumps tracebacks
everywhere. Instead, we get some results that look like we're not
adequately finding things in hg's configuration, which should be
manageable (if somewhat annoying to find and fix.)
Differential Revision: https://phab.mercurial-scm.org/D2690
Augie Fackler <augie@google.com> [Sun, 04 Mar 2018 21:15:37 -0500] rev 36766
sslutil: sslcontext needs the cipher name as a sysstr
Differential Revision: https://phab.mercurial-scm.org/D2689
Augie Fackler <augie@google.com> [Sun, 04 Mar 2018 18:03:55 -0500] rev 36765
sslutil: lots of unicode/bytes cleanup
In general, we handle hostnames as bytes, except where Python forces
them to be unicodes.
This fixes all the tracebacks I was seeing in test-https.t, but
there's still some ECONNRESET weirdness that I can't hunt down...
Differential Revision: https://phab.mercurial-scm.org/D2687
Matt Harbison <matt_harbison@yahoo.com> [Mon, 05 Mar 2018 20:22:34 -0500] rev 36764
debugwireproto: handle unimplemented util.poll() for Windows
This is the same logic used in sshpeer.doublepipe. It doesn't completely fix
test-ssh-proto{,-unbundle}.t ("read(-1) -> X" is changed to "read(X) -> X", the
order of some lines are changed, and abort messages seem to be missing), but it
cuts down a ton on the failure spew.
Yuya Nishihara <yuya@tcha.org> [Sun, 04 Mar 2018 16:55:51 -0500] rev 36763
py3: byte-stringify test-blackbox.t
Yuya Nishihara <yuya@tcha.org> [Sun, 04 Mar 2018 16:54:14 -0500] rev 36762
py3: byte-stringify blackbox-readonly-dispatch.py
# skip-blame because just adding some b''
Yuya Nishihara <yuya@tcha.org> [Sun, 04 Mar 2018 16:50:35 -0500] rev 36761
py3: make blackbox-readonly-dispatch.py use ui instead of print()
Yuya Nishihara <yuya@tcha.org> [Sun, 04 Mar 2018 16:48:17 -0500] rev 36760
py3: fix int formatting of "incoming changes" log
Augie Fackler <augie@google.com> [Sun, 04 Mar 2018 16:48:01 -0500] rev 36759
largefiles: use %d instead of %s to process ints
Differential Revision: https://phab.mercurial-scm.org/D2677
Augie Fackler <augie@google.com> [Sun, 04 Mar 2018 16:11:15 -0500] rev 36758
transaction: fix an error string with bytestr() on a repr()d value
Fixes test-rollback.t on Python 3.
Differential Revision: https://phab.mercurial-scm.org/D2674
Yuya Nishihara <yuya@tcha.org> [Sun, 04 Mar 2018 16:23:10 -0500] rev 36757
py3: work around comparison between int and None in tagmerge
Yuya Nishihara <yuya@tcha.org> [Sun, 04 Mar 2018 16:13:46 -0500] rev 36756
py3: do not mutate dict while iterating in tagmerge
Yuya Nishihara <yuya@tcha.org> [Sun, 04 Mar 2018 16:01:18 -0500] rev 36755
py3: fix type of ui.configitems(ignoresub=True) result