Commit Graph

34570 Commits

Author SHA1 Message Date
Augie Fackler
7914273147 wireproto: use listcomp instead of map()
The latter returns a generator object on Python 3, which breaks
various parts of hg that expected a list.

Differential Revision: https://phab.mercurial-scm.org/D1100
2017-10-15 00:39:29 -04:00
Augie Fackler
e90604cb5e dagutil: use a listcomp instead of a map()
In Python 3, the map() returns a generator object instead of a list,
and some parts of hg depend on this being consumable more than once or
sortable in place.

Differential Revision: https://phab.mercurial-scm.org/D1099
2017-10-15 00:37:24 -04:00
Augie Fackler
510310c11a peer: when collecting method names for batch calls, bytes-ify __name__
This will explode violently if we have a non-ascii command name. That
shouldn't ever happen in core, and seems unlikely even in third-party
code. Regardless, it'll explode violently, so we can revisit things in
the future if we need to change the encoding here.

Differential Revision: https://phab.mercurial-scm.org/D1092
2017-10-14 12:03:42 -04:00
Augie Fackler
6509db2306 python3: replace im_{self,func} with __{self,func}__ globally
These new names are portable back to Python 2.6.

Differential Revision: https://phab.mercurial-scm.org/D1091
2017-10-14 12:02:15 -04:00
Augie Fackler
e5d72894dc httppeer: extract content-type from headers using native str
Differential Revision: https://phab.mercurial-scm.org/D1090
2017-10-14 12:00:35 -04:00
Augie Fackler
74dcc6aa29 httppeer: convert request url back to bytes before inspecting it
Differential Revision: https://phab.mercurial-scm.org/D1089
2017-10-14 11:59:51 -04:00
Augie Fackler
ffc31606d6 templater: explode if we try to emit a str
Without this if branch, we infinitely recurse in _flatten, which is
very confusing. Something in an hgweb template is trying to write out
a string instead of a bytes on Python 3, and this at least makes it
crash politely.

Differential Revision: https://phab.mercurial-scm.org/D1088
2017-10-14 11:30:17 -04:00
Augie Fackler
1eb0868158 hgweb: fill in content-type and content-length as native strings
This lets me actually get a capabilities response from hgweb over
http.

Differential Revision: https://phab.mercurial-scm.org/D1087
2017-10-14 11:20:31 -04:00
Augie Fackler
d3a0083e45 hgweb: mimetype guessing needs a unicode path
Differential Revision: https://phab.mercurial-scm.org/D1086
2017-10-14 10:47:29 -04:00
Augie Fackler
dfaf4b98bc hgweb: set sent_headers attr as early as practical
While doing Python 3 porting work, I've seen exceptions happen in
parts of hgweb we normally assume are robust. It won't hurt anything
to set this attribute significantly earlier, so let's do so and save
confusing during the porting process.

Differential Revision: https://phab.mercurial-scm.org/D1085
2017-10-14 15:37:33 -04:00
Augie Fackler
caec472139 hgweb: detect Python 3-era libraries and use modern attribute names
Differential Revision: https://phab.mercurial-scm.org/D1084
2017-10-05 14:53:52 -04:00
Augie Fackler
1f7e395752 server: indent block that's about to get conditionalized
Differential Revision: https://phab.mercurial-scm.org/D1083
2017-10-14 15:53:36 -04:00
Yuya Nishihara
62122f42ea templates: fix missed space between instability labels 2017-10-14 18:41:20 +09:00
Yuya Nishihara
0e862d288f templates: introduce labelcset() function in map-cmdline.default as example 2017-10-14 18:24:01 +09:00
Yuya Nishihara
550442a9eb templater: load aliases from [templatealias] section in map file
This seems sometimes useful as an alias can be a function, but a template
fragment can't.
2017-10-14 18:06:42 +09:00
Yuya Nishihara
994c332a3b templater: load template fragments from [templates] section in map file
This allows us to %include map-cmdline.<style> file in our .hgrc files. The
syntax is slightly different as hgrc doesn't support loading an external
template file, but map-cmdline files don't use this feature, so the syntax
can be considered identical in practice.

Unnamed section is remapped for backward compatibility.
2017-10-14 17:51:01 +09:00
Yuya Nishihara
615ab8c775 config: allow remapping the default section
The next patch depends on it. It doesn't make sense that the default section
can't be remapped with {'': whatever}.
2017-10-14 17:41:41 +09:00
Yuya Nishihara
e2e58c1839 templater: simplify merge of __base__ dicts by reading it first 2016-08-20 18:33:02 +09:00
Boris Feld
3905794a8c phase: add a dedicated pretxnclose-phase hook
This new hook mirror the newly introduced 'txnclose-phase' but can abort the
transaction.
2017-10-08 17:23:18 +02:00
Boris Feld
5dfba786e8 phase: add a dedicated txnclose-phase hook
The new 'txnclose-phase' hook expose the phase movement information stored in
'tr.changes['phases]'. To provide a simple and straightforward hook API to the
users, we introduce a new hook called for each revision affected.  Since a
transaction can affect the phase of multiple changesets, updating the existing
'txnclose' hook to expose that information would be more complex. The data for
all moves will not fit in environment variables and iterations over each move
would be cumbersome. So the introduction of a new dedicated hook is
preferred in this changesets.

