Yuya Nishihara <yuya@tcha.org> [Sun, 11 Mar 2018 21:05:29 +0900] rev 36985
templater: convert resources to a table of callables for future extension
I'm going to add a full templating support to the annotate command. As the
annotate is a filectx-oriented command, we'll need a way to look up a ctx
from a bounded fctx only when necessary.
This is the minimal change to support that. I'm thinking of defining a proper
interface to look up template resources to fix other issues, but that isn't
ready yet.
(Changes from V1: just updated tests and patch descriptions.)
Augie Fackler <augie@google.com> [Sat, 17 Mar 2018 21:46:17 -0400] rev 36984
merge with stable
Gregory Szorc <gregory.szorc@gmail.com> [Fri, 16 Mar 2018 12:10:15 -0700] rev 36983
hgweb: convert an assert to a ProgrammingError
Because assert may get optimized away.
Differential Revision: https://phab.mercurial-scm.org/D2882
Kyle Lippincott <spectral@google.com> [Fri, 19 Jan 2018 18:52:50 -0800] rev 36982
filemerge: give some variables in _xmerge more descriptive names
Differential Revision: https://phab.mercurial-scm.org/D2886
Martin von Zweigbergk <martinvonz@google.com> [Thu, 15 Mar 2018 13:19:55 -0700] rev 36981
rebase: allow in-memory merge of the working copy parent
Before this patch and when the rebase involved the working copy parent
(and thus the working copy too), we would not do in-memory rebase even
if requested to. The in-code comment explains that the reason had
something to do with avoiding an extra update, but I don't know which
update that refers to. Perhaps an earlier version of the code used to
update to the destination before rebasing even if in-memory rebase was
requested? That seems to not be done at least since aa660c1203a9
(rebase: do not bail on uncomitted changes if rebasing in-memory,
2017-12-07).
To see if this still made it slower, I create a single tiny commit on
top of one branch of the mozilla-unified repo (commit a1098c82 to be
exact) and rebased it to another branch (commit d4e9a7be). Before this
patch that took 11.8s and after this patch it took 8.6s (I only did
two runs each, but the timings were very consistent).
Differential Revision: https://phab.mercurial-scm.org/D2876
Martin von Zweigbergk <martinvonz@google.com> [Sat, 17 Mar 2018 09:33:17 -0700] rev 36980
uncommit: simplify condition for keeping commit
We used to keep the commit if it would have become empty and --keep
was not passed. Since we just changed it so we also keep it if any
patterns were passed on the command line, the only remaining case
where we prune the commit is when no arguments were passed and --keep
was not passed either, we can simplify the "not files and not
allowempty" to just "not allowempty". Let's also rename "allowempty"
to "keepcommit" since it's no longer about allowing an empty commit.
Differential Revision: https://phab.mercurial-scm.org/D2891
Martin von Zweigbergk <martinvonz@google.com> [Sat, 17 Mar 2018 09:49:21 -0700] rev 36979
uncommit: document when the commit will be pruned
Differential Revision: https://phab.mercurial-scm.org/D2890
Martin von Zweigbergk <martinvonz@google.com> [Wed, 14 Mar 2018 11:16:49 -0700] rev 36978
uncommit: leave empty commit if all files are uncommitted
We had instructions for our internal users to add copy information
after commit like this:
hg uncommit <srcfile> <dstfile>
hg cp --after <srcfile> <dstfile>
hg amend
That usually works, but if the rename was the only change in that
commit, then the commit would get pruned. It's easy to fix the recipe:
just pass the --keep option. However, it seems too subtle, so I think
this is an indication that the commit should not be pruned if any
patterns were given.
Differential Revision: https://phab.mercurial-scm.org/D2862
Yuya Nishihara <yuya@tcha.org> [Sat, 17 Mar 2018 00:06:14 +0900] rev 36977
test-template-engine: do not evaluate unused keywords by custom engine
If the custom engine, "mytemplater", were installed as the default, it would
enter to an infinite recursion at stringify(v) because template keywords may
generate a nested mapping containing the same keywords.
Spotted by a future patch which will replace context.resource('templ')(...)
with context.process(...).
Yuya Nishihara <yuya@tcha.org> [Fri, 16 Mar 2018 23:59:13 +0900] rev 36976
py3: make test-template-engine.t bytes-safe
Yuya Nishihara <yuya@tcha.org> [Thu, 15 Mar 2018 20:10:54 +0900] rev 36975
test-template-engine: deduplicate methods of custom template engine
Boris Feld <boris.feld@octobus.net> [Thu, 18 Jan 2018 15:10:22 +0100] rev 36974
revbranchcache: advertise and use 'rbc' exchange capability
The feature is now advertised and use.
Updating the branchmap cache can be very expensive (up to minutes on large
repository) and fetching revision branch data is about 80% of that. Exchanging
the rev branch cache over the wire really help to recover from branch map
invalidation.
(There is a good chance other in flight chance would conflict on
test-http-bad-server.t and other. So here is a small note to help update that
test again: capabilities=19bytes, part-107bytes)
Boris Feld <boris.feld@octobus.net> [Wed, 21 Feb 2018 19:26:41 +0100] rev 36973
revbranchcache: disable the new part for narrow hg bundle
The lack of some revisions confuses the new cache part. To simplify things, we
disable it for now.
Boris Feld <boris.feld@octobus.net> [Thu, 18 Jan 2018 14:58:02 +0100] rev 36972
revbranchcache: add the necessary bit to send 'rbc' data over bundle2
Getbundle is now capable of sending rev-branch-cache information for the
changesets it bundle. The data sent are mostly nodes so it is quite compact.
The goal of the rev-branch-cache is to speed up branch map computation,
especially when the branchmap gets invalidated so we send data for all
exchanged changesets. In addition, computing the relevant heads to send in
case of partial pulling would be challenging.
The feature is still inactive since the capability is not advertised yet.
Boris Feld <boris.feld@octobus.net> [Wed, 21 Feb 2018 17:33:00 +0100] rev 36971
bundle: include advisory rev branch cache part in bundle2 bundle
`hg bundle` command producing bundle2 will now include an optional part
containing the revision-branch cache data.
The data sent are mostly nodes so it is quite compact. The goal of the
rev-branch-cache is to speed up branch map computation, especially when the
branchmap gets invalidated so we send data for all exchanged changesets. In
addition, computing the relevant heads to send in case of partial pulling would
be challenging.
As a reminder, the rev branch cache data significantly speed up branch
computation. Having it around provides a small speedup to pull/clone and much
higher tolerance to branch map cache invalidation that might happens from later
commands.
On the Mercurial repository, computing the visible branchmap from scratch move
from 2.00 seconds to 0.34s (a -83% speedup).
Using this new part, Unbundling the full Mercurial repository moves from 25.736
seconds to 24.030 seconds (around -7% speedup). The bundle size increase is
around 3% (from 22.43 MB to 23.13MB)
On an half a million revision repository with twenty thousand
branches, computing the branchmap moves from 75 seconds to 45 second (-40%) if
the caches is used.
A bundle containing 50 000 changesets in such repository get a 0.5% size
increase from such part for a -3% unbundling time speedup.
Boris Feld <boris.feld@octobus.net> [Wed, 21 Feb 2018 17:26:22 +0100] rev 36970
rev-branch-cache: add a function to generate a part
The function is able to produce a rbc part consumed by the function introduced
into previous changesets. More details on usage and impact in the next
changesets.
Boris Feld <boris.feld@octobus.net> [Wed, 21 Feb 2018 17:35:04 +0100] rev 36969
revbranchcache: add a bundle2 handler for a rbc part
We add the necessary bit to process a part containing rev-branch-cache
information. The local rev branch cache is then updated with the received
information.
Computing branch cache can become a significant part of the time spent pulling.
Boris Feld <boris.feld@octobus.net> [Thu, 18 Jan 2018 14:21:05 +0100] rev 36968
revbranchcache: add a public function to update the data
We want to exchange more cached data over the wire. To do so, we need a clean
way to update the cache on the receiving ends.
Gregory Szorc <gregory.szorc@gmail.com> [Thu, 15 Mar 2018 11:19:16 -0700] rev 36967
httppeer: consolidate _requestbuilder assignments and document
I collapsed multiple assignments because they don't appear to
be necessary. We don't invoke the requestbuilder in anything
called during __init__. So there's no reason to not define it
earlier AFAICT.
This seemingly useless attribute is actually an extension point.
Document it as such.
(A previous version of this patch removed the attribute because
it appeared to just be an alias.)
Differential Revision: https://phab.mercurial-scm.org/D2723
Gregory Szorc <gregory.szorc@gmail.com> [Mon, 05 Mar 2018 00:18:07 -0500] rev 36966
commands: don't check for merge.update() truthiness
AFAICT ``stats`` is always a tuple in these cases. We don't
need to check if the variable has a truthy value.
Differential Revision: https://phab.mercurial-scm.org/D2691
Gregory Szorc <gregory.szorc@gmail.com> [Wed, 07 Mar 2018 19:57:50 -0800] rev 36965
httppeer: alias url as urlmod
"url" is a common variable name. We do this aliasing elsewhere to
avoid shadowing.
Differential Revision: https://phab.mercurial-scm.org/D2724
Gregory Szorc <gregory.szorc@gmail.com> [Wed, 14 Mar 2018 11:52:35 -0700] rev 36964
util: prefer "bytesio" to "stringio"
The io.BytesIO and io.StringIO types enforce the type of
data being operated on. On Python 2, we use cStringIO.StringIO(),
which is lax about mixing types. On Python 3, we actually use
io.BytesIO. Ideally, we'd use io.BytesIO on Python 2. But I believe
its performance is poor compared to cString.StringIO().
Anyway, we canonically define our pycompat type as "stringio."
That name is misleading, especially on Python 3.
This commit renames the canonical symbols to "bytesio."
"stringio" is preserved as an alias for API compatibility. There
are a lot of callers in the repo and I hesitate to take away the
old name. I also don't feel like changing everything at this time.
But at least new callers can use a "proper" name.
Differential Revision: https://phab.mercurial-scm.org/D2868
Augie Fackler <augie@google.com> [Wed, 14 Mar 2018 14:05:45 -0400] rev 36963
contrib: fix a subtle bug in check-code's regex rewriting
We rewrite `\s` to `[ \t]` when preparing our regular expressions, but
we previously weren't working to avoid having nested sets. Previously,
Python let this slide without incident, but in Python 3.7 wants to
make sure you meant an actual [ in a set, and so this warns. This
appears to be fortunate for us, because `[\s(]` was getting rewritten
to be `[[ \t](]` which doesn't actually match what we expected. See
preceding changes that were revealed to be necessary after
implementing this fix.
Differential Revision: https://phab.mercurial-scm.org/D2866
Augie Fackler <augie@google.com> [Tue, 13 Mar 2018 17:55:03 -0400] rev 36962
remotenames: work around move of ABCs in collections
This starts warning in Python 3.7, and will break in 3.8. The import
is performed in a curious place because `import collections.abc`
explodes badly on Python 2.7, and `from collections import abc` flunks
our import checker.
Differential Revision: https://phab.mercurial-scm.org/D2847
Anton Shestakov <av6@dwimlabs.net> [Mon, 26 Feb 2018 20:44:21 +0800] rev 36961
hgweb: explain instabilities of unstable changesets
Anton Shestakov <av6@dwimlabs.net> [Mon, 26 Feb 2018 20:44:01 +0800] rev 36960
debug: add debugwhyunstable that explains instabilities
This is a port of evolve's feature of listing all unstable changesets in detail
(`hg evolve --list`).
Anton Shestakov <av6@dwimlabs.net> [Tue, 13 Mar 2018 20:34:38 +0800] rev 36959
obsolete: move marker flags to obsutil
Evolve extension expects to have obsolete.bumpedfix (imported in
hgext3rd/evolve/evolvecmd.py), so we provide it.
Boris Feld <boris.feld@octobus.net> [Wed, 21 Feb 2018 17:21:10 +0100] rev 36958
debugupdatecache: also warm rev branch cache
We add basic code to have `debugupdatecache` ensure that the rev branch cache
is fully warmed. This only affects the `debugupdatecache` command, not normal
transaction operation.
Boris Feld <boris.feld@octobus.net> [Wed, 21 Feb 2018 17:16:56 +0100] rev 36957
debugbundle: do not display detailed part data in --quiet mode
This changeset makes `hg debugbundle` respect --quiet and only display data
about part headers.
Augie Fackler <augie@google.com> [Wed, 14 Mar 2018 15:44:53 -0400] rev 36956
tests: clean up two wayward `python` invocations
These are also fallout from the check-code regex rewriting bug.
Differential Revision: https://phab.mercurial-scm.org/D2865
Augie Fackler <augie@google.com> [Wed, 14 Mar 2018 15:42:23 -0400] rev 36955
contrib: open a hole in the open().read() ban for open().close()
It turns out open().close() is both fine and something we occasionally
do to verify something can be written. The few cases in the codebase
were getting missed due to a regular expression bug (which I discussed
in my previous change), but since I'm about to fix the bug, I need to
fix the patterns.
Differential Revision: https://phab.mercurial-scm.org/D2864
Augie Fackler <augie@google.com> [Wed, 14 Mar 2018 15:39:28 -0400] rev 36954
cleanup: fix some latent open(path).read() et al calls we previously missed
This pattern was banned by check-code way back in 1b4b82063ce2 (may of
2011), but due to a regular expression rewriting bug in check-code
these particular callsites were never detected. Python 3.7 caught the
bug, which then exposed these errors.
Differential Revision: https://phab.mercurial-scm.org/D2863
Martin von Zweigbergk <martinvonz@google.com> [Wed, 14 Mar 2018 11:16:45 -0700] rev 36953
uncommit: fix unaligned indentation
Differential Revision: https://phab.mercurial-scm.org/D2861
Boris Feld <boris.feld@octobus.net> [Fri, 09 Mar 2018 18:39:48 +0100] rev 36952
util: clear debugstacktrace call
During the renaming of datestr, it seems that I have forget a debugstacktrace
in util.py. Remove it.
Differential Revision: https://phab.mercurial-scm.org/D2838
Boris Feld <boris.feld@octobus.net> [Mon, 05 Mar 2018 11:48:28 -0500] rev 36951
peer-request: include more details about batch commands
A batch commands encapsulate multiple other commands. We display a bit more
details about what is actually batched if peer request tracking is set.
Augie Fackler <augie@google.com> [Wed, 14 Mar 2018 15:56:34 -0400] rev 36950
tests: fix test-wireproto.py to work around serverrepo() not having a ui
This started failing recently, but it doesn't look important as no
actual ui objects have been in play.
Differential Revision: https://phab.mercurial-scm.org/D2867
Augie Fackler <augie@google.com> [Tue, 13 Mar 2018 22:53:49 -0400] rev 36949
tests: add a cat of `error.log` in subrepo test
This made some debugging a lot less painful when something was broken,
and it costs us almost nothing, so I figure we may as well leave it
in.
Differential Revision: https://phab.mercurial-scm.org/D2853
Augie Fackler <augie@google.com> [Tue, 13 Mar 2018 18:13:37 -0400] rev 36948
hghave: fix hardlink-whitelisted check on Python 3
Differential Revision: https://phab.mercurial-scm.org/D2846
Augie Fackler <augie@google.com> [Tue, 13 Mar 2018 18:05:49 -0400] rev 36947
hghave: fix xdiff check on Python 3
Differential Revision: https://phab.mercurial-scm.org/D2845
Augie Fackler <augie@google.com> [Tue, 13 Mar 2018 18:04:37 -0400] rev 36946
commandserver: prefer first-party selectors module from Python 3 to backport
Caught by some deprecation warnings on Python 3.7.
Differential Revision: https://phab.mercurial-scm.org/D2844
Sushil khanchi <sushilkhanchi97@gmail.com> [Sat, 10 Mar 2018 12:33:19 +0530] rev 36945
forget: add --dry-run mode
Boris Feld <boris.feld@octobus.net> [Fri, 09 Mar 2018 15:53:41 +0100] rev 36944
push-discovery: extract the bookmark comparison logic in its own function
This will help extensions to alter the behavior as they see fit.
Boris Feld <boris.feld@octobus.net> [Fri, 09 Mar 2018 16:31:35 +0100] rev 36943
push-discovery: don't turn use generator when comparing bookmarks
We want extensions to be able to implement their own logic. Generators can be
consume only once, impractical for this purpose.
Jun Wu <quark@fb.com> [Tue, 13 Mar 2018 16:56:13 -0700] rev 36942
xdiff: move stdint.h to xdiff.h
It's more correct to put it in xdiff.h since that file actually uses int64_t
etc and xdiff.h is included by xinclude.h.
This should fix the oss-fuzz build. Thanks durin42 for discovering the
issue.
Test Plan:
`make local` and xdiff related tests still work.
Differential Revision: https://phab.mercurial-scm.org/D2848
Yuya Nishihara <yuya@tcha.org> [Mon, 12 Mar 2018 20:37:08 +0900] rev 36941
annotate: correct parameter name of decorate() function
Yuya Nishihara <yuya@tcha.org> [Tue, 13 Mar 2018 21:22:14 +0900] rev 36940
pycompat: name maplist() and ziplist() for better traceback message
Martin von Zweigbergk <martinvonz@google.com> [Sun, 04 Mar 2018 09:07:06 -0800] rev 36939
rebase: move constant expressions out of inner loop in _performrebase()
Differential Revision: https://phab.mercurial-scm.org/D2811
Martin von Zweigbergk <martinvonz@google.com> [Fri, 02 Mar 2018 15:38:20 -0800] rev 36938
rebase: inline _performrebasesubset()
Now that most of _performrebasesubset() has been moved into
_rebasenode(), it's simple enough that we can inline it.
Differential Revision: https://phab.mercurial-scm.org/D2810
Martin von Zweigbergk <martinvonz@google.com> [Mon, 12 Mar 2018 10:39:42 -0700] rev 36937
rebase: extract function for rebasing a single node
We currently have _performrebase() and _performrebasesubset(), but we
don't have a method for rebasing a single node (that's inside a loop
in _performrebasesubset()). I think it makes sense to have such a
method, so that's what this patch does. I think it may simplify future
patches I'm working on that have to do with transactions, but I think
this patch makes sense on its own whether or not that future work
happens.
Differential Revision: https://phab.mercurial-scm.org/D2809
Martin von Zweigbergk <martinvonz@google.com> [Fri, 09 Mar 2018 12:48:00 -0800] rev 36936
rebase: use configoverride context manager for ui.forcemerge
Differential Revision: https://phab.mercurial-scm.org/D2761
Martin von Zweigbergk <martinvonz@google.com> [Fri, 09 Mar 2018 12:45:50 -0800] rev 36935
rebase: also restore "ui.allowemptycommit" value
It looks like this was lost when the code was converted to the
ui.configoverride() context manager in f255b1811f5e (rebase: get rid
of ui.backupconfig, 2017-03-16). (And then the bad example was
duplicated in 228916ca12b5 (rebase: add concludememorynode(), and call
it when rebasing in-memory, 2017-12-07).)
Differential Revision: https://phab.mercurial-scm.org/D2760
Martin von Zweigbergk <martinvonz@google.com> [Thu, 08 Mar 2018 14:17:24 -0800] rev 36934
rebase: fix issue 5494 also with --collapse
Differential Revision: https://phab.mercurial-scm.org/D2759
Martin von Zweigbergk <martinvonz@google.com> [Fri, 09 Mar 2018 10:35:48 -0800] rev 36933
rebase: also include commit of collapsed commits in single transaction
When rebase.singletransaction is set, we still used to create a second
transaction when committing with --collapse. It's simpler to create a
single transaction.
Note that in the affected .t file, the test that uses --collapse still
appears to create two transactions (it prints "rebase status stored"
twice). However, only a single transaction is actually created and the
second printout comes from cmdutil.commitforceeditor() that explicitly
calls tr.writepending().
Also note the that we now roll back any commits if the user closes the
commit message editor with an error code (or leaves the message
empty). That might be unfortunate, but it's consistent with how we
behave in the --no-collapse case (if the user passed --edit). If we
want to change that, I think it should be done consistently in a
separate patch.
Differential Revision: https://phab.mercurial-scm.org/D2728
Matt Harbison <matt_harbison@yahoo.com> [Mon, 12 Mar 2018 23:08:47 -0400] rev 36932
lfs: debug print HTTP headers and JSON payload received from the server
This has been extremely valuable to show divergences between `hg serve` and
`lfs-test-server`. Once the `hg serve` code lands, there will be a certain
amount of conditionalizing that needs to be done, because `lfs-test-server`
doesn't always follow its spec.
The $ISO_8601_DATE_TIME$ pattern masks the fact that `lfs-test-serve` is sending
out an expires_at value of "0001-01-01T00:00:00Z". `hg serve` will (probably)
use current time + 10 minutes or similar. The $HTTP_DATE$ is the current time.
Matt Harbison <matt_harbison@yahoo.com> [Mon, 12 Mar 2018 22:30:01 -0400] rev 36931
test-lfs: dial up the debugging on commands that interact with the server
This will be useful to let the client print out the HTTP headers and JSON in a
future patch, so we can compare native LFS serving against test-lfs-server
behavior. There tends to be a lot of debug stuff that we don't care about here
in a push, so I was tempted to print this output with a [devel] config. But
this will be useful for field debugging too, so just put up with the extra
output here.
It would have been nice to be able to set ui.debug once, but issue5815 prevents
that.
Matt Harbison <matt_harbison@yahoo.com> [Sat, 24 Feb 2018 15:12:01 -0500] rev 36930
tests: add a substitution pattern for dates in HTTP headers and LFS payload
This will be useful when printing HTTP headers and JSON payload received from an
LFS server. The RFC 1123 date masking has uses elsewhere too.
Matt Harbison <matt_harbison@yahoo.com> [Mon, 12 Mar 2018 21:50:18 -0400] rev 36929
xdiff: fix a hard crash on Windows
The xdiff case of test-diff-antipatience.t started crashing in the C extension
with 882657a9f768 (with 6a71a5ba666b backported so it compiles). There are a
few more instances of 'long', but this resolves the crashing.
Yuya Nishihara <yuya@tcha.org> [Thu, 08 Mar 2018 22:23:02 +0900] rev 36928
templater: split template functions to new module
It has grown enough to be a dedicated module.
Yuya Nishihara <yuya@tcha.org> [Thu, 08 Mar 2018 23:15:09 +0900] rev 36927
templater: move hybrid class and functions to templateutil module
And make _hybrid and _mappable classes public. _showlist() is still marked
as private since it's weird and third-party codes shouldn't depend on it.
Yuya Nishihara <yuya@tcha.org> [Thu, 08 Mar 2018 23:10:46 +0900] rev 36926
templater: move stringify() to templateutil module
As we have a util module, it doesn't make sense to import stringify() from
templatefilters.py.
Yuya Nishihara <yuya@tcha.org> [Wed, 28 Feb 2018 15:20:41 -0500] rev 36925
dagop: move lines() out of annotate()
Yuya Nishihara <yuya@tcha.org> [Wed, 28 Feb 2018 15:19:47 -0500] rev 36924
dagop: extract core algorithm of annotate() from context.py
See the previous patch for why.
Yuya Nishihara <yuya@tcha.org> [Wed, 28 Feb 2018 15:09:05 -0500] rev 36923
dagop: move annotateline and _annotatepair from context.py
The annotate logic is large. Let's move it out of the context module, which
is basically an abstraction layer of repository operations.
Matt Harbison <matt_harbison@yahoo.com> [Fri, 09 Mar 2018 21:59:07 -0500] rev 36922
bdiff: convert more longs to int64_t
MSVC previously flagged these where the function is stored in a pointer:
bdiff.c(284) : warning C4028: formal parameter 1 different from declaration
bdiff.c(284) : warning C4028: formal parameter 2 different from declaration
bdiff.c(284) : warning C4028: formal parameter 3 different from declaration
bdiff.c(284) : warning C4028: formal parameter 4 different from declaration
Matt Harbison <matt_harbison@yahoo.com> [Fri, 09 Mar 2018 21:42:33 -0500] rev 36921
xdiff: silence a 32-bit shift warning on Windows
It's probably harmless, but:
warning C4334: '<<' : result of 32-bit shift implicitly converted to 64 bits
(was 64-bit shift intended?)
Adding a 'ULL' suffix to 1 also works, but I doubt that's portable.
Matt Harbison <matt_harbison@yahoo.com> [Fri, 09 Mar 2018 21:31:57 -0500] rev 36920
xdiff: backport int64_t and uint64_t types to Windows
Sadly, MSVC 2008 lacks stdint.h. These are the only two definitions needed
right now.
Yuya Nishihara <yuya@tcha.org> [Thu, 08 Mar 2018 22:33:24 +0900] rev 36919
templater: extract template evaluation utility to new module
Prepares for splitting template functions to new module.
All eval* functions were moved to templateutil.py, and run* functions had to
be moved as well due to the dependency from eval*s. eval*s were aliased as
they are commonly used in codebase. _getdictitem() had to be made public.
Yuya Nishihara <yuya@tcha.org> [Thu, 08 Mar 2018 22:20:36 +0900] rev 36918
templater: move function table to the "context" object
Prepares for splitting template functions from templater.py.
Gregory Szorc <gregory.szorc@gmail.com> [Sun, 11 Mar 2018 16:29:54 -0700] rev 36917
hgweb: remove wsgirequest (API)
Good riddance.
.. api::
The old ``wsgirequest`` class for handling everything WSGI in hgweb
has been replaced by separate request and response types. Various
high-level functions in the hgweb WSGI applications now receive
these new types as arguments instead of the old ``wsgirequest``
type.
Differential Revision: https://phab.mercurial-scm.org/D2832
Pulkit Goyal <7895pulkit@gmail.com> [Sat, 10 Mar 2018 15:24:24 +0530] rev 36916
tweakdefaults: add commands.status.verbose to tweakefaults
commands.status,verbose if set to True, shows conflict information in `hg
status`. It shows which unresolved state you are in, which are the unresolved
files and how to continue the unresolved state. That sounds like a very good
candidate for tweakdefaults.
bisect is added to commands.status.skipstates because people generally leave
unresolved bisect state and we should skip that in morestatus output.
Differential Revision: https://phab.mercurial-scm.org/D2806
Gregory Szorc <gregory.szorc@gmail.com> [Sun, 11 Mar 2018 16:19:20 -0700] rev 36915
hgweb: store the raw WSGI environment dict
We need this so we can construct a new request instance
from the original dict.
Differential Revision: https://phab.mercurial-scm.org/D2831
Gregory Szorc <gregory.szorc@gmail.com> [Sun, 11 Mar 2018 15:55:38 -0700] rev 36914
hgweb: remove dead wsgirequest code
All responses now go through our modern response type. All code related
to response handling can be deleted.
Differential Revision: https://phab.mercurial-scm.org/D2830
Gregory Szorc <gregory.szorc@gmail.com> [Sun, 11 Mar 2018 15:40:58 -0700] rev 36913
hgweb: port to new response API
These were the last consumers of wsgirequest.respond() \o/
Differential Revision: https://phab.mercurial-scm.org/D2829
Gregory Szorc <gregory.szorc@gmail.com> [Sun, 11 Mar 2018 15:35:03 -0700] rev 36912
hgweb: pass modern request type into templater()
Only a handful of consumers of wsgirequest remaining in this
file...
Differential Revision: https://phab.mercurial-scm.org/D2828
Gregory Szorc <gregory.szorc@gmail.com> [Sun, 11 Mar 2018 15:37:59 -0700] rev 36911
hgweb: use modern response type for index generation
Differential Revision: https://phab.mercurial-scm.org/D2827
Gregory Szorc <gregory.szorc@gmail.com> [Sun, 11 Mar 2018 15:29:38 -0700] rev 36910
hgweb: don't pass wsgireq to makeindex and other functions
We only ever access attributes that are available on our newer
request type. So we no longer need this argument.
Differential Revision: https://phab.mercurial-scm.org/D2826
Gregory Szorc <gregory.szorc@gmail.com> [Sun, 11 Mar 2018 15:18:29 -0700] rev 36909
hgweb: replace PATH_INFO with dispatchpath
This was the last consumer of wsgireq.env from our WSGI applications!
(Although indirect consumers of this attribute exist in
wsgirequest.respond().)
Differential Revision: https://phab.mercurial-scm.org/D2825
Gregory Szorc <gregory.szorc@gmail.com> [Sun, 11 Mar 2018 15:15:02 -0700] rev 36908
hgweb: rewrite path generation for index entries
I think this code is easier to read. But the real reason to do this
is to eliminate a consumer of wsgirequest.
Differential Revision: https://phab.mercurial-scm.org/D2824
Gregory Szorc <gregory.szorc@gmail.com> [Sun, 11 Mar 2018 15:08:36 -0700] rev 36907
hgweb: construct {url} with req.apppath
This is how the hgweb WSGI application does it. Let's make the
behavior consistent.
Differential Revision: https://phab.mercurial-scm.org/D2823
Gregory Szorc <gregory.szorc@gmail.com> [Sun, 11 Mar 2018 15:33:56 -0700] rev 36906
hgweb: support constructing URLs from an alternate base URL
The web.baseurl config option allows server operators to define a
custom URL for hosted content.
The way it works today is that hgwebdir parses this config
option into URL components then updates the appropriate
WSGI environment variables so the request "lies" about its
details. For example, SERVER_NAME is updated to reflect the
alternate base URL's hostname.
The WSGI environment should not be modified because WSGI
applications may want to know the original request details (for
debugging, etc).
This commit teaches our request parser about the existence of
an alternate base URL. If defined, the advertised URL and other
self-reflected paths will take the alternate base URL into account.
The hgweb WSGI application didn't use web.baseurl. But hgwebdir
did. We update hgwebdir to alter the environment parsing
accordingly. The old code around environment manipulation
has been removed.
With this change, parserequestfromenv() has grown to a bit
unwieldy. Now that practically everyone is using it, it is
obvious that there is some unused features that can be trimmed.
So look for this in follow-up commits.
Differential Revision: https://phab.mercurial-scm.org/D2822
Gregory Szorc <gregory.szorc@gmail.com> [Sun, 11 Mar 2018 13:55:13 -0700] rev 36905
hgweb: clarify that apppath begins with a forward slash
Differential Revision: https://phab.mercurial-scm.org/D2821
Gregory Szorc <gregory.szorc@gmail.com> [Sun, 11 Mar 2018 13:38:56 -0700] rev 36904
hgweb: change how dispatch path is reported
When I implemented the new request object, I carried forward some
ugly hacks until I could figure out what was happening. One of those
was the handling of PATH_INFO to determine how to route hgweb
requests.
Essentially, if we have PATH_INFO data, we route according to
that. But if we don't, we route by the query string. I question
if we still need to support query string routing. But that's for
another day, I suppose.
In this commit, we clean up the ugly "havepathinfo" hack and
replace it with a "dispatchpath" attribute that can hold None or
empty string to differentiate between the presence of PATH_INFO.
This is still a bit hacky. But at least the request parsing
and routing code is explicit about the meaning now.
Differential Revision: https://phab.mercurial-scm.org/D2820
Gregory Szorc <gregory.szorc@gmail.com> [Sun, 11 Mar 2018 13:11:13 -0700] rev 36903
hgweb: refactor repository name URL parsing
The hgwebdir WSGI application detects when a requested URL is for
a known repository and it effectively forwards the request to the
hgweb WSGI application.
The hgweb WSGI application needs to route the request based on the
base URL for the repository. The way this normally works is
SCRIPT_NAME is used to resolve the base URL and PATH_INFO
contains the path after the script.
But with hgwebdir, SCRIPT_NAME refers to hgwebdir, not the base
URL for the repository. So, there was a hacky REPO_NAME environment
variable being set to convey the part of the URL that represented
the repository so hgweb could ignore this path component for
routing purposes.
The use of the environment variable for passing internal state
is pretty hacky. Plus, it wasn't clear from the perspective of
the URL parsing code what was going on.
This commit improves matters by making the repository name an
explicit argument to the request parser. The logic around
handling of this value has been shored up. We add various checks
that the argument is used properly - that the repository name
does represent the prefix of the PATH_INFO.
Differential Revision: https://phab.mercurial-scm.org/D2819
Gregory Szorc <gregory.szorc@gmail.com> [Sun, 11 Mar 2018 12:53:47 -0700] rev 36902
tests: add test coverage for parsing WSGI requests
A subsequent commit will need to make this code more complicated
in order to support alternate base URLs. Let's establish some test
coverage before we diverge too far from PEP 3333.
As part of this, a minor bug related to a missing SCRIPT_NAME
key has been squashed.
Differential Revision: https://phab.mercurial-scm.org/D2818
Gregory Szorc <gregory.szorc@gmail.com> [Sun, 11 Mar 2018 10:51:14 -0700] rev 36901
hgweb: construct static URL like hgweb does
hgwebdir has a bit of code for constructing URLs. This reinvents wheels
from our parsedrequest instance. And sometimes the behavior varies
from what hgweb does. We'll want to converge that behavior.
This commit changes hgwebdir so its staticurl template keyword
is constructed the same way as hgweb's. There's probably room
to factor this into a shared function. But let's solve the
problem of divergence first.
Differential Revision: https://phab.mercurial-scm.org/D2817
Gregory Szorc <gregory.szorc@gmail.com> [Sun, 11 Mar 2018 10:38:46 -0700] rev 36900
hgweb: remove unused **map argument
It was unused before the recent code refactoring AFAICT.
Differential Revision: https://phab.mercurial-scm.org/D2816
Gregory Szorc <gregory.szorc@gmail.com> [Sun, 11 Mar 2018 10:37:25 -0700] rev 36899
hgweb: extract entries() to standalone function
There was some real wonkiness going on here. Essentially, the
inline function was being executed with default arguments because
a function reference was passed as-is into the templater. That
seemed odd. So now we pass an explicit generator of the function
result.
Moving this code out of makeindex() makes makeindex() small enough
to reason about. This makes it easier to see weird things, like the
fact that we're calling self.refresh() twice. Why, I'm not sure.
I'm also not sure why we need to call updatereqenv() to possibly
update the SERVER_NAME, SERVER_PORT, and SCRIPT_NAME variables as
part of rendering an index. I'll dig into these things in subsequent
commits.
Differential Revision: https://phab.mercurial-scm.org/D2815
Gregory Szorc <gregory.szorc@gmail.com> [Sun, 11 Mar 2018 10:24:46 -0700] rev 36898
hgweb: move rawentries() to a standalone function
It was only accessing a few variables from the outer scope. Let's
make it standalone so there is better clarity about what the inputs
are.
Differential Revision: https://phab.mercurial-scm.org/D2814
Gregory Szorc <gregory.szorc@gmail.com> [Sun, 11 Mar 2018 10:17:58 -0700] rev 36897
hgweb: move archivelist to standalone function
This doesn't need to exist as an inline function in a method.
Minor formatting changes were made as part of the move.
Differential Revision: https://phab.mercurial-scm.org/D2813
Gregory Szorc <gregory.szorc@gmail.com> [Sun, 11 Mar 2018 10:15:33 -0700] rev 36896
hgweb: move readallowed to a standalone function
hgwebdir s kind of large. Let's make the class smaller by
moving things that don't need to be there.
Differential Revision: https://phab.mercurial-scm.org/D2812
Gregory Szorc <gregory.szorc@gmail.com> [Sun, 11 Mar 2018 15:51:13 -0700] rev 36895
hgweb: remove some use of wsgireq in hgwebdir
While we're here, rename a method so abide by our style policy,
since otherwise check-commit would complain.
Differential Revision: https://phab.mercurial-scm.org/D2805
Gregory Szorc <gregory.szorc@gmail.com> [Sat, 10 Mar 2018 20:54:44 -0800] rev 36894
hgweb: fix a bug due to variable name typo
It looks like the "sort" query string parameter was not being
honored properly.
Differential Revision: https://phab.mercurial-scm.org/D2804
Gregory Szorc <gregory.szorc@gmail.com> [Sat, 10 Mar 2018 20:51:46 -0800] rev 36893
hgweb: stop passing req and tmpl into @webcommand functions (API)
We have effectively removed all consumers of the old wsgirequest
type. The templater can be accessed on the requestcontext passed
into the @webcommand function.
For the most part, these arguments are unused. They only exist to
provide backwards compatibility. And in the case of wsgirequest,
use of that object could actively interfere with the new request
object.
So let's stop passing these objects to @webcommand functions.
With this commit, wsgirequest is practically dead from the hgweb
WSGI application. There are still some uses in hgwebdir though...
.. api::
@webcommand functions now only receive a single argument. The
request and templater instances can be accessed via the
``req`` and ``templater`` attributes of the first argument.
Note that the request object is different from previous Mercurial
releases and consumers of the previous ``req`` 2nd argument
will need updating to use the new API.
Differential Revision: https://phab.mercurial-scm.org/D2803
Gregory Szorc <gregory.szorc@gmail.com> [Sat, 10 Mar 2018 19:57:08 -0800] rev 36892
hgweb: pass modern request type into various webutil functions (API)
Our march towards killing wsgirequest continues.
.. api::
Various functions in hgweb.webutil now take a modern request
object instead of ``wsgirequest``.
Differential Revision: https://phab.mercurial-scm.org/D2802
Gregory Szorc <gregory.szorc@gmail.com> [Sat, 10 Mar 2018 19:46:54 -0800] rev 36891
hgweb: don't redundantly pass templater with requestcontext (API)
The requestcontenxt has a ``tmpl`` attribute to access the
templater. We don't need to pass the templater explicitly when
passing a requestcontext instance.
.. api::
Various helper functions in hgweb.webutil no longer accept a
templater instance. Access the templater through the
``web`` argument instead.
Differential Revision: https://phab.mercurial-scm.org/D2801
Gregory Szorc <gregory.szorc@gmail.com> [Sat, 10 Mar 2018 20:38:28 -0800] rev 36890
hgweb: use templater on requestcontext instance
After this commit, all @webcommand function no longer use their
"tmpl" argument. Instead, they use the templater attached to the
requestcontext.
This is the same exact object. So there should be no difference in
behavior.
Differential Revision: https://phab.mercurial-scm.org/D2800
Gregory Szorc <gregory.szorc@gmail.com> [Sat, 10 Mar 2018 19:41:18 -0800] rev 36889
hgweb: add a sendtemplate() helper function
This pattern is common. Let's make a helper function to reduce
boilerplate.
We store the "global" template on the requestcontext instance and
use it. The templater used by the helper function is the same
templater that's passed in as an argument to the @webcommand
functions. It needs to be this way because various commands are
accessing and mutating the defaults on the templater instance.
Differential Revision: https://phab.mercurial-scm.org/D2799
Gregory Szorc <gregory.szorc@gmail.com> [Sat, 10 Mar 2018 19:11:41 -0800] rev 36888
hgweb: use web.req instead of req.req
We now have access to the modern request type on the
requestcontext instance. Let's access it from there.
While we're here, remove an unused argument from _search().
Differential Revision: https://phab.mercurial-scm.org/D2798
Gregory Szorc <gregory.szorc@gmail.com> [Sat, 10 Mar 2018 19:08:58 -0800] rev 36887
hgweb: stop setting headers on wsgirequest
All commands now go through the new response API. This is dead code.
Differential Revision: https://phab.mercurial-scm.org/D2797
Gregory Szorc <gregory.szorc@gmail.com> [Sat, 10 Mar 2018 20:35:35 -0800] rev 36886
hgweb: always return iterable from @webcommand functions (API)
We had to hack up this function to support our transition to the
new response API. Now that we're done with the transition (!!),
we can return to returning an iterator of content chunks from
these functions.
It is tempting to return a normal object and not a generator.
However, as the keyword extension demonstrates, extensions may
wish to wrap commands and have a try..finally block around
execution. Since there is a generator producing content and
that generator could be executing code, the try..finally needs
to live for as long as the generator is running. That means we
have to return a generator so wrappers can consume the generator
inside a try..finally.
.. api::
hgweb @webcommand functions must use the new response object
passed in via ``web.res`` to initiate sending of a response.
The hgweb WSGI application will no longer start sending the
response automatically.
Differential Revision: https://phab.mercurial-scm.org/D2796
Gregory Szorc <gregory.szorc@gmail.com> [Sat, 10 Mar 2018 18:51:32 -0800] rev 36885
hgweb: send errors using new response API
Our slow march off of wsgirequest continues.
Differential Revision: https://phab.mercurial-scm.org/D2795
Gregory Szorc <gregory.szorc@gmail.com> [Sat, 10 Mar 2018 18:42:00 -0800] rev 36884
hgweb: refactor 304 handling code
We had generic code in wsgirequest for handling HTTP 304 responses.
We also had a special case for it in the catch all exception handler
in the WSGI application.
We only ever raise 304 in one place. So, we don't need to treat it
specially in the catch all exception handler.
But it is useful to validate behavior of 304 responses. We port the
code that sends a 304 to use the new response API. We then move the
code for screening 304 sanity into the new response API.
As part of doing so, we discovered that we would send
Content-Length: 0. This is not allowed. So, we fix our response code
to not emit that header for empty response bodies.
Differential Revision: https://phab.mercurial-scm.org/D2794
Gregory Szorc <gregory.szorc@gmail.com> [Sat, 10 Mar 2018 18:19:27 -0800] rev 36883
hgweb: transition permissions hooks to modern request type (API)
We're trying to remove ``wsgirequest``. The permissions hooks don't
do anything they can't do with our new request type. So let's
pass that in.
This was the last use of ``wsgirequest`` in the wire protocol code!
.. api::
hgweb.hgweb_mod.permhooks no longer take a ``wsgirequest`` instance
as an argument.
Differential Revision: https://phab.mercurial-scm.org/D2793
Gregory Szorc <gregory.szorc@gmail.com> [Sat, 10 Mar 2018 20:16:20 -0800] rev 36882
hgweb: port archive command to modern response API
Well, I tried to go with PEP 3333's recommendations and only allow
our WSGI application to emit data via a response generator.
Unfortunately, the "archive" command calls into the zipfile and
tarfile modules and these operator on file objects and must send
their data to an object with write(). There's no easy way turn
these write() calls into a generator.
So, we teach our response type how to expose a file object like
object that can be used to write() output. We try to keep the API
consistent with how things work currently: callers must call a
setbody*(), then sendresponse() to trigger sending of headers,
and only then can they get a handle on the object to perform
writing.
This required overloading the return value of @webcommand functions
even more. Fortunately, we're almost completely ported off the
legacy API. So we should be able to simplify matters in the near
future.
A test relying on this functionality has also been updated to use
the new API.
Differential Revision: https://phab.mercurial-scm.org/D2792
Gregory Szorc <gregory.szorc@gmail.com> [Sat, 10 Mar 2018 16:17:51 -0800] rev 36881
hgweb: refactor fake file object proxy for archiving
Python's zip file writer operates on a file object. When doing work,
it periodically calls write(), flush(), and tell() on that object.
In WSGI contexts, the start_response function returns a write()
function. That's a function to write data, not a full file object.
So, when the archival code was first introduced in 2b03c6733efa in
2006, someone invented a proxy "tellable" type that wrapped a file
object like object and kept track of write count so it could
implement tell() and satisfy zipfile's needs.
When our archival code runs, it attempts to tell() the destination
and if that fails, converts it to a "tellable" instance. Our WSGI
application passes the "wsgirequest" instance to the archival
function. It fails the tell() test and is converted to a "tellable."
It's worth noting that "wsgirequest" implements flush(), so
"tellable" doesn't.
This hackery all seems very specific to the WSGI code. So this commit
moves the "tellable" type and the conversion of the destination file
object into the WSGI code. There's a chance some other caller may be
passing a file object like object that doesn't implement tell(). But
I doubt it.
As part of the refactor, our new type implements flush() and doesn't
implement __getattr__. Given the intended limited use of this type,
I want things to fail fast if there is an attempt to access attributes
because I think it is important to document which attributes are being
used for what purposes.
Differential Revision: https://phab.mercurial-scm.org/D2791
Gregory Szorc <gregory.szorc@gmail.com> [Sat, 10 Mar 2018 16:27:01 -0800] rev 36880
tests: additional test coverage of archive web command
This command is special in a few ways. First, it is the only command
using the write() function from WSGI's start_response() function.
Second, it is setting a custom content-disposition header.
We change the test so it prints out full details of the HTTP
response. We also save the response body to a file so we can
verify its size and hash. The hash check will help ensure that
archive generation is deterministic.
Differential Revision: https://phab.mercurial-scm.org/D2790
Gregory Szorc <gregory.szorc@gmail.com> [Sat, 10 Mar 2018 15:46:29 -0800] rev 36879
hgweb: port static file handling to new response API
hgwebdir_mod hasn't received as much porting effort. So we had to
do some minor plumbing to get it to match hgweb_mod and to support
the new response object.
Differential Revision: https://phab.mercurial-scm.org/D2789
Gregory Szorc <gregory.szorc@gmail.com> [Sat, 10 Mar 2018 15:37:29 -0800] rev 36878
hgweb: remove one-off routing for file?style=raw
Now that both functions are using the same API, we can unify how
the command is called and perform command-specific behavior in the
command itself instead of in the high-level router.
Differential Revision: https://phab.mercurial-scm.org/D2788
Gregory Szorc <gregory.szorc@gmail.com> [Sat, 10 Mar 2018 20:36:34 -0800] rev 36877
hgweb: port most @webcommand to use modern response type
This only focused on porting the return value.
raw file requests are wonky because they go through a separate code
path at the dispatch layer. Now that everyone is using the same
API, we could clean this up.
It's worth noting that wsgirequest.respond() allows sending the
Content-Disposition header, but the only user of that feature was
removed as part of this change (with the setting of the header
now being performed inline).
A few @webcommand are not as straightforward as the others and
they have not been ported yet.
Differential Revision: https://phab.mercurial-scm.org/D2787
Gregory Szorc <gregory.szorc@gmail.com> [Sat, 10 Mar 2018 17:02:57 -0800] rev 36876
hgweb: support using new response object for web commands
We have a "requestcontext" type for holding state for the current
request. Why we pass in the wsgirequest and templater instance
to @webcommand functions, I don't know.
I like the idea of standardizing on using "requestcontext" for passing
all state to @webcommand functions because that scales well without
API changes every time you want to pass a new piece of data. So,
we add our new request and response instances to "requestcontext" so
@webcommand functions can access them.
We also teach our command dispatcher to recognize a new calling
convention. Instead of returning content from the @webcommand
function, we return our response object. This signals that this
response object is to be used for sending output. The keyword
extension was wrapping various @webcommand and assuming the output
was iterable, so we had to teach it about the new calling convention.
To prove everything works, we convert the "filelog" @webcommand
to use the new convention.
The new calling convention is a bit wonky. I intend to improve this
once all commands are ported to use the new response object.
Differential Revision: https://phab.mercurial-scm.org/D2786
Gregory Szorc <gregory.szorc@gmail.com> [Sat, 10 Mar 2018 14:19:27 -0800] rev 36875
hgweb: inline caching() and port to modern mechanisms
We only had one consumer of this simple function. While it could be
a generic function, let's not over abstract the code.
As part of inlining, we port it off wsgirequest, fix some Python 3
issues, and set a response header on our new response object so it
is ready once we start using it to send responses.
Differential Revision: https://phab.mercurial-scm.org/D2785
Gregory Szorc <gregory.szorc@gmail.com> [Sat, 10 Mar 2018 14:06:58 -0800] rev 36874
hgweb: expose repo name on parsedrequest
I'm not a fan of doing this because I want to find a better solution to
the REPO_NAME hack. But this change gets us a few steps closer to
eliminating use of wsgirequest. We can worry about fixing REPO_NAME
once wsgirequest is gone.
Differential Revision: https://phab.mercurial-scm.org/D2784
Gregory Szorc <gregory.szorc@gmail.com> [Sat, 10 Mar 2018 14:00:40 -0800] rev 36873
hgweb: expose URL scheme and REMOTE_* attributes
These are consulted by the HTTP wire protocol handler by reading from
the env dict. Let's expose them as attributes instead.
With the wire protocol handler updates to use the new attributes, we
no longer have any consumers of the legacy wsgirequest type in the
wire protocol code (outside of a proxied call to the permissions
checker). So, we remove most references to it.
Differential Revision: https://phab.mercurial-scm.org/D2783
Gregory Szorc <gregory.szorc@gmail.com> [Sat, 10 Mar 2018 12:31:11 -0800] rev 36872
hgweb: remove wsgirequest.form (API)
Now that everything is ported to consume from parsedrequest.qsparams,
we no longer have a need for wsgirequest.form. Let's remove all
references to it.
.. api::
The WSGI request object no longer exposes a ``form`` attribute
containing parsed query string data. Use the ``qsparams`` attribute
instead.
Differential Revision: https://phab.mercurial-scm.org/D2782
Gregory Szorc <gregory.szorc@gmail.com> [Sat, 10 Mar 2018 12:36:36 -0800] rev 36871
hgweb: perform all parameter lookup via qsparams
I think I managed to update all call sites using wsgirequest.form
to use parsedrequest.qsparams.
Since behavior of qsparams is to retrieve last value, behavior will
change if a parameter was specified multiple times. But I think this
is acceptable.
I'm not a fan of the `req.req.qsparams` pattern. And some of the
modified code could be written better. But I was aiming for a
straight port with this change. Cleanup can come later.
Differential Revision: https://phab.mercurial-scm.org/D2781
Gregory Szorc <gregory.szorc@gmail.com> [Sat, 10 Mar 2018 12:11:26 -0800] rev 36870
hgweb: set variables in qsparams
We currently mutate wsgireq.form in a few places. Since it is
independent from req.qsparams, we will need to make changes on
req.qsparams as well before consumers can use qsparams. So let's
do that.
Eventually, we'll delete wsgireq.form and all references to it.
Differential Revision: https://phab.mercurial-scm.org/D2780
Gregory Szorc <gregory.szorc@gmail.com> [Sat, 10 Mar 2018 11:46:52 -0800] rev 36869
hgweb: use our new request object for "style" parameter
The "style" parameter is kind of wonky because it is explicitly
set and has lookups in random locations.
Let's port it to qsparams first because it isn't straightforward.
There is subtle change in behavior. But I don't think it is worth
calling out in a BC.
Our multidict's __getitem__ returns the last set value for a key,
not the first. So if the query string set a variable multiple times,
before we would get the first value and now we would get the last
value. It makes no sense to specify these things multiple times.
And I think last write wins is more sensible than first write wins.
Differential Revision: https://phab.mercurial-scm.org/D2779
Gregory Szorc <gregory.szorc@gmail.com> [Sat, 10 Mar 2018 12:35:38 -0800] rev 36868
hgweb: use a multidict for holding query string parameters
My intention with refactoring the WSGI code was to make it easier
to read. I initially wanted to vendor and use WebOb, because it seems
to be a pretty reasonable abstraction layer for WSGI. However, it isn't
using relative imports and I didn't want to deal with the hassle of
patching it. But that doesn't mean we can't use good ideas from WebOb.
WebOb has a "multidict" data structure for holding parsed query string
and POST form data. It quacks like a dict but allows you to store
multiple values for each key. It offers mechanisms to return just one
value, all values, or return 1 value asserting that only 1 value is
set. I quite like its API.
This commit implements a read-only "multidict" in the spirit of
WebOb's multidict.
We replace the query string attributes of our parsed request with
an instance of it.
Differential Revision: https://phab.mercurial-scm.org/D2776
Gregory Szorc <gregory.szorc@gmail.com> [Sat, 10 Mar 2018 11:23:05 -0800] rev 36867
hgweb: create dedicated type for WSGI responses
We have refactored the request side of WSGI processing into a dedicated
type. Now let's do the same thing for the response side.
We invent a ``wsgiresponse`` type. It takes an instance of a
request (for consulation) and the WSGI application's "start_response"
handler.
The type basically allows setting the HTTP status line, response
headers, and the response body.
The WSGI application calls sendresponse() to start sending output.
Output is emitted as a generator to be fed through the WSGI application.
According to PEP 3333, this is the preferred way for output to be
transmitted. (Our legacy ``wsgirequest`` exposed a write() to send
data. We do not wish to support this API because it isn't recommended
by PEP 3333.)
The wire protocol code has been ported to use the new API.
Differential Revision: https://phab.mercurial-scm.org/D2775
Gregory Szorc <gregory.szorc@gmail.com> [Sat, 10 Mar 2018 11:15:05 -0800] rev 36866
tests: add test for a wire protocol request to wrong base URL
We have code that validates that wire protocol commands (which are
specified via query string) must occur at the base URL of a repo.
But we have no test coverage for this behavior. Let's add some.
Differential Revision: https://phab.mercurial-scm.org/D2778
Gregory Szorc <gregory.szorc@gmail.com> [Fri, 09 Mar 2018 17:10:36 -0800] rev 36865
hgweb: remove support for short query string based aliases (BC)
Form data exposed by hgweb is post-processed to expand certain
shortcuts. For example, URLs with "?cs=@" is essentially expanded to
"?cmd=changeset&node=@". And the URL router treats this the same
as "/changeset/@".
These shortcuts were initially added in 2005 in 34cb3957d875 and
964baa35faf8. They have rarely been touched in the last decade (just
moving code around a bit).
We have almost no test coverage of this feature. AFAICT no templates
reference URLs of this form. I even looked at the initial version
of paper and coal from ~2008 and they use the "/command/params" URL
form and not these shortcuts.
Furthermore, I couldn't even get some shortcuts to work! For example,
"?sl=@" attempts to do a revision search instead of showing shortlog
starting at revision @. Maybe I'm just doing it wrong?
Because this is ancient, mostly untested code, there is a migration
path to something better, and because anyone passionate enough to
preserve URLs can install URL redirects, let's nuke the feature.
.. bc::
Query string shorts in hgweb like ``?cs=@`` have been removed. Use
URLs of the form ``/:cmd`` instead.
Differential Revision: https://phab.mercurial-scm.org/D2773
Gregory Szorc <gregory.szorc@gmail.com> [Sat, 10 Mar 2018 11:07:53 -0800] rev 36864
hgweb: remove support for POST form data (BC)
Previously, we called out to cgi.parse(), which for POST requests
parsed multipart/form-data and application/x-www-form-urlencoded
Content-Type requests for form data, combined it with query string
parameters, returned a union of the values.
As far as I know, nothing in Mercurial actually uses this mechanism
to submit data to the HTTP server. The wire protocol has its own
mechanism for passing parameters. And the web interface only does
GET requests. Removing support for parsing POST data doesn't break
any tests.
Another reason to not like this feature is that cgi.parse() may
modify the QUERY_STRING environment variable as a side-effect.
In addition, it merges both POST data and the query string into
one data structure. This prevents consumers from knowing whether
a variable came from the query string or POST data. That can matter
for some operations.
I suspect we use cgi.parse() because back when this code was
initially implemented, it was the function that was readily
available. In other words, I don't think there was conscious
choice to support POST data: we just got it because cgi.parse()
supported it.
Since nothing uses the feature and it is untested, let's remove
support for parsing POST form data. We can add it back in easily
enough if we need it in the future.
.. bc::
Hgweb no longer reads form data in POST requests from
multipart/form-data and application/x-www-form-urlencoded
requests. Arguments should be specified as URL path components
or in the query string in the URL instead.
Differential Revision: https://phab.mercurial-scm.org/D2774
Gregory Szorc <gregory.szorc@gmail.com> [Sat, 10 Mar 2018 11:06:13 -0800] rev 36863
hgweb: expose input stream on parsed WSGI request object
Our next step towards moving away from wsgirequest to our newer,
friendlier parsedrequest type is input stream access.
This commit exposes the input stream on the instance. Consumers
in the HTTP protocol server switch to it.
Because there were very few consumers of the input stream, we stopped
storing a reference to the input stream on wsgirequest directly. All
access now goes through parsedrequest. However, wsgirequest still
may read from this stream as part of cgi.parse(). So we still need to
create the stream from wsgirequest.
Differential Revision: https://phab.mercurial-scm.org/D2771
Gregory Szorc <gregory.szorc@gmail.com> [Sat, 10 Mar 2018 10:56:10 -0800] rev 36862
hgweb: make parsedrequest part of wsgirequest
This is kind of ugly. But an upcoming commit will teach parsedrequest
about the input stream. Because the input stream is global state and
can't be accessed without side-effects, we need to take actions to
ensure that multiple consumers don't read from it independently. The
easiest way to do this is for one object to hold a reference to both
items having access to the input stream so that when a copy is made,
we can remove the attribute from the other instance.
So we create our parsed request instance from the wsgirequest
constructor and hold a reference to it there. This is better than
our new type holding a reference to wsgirequest because all the
code for managing access will be temporary and we shouldn't pollute
parsedrequest with this ugly history.
Differential Revision: https://phab.mercurial-scm.org/D2770
Gregory Szorc <gregory.szorc@gmail.com> [Sat, 10 Mar 2018 11:03:45 -0800] rev 36861
hgweb: refactor the request draining code
The previous code for draining was only invoked in a few places in
the wire protocol. Behavior wasn't consist. Furthermore, it was
difficult to reason about.
With us converting the input stream to a capped reader, it is now
safe to always drain the input stream when its size is known because
we can never overrun the input and read into the next HTTP request.
The only question is "should we?"
This commit changes the draining code so every request is examined.
Draining now kicks in for a few requests where it wouldn't before.
But I think the code is sufficiently restricted so the behavior is
safe. Possibly the most dangerous part of this code is the issuing
of Connection: close for POST and PUT requests that don't have a
Content-Length. I don't think there are any such uses in our WSGI
application, so this should be safe.
In the near future, I plan to significantly refactor the WSGI
response handling. I anticipate this code evolving a bit. So any
minor regressions around draining or connection closing behavior
might be fixed as a result of that work.
All tests pass with this change. That scares me a bit because it
means we are lacking low-level tests for the HTTP protocol.
Differential Revision: https://phab.mercurial-scm.org/D2769
Gregory Szorc <gregory.szorc@gmail.com> [Sat, 10 Mar 2018 10:48:34 -0800] rev 36860
hgweb: use a capped reader for WSGI input stream
Per PEP 3333, the input stream from WSGI should respect EOF and
prevent reads past the end of the request body. However, not all
WSGI servers guarantee this. Notably, our BaseHTTPServer based
built-in HTTP server doesn't. Instead, it exposes the raw socket
and you can read() from it all you want, getting the connection in
a bad state by doing so.
We have a "cappedreader" utility class that proxies a file object
and prevents reading past a limit.
This commit converts the WSGI input stream into a capped reader when
the input length is advertised via Content-Length headers.
"cappedreader" only exposes a read() method. PEP 3333 states that
the input stream MUST also support readline(), readlines(hint), and
__iter__(). However, since our WSGI application code only calls
read() and since we're not manipulating the stream exposed by the
WSGI server, we're not violating the spec here.
Differential Revision: https://phab.mercurial-scm.org/D2768
Gregory Szorc <gregory.szorc@gmail.com> [Sat, 10 Mar 2018 10:47:30 -0800] rev 36859
hgweb: document continuereader
Differential Revision: https://phab.mercurial-scm.org/D2767
Gregory Szorc <gregory.szorc@gmail.com> [Thu, 08 Mar 2018 18:00:04 -0800] rev 36858
hgweb: remove wsgirequest.__iter__
This was added in d0db3462d568 in 2006. I can't find a justification
for this method in PEP 3333. I suspect we were originally intending
to use this type as the WSGI application (which should be iterable)?
The tests all pass without this method. So let's nuke it.
Differential Revision: https://phab.mercurial-scm.org/D2749
Gregory Szorc <gregory.szorc@gmail.com> [Thu, 08 Mar 2018 17:57:07 -0800] rev 36857
hgweb: remove wsgirequest.read()
This was just a proxy to self.inp.read(). This method serves little
value. Let's nuke it.
Callers in the wire protocol server have been updated accordingly.
Differential Revision: https://phab.mercurial-scm.org/D2748
Gregory Szorc <gregory.szorc@gmail.com> [Sat, 10 Mar 2018 10:46:08 -0800] rev 36856
hgweb: remove unused methods on wsgirequest
writelines() isn't used in our code base.
close() was a no-op. It is an optional method per PEP 3333.
My eventual goal is to kill the wsgirequest class, hence why I'm
removing code.
Differential Revision: https://phab.mercurial-scm.org/D2747
Gregory Szorc <gregory.szorc@gmail.com> [Thu, 08 Mar 2018 17:17:48 -0800] rev 36855
wireprotoserver: remove unused argument from _handlehttperror()
Differential Revision: https://phab.mercurial-scm.org/D2746
Gregory Szorc <gregory.szorc@gmail.com> [Sat, 10 Mar 2018 10:44:56 -0800] rev 36854
hgweb: store and use request method on parsed request
PEP 3333 says that REQUEST_METHOD is always defined.
Differential Revision: https://phab.mercurial-scm.org/D2745
Gregory Szorc <gregory.szorc@gmail.com> [Sat, 10 Mar 2018 10:45:12 -0800] rev 36853
hgweb: handle CONTENT_LENGTH
PEP 3333 says CONTENT_LENGTH may be set. I /think/ WSGI servers are
allowed to invent this key even if the client didn't send it.
We had code in wireprotoserver looking for this key. So let's
just automagically convert this key to an HTTP request header
when parsing the request.
Differential Revision: https://phab.mercurial-scm.org/D2744
Gregory Szorc <gregory.szorc@gmail.com> [Thu, 08 Mar 2018 16:38:01 -0800] rev 36852
wireprotoserver: access headers through parsed request
Now that we can access headers via the parsed request object, let's
do that.
Since the new object uses bytes, hyphens, and is case-insensitive, a
bit of code around normalizing values has been removed. I think
the new code is much more intuitive because it more closely matches
what is going out over the wire.
Differential Revision: https://phab.mercurial-scm.org/D2743
Yuya Nishihara <yuya@tcha.org> [Mon, 12 Mar 2018 22:47:33 +0900] rev 36851
debugwireproto: close the write end before consuming all available data
And make it read all available data deterministically. Otherwise util.poll()
may deadlock because both stdout and stderr could have no data.
Spotted by the next patch which removes stderr from the fds.
Joerg Sonnenberger <joerg@bec.de> [Fri, 09 Mar 2018 15:57:16 +0100] rev 36850
graft: check for missing revision first before scanning working copy
Differential Revision: https://phab.mercurial-scm.org/D2753
Matt Harbison <matt_harbison@yahoo.com> [Sat, 10 Mar 2018 22:02:58 -0500] rev 36849
hook: ensure stderr is flushed when an exception is raised, for test stability
Windows has had issues with output order in test-ssh-proto-unbundle.t[1] since
it was created a few weeks ago. Each of the problems occurred when an exception
was thrown out of the hook.
Now the only thing blocking D2720 is the fact that the "abort: ..." lines on
stderr are totally AWOL. I have no idea where there are.
[1] https://buildbot.mercurial-scm.org/builders/Win7%20x86_64%20hg%20tests/builds/541/steps/run-tests.py%20%28python%202.7.13%29/logs/stdio
Gregory Szorc <gregory.szorc@gmail.com> [Sat, 10 Mar 2018 10:27:56 -0800] rev 36848
wireproto: raise ProgrammingError instead of Abort
This isn't a user-facing error and can only be caused by bad
Python code.
Thanks to Yuya for spotting this.
Differential Revision: https://phab.mercurial-scm.org/D2777
Yuya Nishihara <yuya@tcha.org> [Sat, 10 Mar 2018 19:56:47 +0900] rev 36847
py3: make test-commit-interactive.t byte-safe
Yuya Nishihara <yuya@tcha.org> [Sat, 10 Mar 2018 19:49:09 +0900] rev 36846
py3: open patch file in binary mode and convert eol manually
Here we don't introduce a reader wrapper since it wouldn't be easy to make
read(n) handle partial data and length correctly.
Yuya Nishihara <yuya@tcha.org> [Tue, 06 Mar 2018 07:45:57 -0600] rev 36845
py3: wrap file object to write patch in native eol preserving byte-ness
Yuya Nishihara <yuya@tcha.org> [Tue, 06 Mar 2018 07:24:12 -0600] rev 36844
py3: drop b'' from debug message "moving bookmarks"
Yuya Nishihara <yuya@tcha.org> [Sat, 10 Mar 2018 15:57:16 +0900] rev 36843
py3: use r'' instead of sysstr('') to get around code transformer
Fewer function calls should be better.
Yuya Nishihara <yuya@tcha.org> [Sat, 10 Mar 2018 15:50:09 +0900] rev 36842
ui: remove any combinations of CR|LF from prompt response
On Windows, we have to accept both CR+LF and LF. This patch simply makes
any trailing CRs and LFs removed from a user input instead of doing stricter
parsing, as an input must be a readable text.
Matt Harbison <matt_harbison@yahoo.com> [Sat, 10 Mar 2018 12:45:10 -0500] rev 36841
sshpeer: check pipe validity before forwarding output from it
After the previous fix, fileobjectproxy._observedcall() (called when
win32.peekpipe() accesses .fileno) started exploding. With this fix, similar
checks are needed inside debugwireproto(). Since that is hardcoded to not use
os.devnull, IDK if those are worth fixing.
Matt Harbison <matt_harbison@yahoo.com> [Sat, 10 Mar 2018 12:22:08 -0500] rev 36840
util: forward __bool__()/__nonzero__() on fileobjectproxy
In trying to debug the Windows process hang in D2720, I changed the stderr pipe
to the peer to be os.devnull instead. That caused sshpeer._cleanuppipes()[1] to
explode, complaining NoneType has no __iter__ attribute, even though the
previous line checked for None.
[1] https://www.mercurial-scm.org/repo/hg/file/b434965f984e/mercurial/sshpeer.py#l133
Yuya Nishihara <yuya@tcha.org> [Tue, 06 Mar 2018 07:16:41 -0600] rev 36839
py3: fix slicing of bisect label in templatefilters.shortbisect()
Yuya Nishihara <yuya@tcha.org> [Tue, 06 Mar 2018 07:15:01 -0600] rev 36838
templatefilters: inline hbisect.shortlabel()
It's pretty simple. I don't think the business logic has to be placed in
hbisect.py.
Yuya Nishihara <yuya@tcha.org> [Tue, 06 Mar 2018 07:11:24 -0600] rev 36837
py3: make test-bisect.t bytes-safe
Yuya Nishihara <yuya@tcha.org> [Tue, 06 Mar 2018 07:10:50 -0600] rev 36836
py3: fix integer formatting in bisect error
Yuya Nishihara <yuya@tcha.org> [Sat, 10 Mar 2018 16:55:54 +0900] rev 36835
py3: silence f.write() in test-annotate.t
Jun Wu <quark@fb.com> [Fri, 09 Mar 2018 14:52:36 -0800] rev 36834
xdiff: resolve signed unsigned comparison warning
Since the value won't be changed inside the code (because context lines
feature was removed by D2705), let's just remove the variable and inline
the 0 value.
The code might be potentially further simplified. But I'd like to make sure
correctness is easily verifiable in this patch.
Differential Revision: https://phab.mercurial-scm.org/D2766
Jun Wu <quark@fb.com> [Fri, 09 Mar 2018 14:47:29 -0800] rev 36833
xdiff: use int64 for hash table size
Follow-up of the previous "long" -> "int64" change. Now xdiff only uses int
for return values and small integers (ex. booleans, shifting score, bits in
hash table size, etc) so it should be able to handle large input.
Differential Revision: https://phab.mercurial-scm.org/D2765
Jun Wu <quark@fb.com> [Fri, 09 Mar 2018 14:39:35 -0800] rev 36832
xdiff: remove unused xpp and xecfg parameters
They are unused. Thus removed.
Differential Revision: https://phab.mercurial-scm.org/D2764
Jun Wu <quark@fb.com> [Fri, 09 Mar 2018 14:37:55 -0800] rev 36831
xdiff: remove unused flags parameter
After D2683, the flags parameter in some functions is no longer needed.
Thus removed.
Differential Revision: https://phab.mercurial-scm.org/D2763
Jun Wu <quark@fb.com> [Fri, 09 Mar 2018 14:24:27 -0800] rev 36830
xdiff: replace {unsigned ,}long with {u,}int64_t
MSVC treats "long" as 4-byte. That could cause overflows since the xdiff
code uses "long" in places where "size_t" or "ssize_t" should be used.
Let's use explicit 8 byte integers to avoid
FWIW git avoids that overflow by limiting diff size to 1GB [1]. After
examining the code, I think the remaining risk (the use of "int") is low
since "int" is only used for return values and hash table size. Although a
wrong hash table size would not affect the correctness of the code, but that
could make the code extremely slow. The next patch will change hash table
size to 8-byte integer so the 1GB limit is unlikely needed.
This patch was done by using `sed`.
[1]: https://github.com/git/git/commit/dcd1742e56ebb944c4ff62346da4548e1e3be67
Differential Revision: https://phab.mercurial-scm.org/D2762
Jun Wu <quark@fb.com> [Sun, 04 Mar 2018 11:30:16 -0800] rev 36829
xdiff: add comments for fields in xdfile_t
This makes the related code easier to understand.
Differential Revision: https://phab.mercurial-scm.org/D2685
Jun Wu <quark@fb.com> [Wed, 07 Mar 2018 14:45:31 -0800] rev 36828
xdiff: add a preprocessing step that trims files
xdiff has a `xdl_trim_ends` step that removes common lines, unmatchable
lines. That is in theory good, but happens too late - after splitting,
hashing, and adjusting the hash values so they are unique. Those splitting,
hashing and adjusting hash values steps could have noticeable overhead.
Diffing two large files with minor (one-line-ish) changes are not uncommon.
In that case, the raw performance of those preparation steps seriously
matter. Even allocating an O(N) array and storing line offsets to it is
expensive. Therefore my previous attempts [1] [2] cannot be good enough
since they do not remove the O(N) array assignment.
This patch adds a preprocessing step - `xdl_trim_files` that runs before
other preprocessing steps. It counts common prefix and suffix and lines in
them (needed for displaying line number), without doing anything else.
Testing with a crafted large (169MB) file, with minor change:
```
open('a','w').write(''.join('%s\n' % (i % 100000) for i in xrange(30000000) if i != 6000000))
open('b','w').write(''.join('%s\n' % (i % 100000) for i in xrange(30000000) if i != 6003000))
```
Running xdiff by a simple binary [3], this patch improves the xdiff perf by
more than 10x for the above case:
```
# xdiff before this patch
2.41s user 1.13s system 98% cpu 3.592 total
# xdiff after this patch
0.14s user 0.16s system 98% cpu 0.309 total
# gnu diffutils
0.12s user 0.15s system 98% cpu 0.272 total
# (best of 20 runs)
```
It's still slightly slower than GNU diffutils. But it's pretty close now.
Testing with real repo data:
For the whole repo, this patch makes xdiff 25% faster:
```
# hg perfbdiff --count 100 --alldata -c d334afc585e2 --blocks [--xdiff]
# xdiff, after
! wall 0.058861 comb 0.050000 user 0.050000 sys 0.000000 (best of 100)
# xdiff, before
! wall 0.077816 comb 0.080000 user 0.080000 sys 0.000000 (best of 91)
# bdiff
! wall 0.117473 comb 0.120000 user 0.120000 sys 0.000000 (best of 67)
```
For files that are long (ex. commands.py), the speedup is more than 3x, very
significant:
```
# hg perfbdiff --count 3000 --blocks commands.py.i 1 [--xdiff]
# xdiff, after
! wall 0.690583 comb 0.690000 user 0.690000 sys 0.000000 (best of 12)
# xdiff, before
! wall 2.240361 comb 2.210000 user 2.210000 sys 0.000000 (best of 4)
# bdiff
! wall 2.469852 comb 2.440000 user 2.440000 sys 0.000000 (best of 4)
```
[1]: https://phab.mercurial-scm.org/D2631
[2]: https://phab.mercurial-scm.org/D2634
[3]:
```
// Code to run xdiff from command line. No proper error handling.
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "mercurial/thirdparty/xdiff/xdiff.h"
#define ensure(x) if (!(x)) exit(255);
mmfile_t readfile(const char *path) {
struct stat st; int fd = open(path, O_RDONLY);
fstat(fd, &st); mmfile_t file = { malloc(st.st_size), st.st_size };
ensure(read(fd, file.ptr, st.st_size) == st.st_size); close(fd);
return file;
}
int main(int argc, char const *argv[]) {
mmfile_t a = readfile(argv[1]), b = readfile(argv[2]);
xpparam_t xpp = {0}; xdemitconf_t xecfg = {0}; xdemitcb_t ecb = {0};
xdl_diff(&a, &b, &xpp, &xecfg, &ecb);
return 0;
}
```
Differential Revision: https://phab.mercurial-scm.org/D2686
Martin von Zweigbergk <martinvonz@google.com> [Fri, 09 Mar 2018 14:30:15 -0800] rev 36827
transaction: add a name and a __repr__ implementation (API)
This has been useful for me for debugging.
Differential Revision: https://phab.mercurial-scm.org/D2758
Joerg Sonnenberger <joerg@bec.de> [Fri, 09 Mar 2018 16:10:55 +0100] rev 36826
phabricator: update doc string for deprecated token argument
Differential Revision: https://phab.mercurial-scm.org/D2755
Joerg Sonnenberger <joerg@bec.de> [Fri, 09 Mar 2018 16:09:27 +0100] rev 36825
phabricator: print deprecation warning only once
Differential Revision: https://phab.mercurial-scm.org/D2754
Martin von Zweigbergk <martinvonz@google.com> [Thu, 08 Mar 2018 21:17:26 -0800] rev 36824
tests: add a few tests involving --collapse and rebase.singletransaction=1
I'm about to change the rebase code quite a bit and this was poorly
tested.
Differential Revision: https://phab.mercurial-scm.org/D2757
Martin von Zweigbergk <martinvonz@google.com> [Thu, 08 Mar 2018 20:55:51 -0800] rev 36823
tests: simplify test-rebase-transaction.t
The file was extracted from test-rebase-base.t in 8cef8f7d51d0
(test-rebase-base: clarify it is about the "--base" flag,
2017-10-05). This patch follows up that and clarifies the new file's
purpose and simplifies it a bit.
Differential Revision: https://phab.mercurial-scm.org/D2756
Gregory Szorc <gregory.szorc@gmail.com> [Thu, 08 Mar 2018 16:22:25 -0800] rev 36822
hgweb: parse and store HTTP request headers
WSGI transmits HTTP request headers as HTTP_* environment variables.
We teach our parser about these and hook up a dict-like data
structure that supports case insensitive header manipulation.
Differential Revision: https://phab.mercurial-scm.org/D2742
Gregory Szorc <gregory.szorc@gmail.com> [Thu, 08 Mar 2018 16:43:32 -0800] rev 36821
wireprotoserver: remove broken optimization for non-httplib client
There was an experimental non-httplib client in core for several
years. It was removed a week or so ago.
We kept the optimization for this client in the server code. I'm
not sure if that was intended or not. But it doesn't matter: the
code was wrong.
Because the code was accessing a WSGI environment dict, it needed to
access the HTTP_X_HGHTTP2 key to actually read the HTTP header. So
the code deleted by this commit wasn't actually doing anything
meaningful. Doh.
Differential Revision: https://phab.mercurial-scm.org/D2741
Gregory Szorc <gregory.szorc@gmail.com> [Thu, 08 Mar 2018 15:58:52 -0800] rev 36820
wireprotoserver: move all wire protocol handling logic out of hgweb
Previous patches from several days ago worked to isolate processing
of HTTP wire protocol requests to wireprotoserver. We still had a
little logic in hgweb. If feels like the right time to finish the
job.
This commit moves WSGI request servicing from hgweb to wireprotoserver.
The ugly dict holding the parsed request is no more. I think the new
code is cleaner.
As part of this, we now process wire protocol requests before the
block to obtain the "query" variable. This makes it clear that this
wonky "query" variable is not used by the wire protocol.
The wonkiest part about this code is the HTTP 404. I'm actually not
sure what all is going on here. It looks like the code is trying to
prevent URL with path components that specify a command from not
working. That part I grok. What I don't grok is why we need to send
a 404. I would think it would be OK to no-op and let another handler
try to service the request. But if we do this, we get some subrepo
test failures. So it looks like something is expecting the HTTP 404
and reacting to it in a specific way. It /might/ be possible to
change the behavior here. But it isn't something I'm comfortable
doing because I don't understand the problem space.
Differential Revision: https://phab.mercurial-scm.org/D2740
Gregory Szorc <gregory.szorc@gmail.com> [Thu, 08 Mar 2018 15:37:05 -0800] rev 36819
hgweb: use parsed request to construct query parameters
The way hgweb routes requests is kind of bonkers. If PATH_INFO is
set, we take the URL path after the repository. Otherwise, we take
the first part of the query string before "&" and the part before
";" in that.
We then kinda/sorta treat this as a path and route based on that.
This commit ports that code to use the parsed request object. This
required a new attribute on the parsed request to indicate whether
there is any PATH_INFO.
The new code still feels a bit convoluted for my liking. But we'll
need to rewrite more of the code before a better solution becomes
apparant. This code feels strictly better since we're no longer
doing low-level WSGI manipulation during routing.
Differential Revision: https://phab.mercurial-scm.org/D2739
Gregory Szorc <gregory.szorc@gmail.com> [Thu, 08 Mar 2018 11:33:33 -0800] rev 36818
hgweb: only recognize wire protocol commands from query string (BC)
Previously, we attempted to parse the wire protocol command from
`req.form`. Data could have come from the query string or POST
form data.
The wire protocol states that the command must be declared in the
query string. And AFAICT all Mercurial releases from at least 1.0
send the command in the query string.
So let's actual require this behavior.
This is technically BC. But I'm not sure how anyone in the wild
would encounter this. POST has historically been used for sending
bundle data. So there's no opportunity to encode arguments there.
And the experimental HTTP POST args also takes over the body. So
the only way someone would be impacted by this is if they wrote
a custom client that both used POST for everything and sent arguments
via the HTTP body. I don't believe such a client exists.
.. bc::
The HTTP wire protocol server no longer accepts the ``cmd``
argument to control which command to run via HTTP POST bodies.
The ``cmd`` argument must be specified on the URL query string.
Differential Revision: https://phab.mercurial-scm.org/D2738
Gregory Szorc <gregory.szorc@gmail.com> [Thu, 08 Mar 2018 11:21:46 -0800] rev 36817
hgweb: teach WSGI parser about query strings
Currently, req.form uses cgi.parse() to populate form data. Depending
on the request, form data can come from POST multipart/form-data,
application/x-www-form-urlencoded, or the URL query string.
Putting all these things into one data structure makes it difficult
to reason about how exactly parameters got to the request. It can
lead to wonkiness such as pulling parameters from both the URL and
POST data.
This commit teaches our WSGI request parser about argument data
in query strings. We populate fields containing the query string
data and only the query string data so it can't be confused with
POST data.
Differential Revision: https://phab.mercurial-scm.org/D2737
Gregory Szorc <gregory.szorc@gmail.com> [Thu, 08 Mar 2018 15:08:20 -0800] rev 36816
hgweb: use the parsed application path directly
Previously, we assigned a custom system string with a trailing slash
to wsgirequest.url.
The addition of the trailing slash felt arbitrary and seems to go
against how things typically work in WSGI.
We also want our URLs to be bytes, not system strings.
And, assigning a custom attribute to wsgirequest felt wrong.
This commit fixes all those things by removing the trailing
slash from the app path, changing consumers to use that variable
and to use it without a trailing slash, and removing the custom
attribute from wsgirequest.
We preserve the trailing slash on {url}. Also, makebreadcrumb
strips the trailing slash. So no change to it was needed.
Differential Revision: https://phab.mercurial-scm.org/D2736
Gregory Szorc <gregory.szorc@gmail.com> [Thu, 08 Mar 2018 12:59:25 -0800] rev 36815
hgweb: use computed base URL from parsed request
Let's not reinvent URL construction in a function that runs the
templater.
Differential Revision: https://phab.mercurial-scm.org/D2735
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
Yuya Nishihara <yuya@tcha.org> [Sun, 04 Mar 2018 15:53:10 -0500] rev 36754
py3: don't use str() to stringify pushloc
Yuya Nishihara <yuya@tcha.org> [Sun, 04 Mar 2018 15:26:26 -0500] rev 36753
py3: byte-stringify test-config.t and test-config-env.py
Yuya Nishihara <yuya@tcha.org> [Sun, 04 Mar 2018 15:24:45 -0500] rev 36752
py3: use startswith() instead of slicing to detect leading whitespace
Augie Fackler <augie@google.com> [Sun, 04 Mar 2018 16:06:47 -0500] rev 36751
archival: use py3 friendly replacements for chr() and long()
Differential Revision: https://phab.mercurial-scm.org/D2673
Augie Fackler <augie@google.com> [Sun, 04 Mar 2018 16:06:27 -0500] rev 36750
archival: ensure file mode for gzipfile is sysstr
Differential Revision: https://phab.mercurial-scm.org/D2672
Augie Fackler <augie@google.com> [Sun, 04 Mar 2018 16:06:10 -0500] rev 36749
archival: fix a missing r'' on a kwargs check
# skip-blame just an r prefix
Differential Revision: https://phab.mercurial-scm.org/D2671
Augie Fackler <augie@google.com> [Sun, 04 Mar 2018 16:05:44 -0500] rev 36748
py3: more passing tests (ten this time)
Differential Revision: https://phab.mercurial-scm.org/D2670
Augie Fackler <augie@google.com> [Sun, 04 Mar 2018 15:55:55 -0500] rev 36747
util: fix unsafe url abort with bytestr() on url
Differential Revision: https://phab.mercurial-scm.org/D2669
Matt Harbison <matt_harbison@yahoo.com> [Sun, 04 Mar 2018 15:16:42 -0500] rev 36746
xdiff: fix builds on Windows
This works on my ancient Fedora system too, without warnings. There are,
however, warnings about various 64 to 32 bit conversions on Windows that need to
be examined.