Commit Graph

29855 Commits

Author SHA1 Message Date
Simon Farnsworth
c7fbc87ac7 template: provide a termwidth keyword (issue5395)
We want to provide terminal-sized output. As a starting point, expose the
terminal width to the templater for use in things like fill.
2016-10-08 02:26:48 -07:00
Augie Fackler
10de2c7e4f util: ensure forwarded attrs are set in globals() as sysstr
Custom module importer strikes again.
2016-10-08 08:36:39 -04:00
Augie Fackler
867b91b167 pycompat: when setting attrs, ensure we use sysstr
The custom module importer was making these bytes, so when we poked
values into self.__dict__ we had bytes instead of unicode on py3 and
it didn't work.
2016-10-08 08:35:43 -04:00
Augie Fackler
968375bf81 i18n: make the locale directory name the same string type as the datapath 2016-10-08 05:26:18 -04:00
Augie Fackler
5a5f1c4d36 contributing: add new file with a pointer to the wiki
This also includes what I consider to be the minimum set of steps
someone should be able to perform even if they can't run the
testsuite. Hopefully this will help new contributors know to at least
run the two checkers that find most things that (in my experience)
require manual cleanup.
2016-10-08 10:39:00 -04:00
Yuya Nishihara
5196f3da90 templater: add relpath() to convert repo path to relative path (issue5394)
File paths in template are repository-absolute paths. This function can be
used to convert them to filesystem paths relative to cwd. This also converts
'/' to '\\' on Windows.
2016-10-08 15:24:26 +02:00
Martijn Pieters
de1f10a894 hgweb: fix the MRO in Python 3
object should appear at the end, otherwise it tries to pre-empt the other
new-style classes in the MRO, resulting in an unresolvable MRO in Py3. We still
need to include object because otherwise in 2.7 we end up with an old-style
class if threading is not supported, new-style if it is.
2016-10-08 19:11:19 +02:00
Jun Wu
a68511813b hgweb: make fctx.annotate a separated function so it could be wrapped
This patch moves "fctx.annotate" used by the "annotate" webcommand, along
with the diffopts to a separated function which takes a ui and a fctx.
So it could be replaced by other implementations which don't want to replace
the core "fctx.annotate" directly.
2016-10-08 16:10:34 +01:00
Anton Shestakov
36cf1f5e53 zsh_completion: update some option usage flags ('+', '=' and ':')
Here are the relevant symbol descriptions from [0]

optspec:...
  The colon indicates handling for one or more arguments to the option; if it
  is not present, the option is assumed to take no arguments.

-optname+
  The first argument may appear immediately after optname in the same word,
  or may appear as a separate word after the option. For example, ‘-foo+:...’
  specifies that the completed option and argument will look like either
  ‘-fooarg’ or ‘-foo arg’.

-optname=
  The argument may appear as the next word, or in same word as the option
  name provided that it is separated from it by an equals sign, for example
  ‘-foo=arg’ or ‘-foo arg’.

There are 3 types of changes in this patch:

- addition of '=': means that '--repository ~/foo' can now also be spelled as
  '--reporitory=~/foo'

- addition of '+': means '-r 0' can now also be spelled as '-r0'

- removal of '+', '=' and ':': means that '-u|--untrusted' doesn't take any
  arguments, so '-uq' is definitely '-u -q' and not '--untrusted=q'

Occasionally, ':' had to be added together with '=' and '+'.

This patch is mostly just making zsh_completion file look more like zsh's own
hg completion file so that we can more easily take improvements from them or
send patches to them. Some context for this patch from zsh project: [2] [3].

[0]: http://zsh.sourceforge.net/Doc/Release/Completion-System.html
[1]: https://sourceforge.net/p/zsh/code/ci/master/tree/Completion/Unix/Command/_hg
[2]: 92584634d3/
[3]: http://www.zsh.org/mla/workers/2015/msg02551.html
2016-10-04 20:49:59 +08:00
Gregory Szorc
552458f2ca manifest: drop Py_TPFLAGS_HAVE_SEQUENCE_IN from tp_flags in Python 3
This flag disappeared in Python 3. It is only necessary in Python 2,
apparently.
2016-10-08 18:04:57 +02:00
Ryan McElroy
eabf9d1003 import: abort instead of crashing when copy source does not exist (issue5375)
Previously, when a patch contained a move or copy from a source that did not
exist, `hg import` would crash. This patch changes import to raise a PatchError
with an explanantion of what is wrong with the patch to avoid the stack trace
and bad user experience.
2016-10-08 05:26:58 -07:00
Mateusz Kwapich
c9434eddcf py3: make encodefun in store.py compatible with py3k
This ensures that the filename encoding functions always map bytestrings
to bytestrings regardless of python version.
2016-10-08 08:54:05 -07:00
Mateusz Kwapich
411ad51cc8 py3: make the string unicode so its iterable in py3k 2016-10-08 08:45:28 -07:00
Gábor Stefanik
8d5c0019c5 copies: don't record divergence for files needing no merge
This is left over from when _checkcopies was factored out from mergecopies.