This does not exclude the addition of the full phase movement information to
the existing 'txnclose' in the future to help write more complex hooks.
2017-10-08 17:50:46 +02:00
Boris Feld
db2e8fadae bookmark: add a dedicated pretxnclose-bookmark hook
This new hook mirror the newly introduced 'txnclose-bookmark' but can abort the
transaction.
2017-10-08 18:50:14 +02:00
Boris Feld
4815e3ce8d bookmark: add a dedicated txnclose-bookmark hook
The new 'txnclose-bookmark' hook expose the bookmark movement information
stored in 'tr.changes['bookmarks]'. To provide a simple and straightforward
hook API to the users, we introduce a new hook called for each bookmark
touched. Since a transaction can affect multiple bookmarks, updating the
existing 'txnclose' hook to expose that information would be more complex. The
data for all moves might not fit in environment variables and iterations over
each move would be cumbersome. So the introduction of a new dedicated hook is
preferred in this changeset.

This does not exclude the addition to the full bookmark information to the
existing 'txnclose' in the future to help write more complex hooks.
2017-10-10 17:53:42 +02:00
Augie Fackler
83f88ecb85 tweakdefaults: make commands.update.check be noconflict
This is the second-safest option we have to offer in `updatecheck`,
with `abort` being the safest and `linear` being the default. At the
sprint we discussed how much `none` and `linear` make us all
uncomfortable, and how we'd like to move the default behavior if we can.

I'm not sure we can get away with actually changing the out of the box
default behavior, but we can at *least* do this.

Differential Revision: https://phab.mercurial-scm.org/D1062
2017-10-13 15:58:54 -04:00
Augie Fackler
bc69639184 hgweb: fix logging to use native strings as appropriate
Kind of a tangled mess, but now logging works in both Python 2 and 3.

# no-check-commit because of the interface required by Python's HTTP
server code.

Differential Revision: https://phab.mercurial-scm.org/D1080
2017-10-14 15:43:06 -04:00
Augie Fackler
2fea5f41d1 config: graduate experimental.updatecheck to commands.update.check
.. feature::

  New `commands.update.check` feature to adjust constraints on when
  `hg update` will allow updates with a dirty working copy.

also

.. bc::

    The `experimental.updatecheck` name for the new `commands.update.check`
    feature is now deprecated, and will be removed after this release.

Differential Revision: https://phab.mercurial-scm.org/D1070
2017-10-14 03:13:50 -04:00
Augie Fackler
3327fe780e hgweb: rewrite most obviously-native-strings to be native strings
This clearly won't be everything, but it unblocks a fair amount of
stuff here.

Differential Revision: https://phab.mercurial-scm.org/D1079
2017-10-14 15:42:38 -04:00
Augie Fackler
9f097cd648 hgweb: use native strings consistently for querystring parsing
Differential Revision: https://phab.mercurial-scm.org/D1078
2017-10-05 14:48:52 -04:00
Augie Fackler
4fec03fc61 hgweb: rewrite two X or Y and Z ad-hoc ternaries with Y if X else Z
Just easier to muddle through for my brain now that I don't see the
old pattern much anymore.

Differential Revision: https://phab.mercurial-scm.org/D1077
2017-10-05 14:48:31 -04:00
Augie Fackler
14c0f38685 httppeer: use native strings for headers
On Python 3, we need to use unicodes, rather than bytes. This lets
test-pull.t get a lot further along.

Differential Revision: https://phab.mercurial-scm.org/D887
2017-10-01 12:12:34 -04:00
Augie Fackler
58adac28f6 hgweb: more native string treatment in query string parsing
Differential Revision: https://phab.mercurial-scm.org/D1076
2017-10-05 14:29:51 -04:00
Augie Fackler
97ea947740 httppeer: pass url to urllib as native str, not bytes
Differential Revision: https://phab.mercurial-scm.org/D1075
2017-10-14 14:07:39 -04:00
Denis Laxalde
6c2c086e11 tersestatus: rework dirnode and tersedir docstrings
Follow-up on refactorings 6a96abee0045 and b8c13fc92233 of the original
changeset 8c58ee1e5fa4 by updating the docstrings of dirnode class and tersedir
function:

* rewrite dirnode.iterfilepaths()'s docstring (the method got
  renamed and reimplemented in b8c13fc92233);
* simplify and update dirnode.tersewalk() to remove reference to 'self' and
  'tersedict';
* use the imperative form of verbs in the first sentence of all docstrings.

Differential Revision: https://phab.mercurial-scm.org/D1072
2017-10-14 13:33:37 +02:00
Augie Fackler
714a44cc5e bitmanipulation: reformat with clang-format
Mostly un-wrapping over-wrapped definitions.