The 2nd break has "of = None" before it, so it's a functionally equivalent
change. The 1st one, however, causes a divergence to be recorded when
a file has been renamed, but there is nothing to be merged to it.

This is currently harmless, since the extra divergence is simply ignored
later. However, the new _checkcopies introduced in the rest of this series
does more than just record a divergence after completing the main loop,
and it's important that the "post-processing" stage is really skipped
for no-merge-needed renames.
2016-10-03 13:29:59 +02:00
Tooru Fujisawa
2c9ec77e6d hgweb: avoid line wrap between revision and annotate-info (issue5398)
Add white-space: nowrap to td.annotate to avoid wrapping div.annotate-info
into next line if there is revision number in the same cell, as it is hard to
mouse over div.annotate-info if it's wrapped into next line.
2016-10-08 19:32:54 +09:00
Pulkit Goyal
e4b15b1b8c py3: make format strings unicodes and not bytes
Fixes issues on Python 3, wherein docstrings are unicodes.
Shouldn't break anything on Python 2.
2016-10-08 16:10:58 +02:00
Pulkit Goyal
5df46f7e20 mail: handle renamed email.Header
We are still using email.Header which was renamed to email.header back in
Python 2.5. References: https://hg.python.org/cpython/file/2.4/Lib/email
and https://hg.python.org/cpython/file/2.5/Lib/email
2016-10-07 17:30:11 +02:00
Augie Fackler
efaaf08415 revset: build _syminitletters from a saner source: the string module
For now, these sets will be unicode characters in Python 3, which is
probably wrong, but it un-blocks importing the module so we can get
further along. In the future we'll have to come up with a reasonable
encoding strategy for revsets in Python 3.

This patch was originally pair-programmed with Martijn.
2016-10-07 08:32:40 -04:00
Pierre-Yves David
0d0d0a7af9 mq: release lock after transaction in qrefresh
The transaction should be closed within the lock.
2016-08-11 15:05:17 +02:00
Pierre-Yves David
21997e4a02 perf: release lock after transaction in perffncachewrite
The transaction should be closed within the lock.
2016-08-11 14:51:19 +02:00
Pierre-Yves David
8b00f799de pull: grab wlock during pull
because pull might move bookmarks and bookmark are protected by wlock, we have
to grab wlock for pull :-(

This required a small upgrade of the 'lockdelay' extension used by
'test-clone.t' because the delay must apply to a single lock only.
2016-08-23 23:47:59 +02:00
Pierre-Yves David
452cc705b7 bisect: move 'printresult' in the 'hbisect' module
The logic is already extracted into a closure. We move it into the module
dedicated to bisect.

A minor change is applied: the creation of the 'displayer' is kept in the main
command function, it remove the needs to import 'cmdutil' in 'hbisect'. This
would create an import circle otherwise.
2016-08-24 04:19:11 +02:00
Pierre-Yves David
88806a61a8 bisect: move the 'extendrange' to the 'hbisect' module
We have a module ready to host any bisect logic. That logic was already isolated
in a function so we just migrate it as is.
2016-08-24 04:16:07 +02:00
Pierre-Yves David
8a0460c873 bisect: extract the 'reset' logic into its own function
This is part of small clean up movement. The bisect module seem more appropriate
to host the bisect logic. The cleanup itself is motivated by some higher level
cleanup around vfs and locking.
2016-08-24 04:13:53 +02:00
Pierre-Yves David
8e48e80491 bisect: access the filesystem through vfs when reseting
We have nice and shiny abstractions now.
2016-08-24 04:31:49 +02:00
Martijn Pieters
c065b86af4 util: remove the copypasta unquote function
The _urlunquote function was added back in the day to improve startup
performance, but this version is a) not compatible with Python 3 and b) has
quadratic performance issues that Python core solved eons ago.

Moreover, the function moved from urllib to urlparse (cheaper to import) *and*
that module is already imported into pycompat. As a result, removing this
function improves perf now.

Before:

! wall 0.066773 comb 0.000000 user 0.000000 sys 0.000000 (best of 100)

After:

! wall 0.065990 comb 0.000000 user 0.000000 sys 0.000000 (best of 100)
2016-10-07 17:06:55 +02:00
Simon Farnsworth
3622717b76 merge: add conflict labels to merge command
Now that we present the conflict labels in prompts, it's useful to have
better names than "local" and "other" for every command.
2016-10-07 08:51:50 -07:00
Mathias De Maré
ffcbeb8c14 check-commit: allow underscore as commit topic
It's currently not possible to commit with a changeset topic
like 'bash_completion'. This change fixes that.
2016-10-05 15:28:34 +02:00
Simon Farnsworth
dfbb92b63b merge: use labels in subrepo merge
This is the last place that doesn't respect conflict labels in merge output.
Teach subrepos to use subrepo merge output too.
2016-10-08 01:25:28 -07:00
Augie Fackler
2943f5ca36 registrar: make format strings unicodes and not bytes
Fixes issues on Python 3, wherein docstrings are unicodes. Shouldn't
break anything on Python 2.
2016-10-07 08:32:18 -04:00
Jun Wu
af2ff7c3d4 extensions: move the "import" logic out from "load"
The "load" method does too many things: on-demand import and check version.
This patch moves the import logic out from "load" so it could be wrapped to
change the import behavior, for example, chg will use it to pre-import
extensions.
2016-10-03 03:37:10 +01:00
Augie Fackler
8facc4e910 hgmanpage: stop using raw-unicode strings
These don't exist in Python 3, and this ends up looking a little more
explicit to Martijn and me anyway.
2016-10-07 07:43:04 -04:00
Augie Fackler
a4faa822dc revset: define _symletters in terms of _syminitletters 2016-10-07 08:09:23 -04:00
Augie Fackler
71a3469685 revset: remove doubled space 2016-10-07 08:03:30 -04:00
Augie Fackler
2b99f3fc25 util: use string.hexdigits instead of defining it ourselves
This resolves some Python 3 weirdness.
2016-10-07 08:58:23 -04:00
Augie Fackler
ef318ea690 util: correct check of sys.version_info
sys.version is a string, and shouldn't be compared against a tuple for
version comparisons. This was always true, so we were never disabling
gc on 2.6.

>>> (2, 7) >= '2.7'
True
>>> (2, 6) >= '2.7'
True
2016-10-07 08:01:16 -04:00
Pulkit Goyal
924bdac6e1 py3: switch to .items() using transformer
.iteritems() don't exist in Python 3 world. Used the transformer
to replace .iteritems() to .items()
2016-10-07 15:29:57 +02:00
Pulkit Goyal
757d64b218 py3: handle multiple arguments in .encode() and .decode()
There is a case and more can be present where these functions have
multiple arguments. Our transformer used to handle the first argument, so
added a loop to handle more arguments if present.
2016-10-07 14:04:49 +02:00
Pulkit Goyal
3a0ce3bcba py3: convert to unicode to pass into encode()
encoding.encoding is bytes, we need to pass it to encode() which accepts
unicodes in py3, so used pycomapt.sysstr() Also this can't be done using
transformer as that only transforms the string values not variables.
2016-10-07 12:13:28 +02:00
Anton Shestakov
64aa0688e0 templater: use "needle" and "haystack" as (meta-)variables for ifcontains()
It wasn't immediately clear if it's supposed to look for "search" in "thing" or
"thing" in "search".
2016-10-01 09:55:32 +08:00
Gábor Stefanik
5a7c7889a5 copies: mark checkcopies as internal with the _ prefix 2016-10-03 13:24:56 +02:00
Gábor Stefanik
6f3ec7c4c3 copies: split u1/u2 to u1u/u2u and u1r/u2r
These will be made different in case of grafts by another patch in this series.
2016-10-03 13:23:19 +02:00
Gábor Stefanik
88c9737beb copies: style fixes and add comment 2016-10-03 13:18:31 +02:00
Gábor Stefanik
846bad50ac copies: limit is an optimization, and doesn't provide guarantees 2016-10-03 16:19:55 +02:00
Yuya Nishihara
7078b29941 revset: do not rewrite ':y' to '0:y' (issue5385)
That's no longer valid since the revision 0 may be hidden. Bypass validating
the existence of '0' and filter it by spanset.
2016-10-01 20:20:11 +09:00
Yuya Nishihara
b94864e756 revset: extract function that creates range set from computed revisions
So we can pass m=0 to _makerangeset() even if the revision 0 is hidden.
Hidden revisions are filtered by spanset.
2016-10-01 20:11:48 +09:00
Maciej Fijalkowski
6efacdd6af lazymanifest: write a more efficient, pypy friendly version of lazymanifest 2016-09-12 13:37:14 +02:00
Gregory Szorc
f91c7e8491 hg: set default path correctly when doing a clone+share (issue5378)
Before, if performing a clone+share from a repo that was itself
using shared storage, the share code would copy paths.default from
the underlying repo being shared, not from the source given by
the user.

This patch teaches hg.clonewithshare to resolve paths.default
and pass it to share so it can be written to the hgrc accordingly.
2016-10-02 22:34:40 -07:00
Jun Wu
5ca5bb4a7c annotate: calculate line count correctly
Before this patch, the "lines" function inside "annotate" returns 1 for
empty text (''). This patch makes it 0. Because the function should match
mdiff.splitnewlines (used by mdiff.allblocks), or s.splitlines (used at the
end of the "annotate" method). Both len(mdiff.splitnewlines('')) and
len(''.splitlines(True)) are 0.

This issue was discovered while testing fastannotate [1].

I could not find a test case to reveal this issue. However in theory this
could reduce memory usage a little bit, and avoids surprises when people
are touching this area in the future.

[1]: https://bitbucket.org/facebook/hg-experimental/commits/525b3b98e93a
2016-10-01 14:18:58 +01:00
Pulkit Goyal
8ae574b546 py3: use unicode in is_frozen()
imp.is_frozen() doesnot accepts bytes on Python 3.
It does accept both bytes and strings on Python 2.
2016-10-02 05:29:17 +05:30