Differential Revision: https://phab.mercurial-scm.org/D1069
2017-10-04 10:52:50 -04:00
Augie Fackler
e06dbb26d0 hghave: add a check for clang-format
Differential Revision: https://phab.mercurial-scm.org/D1068
2015-09-14 14:16:31 -04:00
Augie Fackler
a67386352a python3: use our bytes-only version of cgi.escape everywhere
As suggested by Yuya in D965.

Differential Revision: https://phab.mercurial-scm.org/D1067
2017-10-05 14:16:20 -04:00
Augie Fackler
5167a44c70 url: add cgi.escape equivalent for bytestrings
This seems like a sensible enough place to put it.

Differential Revision: https://phab.mercurial-scm.org/D1066
2017-10-14 02:57:26 -04:00
Augie Fackler
a4bc1fe43c python3: move from using func_name to __name__
Previously reviewed as D964, but required some fixups and therefore
seems to need a new revision.

Differential Revision: https://phab.mercurial-scm.org/D1065
2017-10-05 14:15:05 -04:00
Matt Harbison
c1087ae158 tests: add globs for Windows 2017-10-14 01:20:12 -04:00
Matt Harbison
f3e987661c test-conflicts: conditionalize for no-symlink platforms
It seems better to create standin files for the symlinks, rather than blacklist
the entire tests.  Especially since link vs file doesn't seem to affect the
tests.

There is more instability in test-pathconflicts-{basic,merge}.t that I can't
figure out.
2017-10-14 01:07:59 -04:00
Matt Harbison
773c9a551d test-extdata: conditonalize error message for Windows 2017-10-14 00:20:59 -04:00
Matt Harbison
95f6e46463 test-audit-path: fill in missing output for no-symlink case
It looks like this was meant to go with bf9ade12e62e.
2017-10-14 00:07:26 -04:00
Yuya Nishihara
74b6f75047 test-i18n: guard gettext test appropriately 2017-10-14 13:37:14 +09:00
Boris Feld
00846dabc6 hook: add a 'hashook' function to test for hook existence
Preparing the data for some hooks can be expensive. Add a function to check if
a hook exists so we can skip useless preparation if no hook is configured.
2017-10-08 13:08:31 +02:00
muxator
66d556e57b build: for the bootstrap phase of a deb/rpm build pure-py mercurial is enough
When bootstrapping a deb/rpm build, packagelib.sh starts performing a local
build for the sole purpose of parsing the output of "hg version".
Then it "hg archive"s the source code, and builds everything again.

For that initial step, we are perfectly good in using a pure python mercurial,
without compiling the c modules (base85, bdiff, zstdlib, ...).

On my personal system, this cuts down 22 seconds for a package build (the
bootstrapping build goes from ~30 to ~8 seconds).
2017-10-13 22:42:17 +02:00
Phil Cohen
0d0a416a27 context: add a fast-comparision for arbitraryfilectx and workingfilectx
Differential Revision: https://phab.mercurial-scm.org/D1056
2017-10-13 12:40:05 -07:00
Denis Laxalde
6ff583b949 tersestatus: avoid modifying tersedict
Turn dirnode's methods into generators which can be used to update "tersedict"
in caller. So instead of passing the "tersedict" to be mutated here and there,
it's now clearer where it is updated as it's purely a local variable to
tersedir() function.

While I was here, I renamed _processtersestatus to tersewalk and
_addfilestotersed to iterfilepaths.

Differential Revision: https://phab.mercurial-scm.org/D1043
2017-10-13 04:02:06 +05:30
Denis Laxalde
e623051ee4 tersestatus: make methods part of the dirnode class
Differential Revision: https://phab.mercurial-scm.org/D1042
2017-10-11 21:19:19 +02:00
Pulkit Goyal
4b9eb4d057 tersestatus: re-implement the functionality to terse the status
The previous terse status implementation was hacking around os.listdir() and was
flaky. There have been a lot of instances of mercurial buildbots failing
and google's internal builds failing because of the
hacky implementation of terse status. Even though I wrote the last
implementation but it was hard for me to find the reason for the flake.

The new implementation can be slower than the old one but is clean and easy to
understand.

In this we create a node object for each directory and create a tree
like structure starting from the root of the working copy. While building the
tree like structure we store some information on the nodes which will be helpful
for deciding later whether we can terse the dir or not.
Once the whole tree is build we traverse and built the list of files for each
status with required tersing.

There is no behaviour change as the old test, test-status-terse.t passes with
the new implementation.

Differential Revision: https://phab.mercurial-scm.org/D985
2017-10-06 20:54:23 +05:30
Phil Cohen
b6042b5881 context: add is isinmemory() to filectx
This will make it easier to skip certain behavior when running an in-memory
merge.

Differential Revision: https://phab.mercurial-scm.org/D1061
2017-10-13 12:54:46 -07:00
Ryan McElroy
25aff2d866 merge: ensure that we always commit the mergestate
In future patches, we may halt the merge process based on configuration or
user requests by raising exceptions. We need to ensure that the mergestate
is unconditionally committed even when such an exception is raised.

Depends on D930.

Differential Revision: https://phab.mercurial-scm.org/D931
2017-10-06 06:48:43 -07:00