Commit Graph

27905 Commits

Author SHA1 Message Date
Siddharth Agarwal
f93c751fee hook: use sys.exc_info rather than the deprecated equivalents
sys.exc_type etc have been deprecated since Python 1.5.
2016-02-11 22:02:52 -08:00
FUJIWARA Katsunori
5875073363 doc: describe full help document hierarchy to create a valid link in HTML
For example, ":hg:`help config.default-push`" creates an invalid link
to "hgrc.5.html#default-push" in HTML, but ":hg:`help
config.paths.default-push`" creates a valid link to
"hgrc.5.html#paths".
2016-02-11 23:15:34 +09:00
FUJIWARA Katsunori
8e59a858bd doc: translate from :hg:help config.SECTION to a valid link to hgrc.5.html
Before this patch, ":hg:`help config.SECTION`" in online help text is
translated to a link to "hg.1.html#config.SECTION" in HTML
unintentionally.

This patch translates from :hg:`help config.SECTION` in online help
text to a valid link to "hgrc.5.html#SECTION" in HTML.

This patch ignores element(s) under "SECTION" (e.g. "ITEM" of
":hg:`help config.SECTION.ITEM`"), because there is no way to refer
directly to it in HTML, yet.
2016-02-11 23:15:34 +09:00
FUJIWARA Katsunori
4436dba238 doc: translate from :hg:help config to a valid link to hgrc.5.html
Before this patch, ":hg:`help config`" in online help text is
translated to a link to "hg.1.html#config" in HTML, even though actual
"hg help config" shows not help for "hg config" command but "config"
help topic, and all of current ":hg:`help config`" expects the latter.

This patch translates from ":hg:`help config`" in online help text to
a link to "hgrc.5.html" in HTML as expected.

This patch also allows ":hg:`help -c COMMAND`" style to link
"hg.1.html#COMMAND" for readability.
2016-02-11 23:15:34 +09:00
FUJIWARA Katsunori
5a05b076f2 i18n: calculate correct line number in source of messages to be translated
Before this patch, line number in source of the message to be
translated is wrong in hg.pot, if corresponded message is placed after
".. DIRECTIVE::", because number of lines related to such directive
isn't added to variable "delta", which holds number of untranslated
lines in given text.

This patch always adds "2" to "delta", because text block is split
into translation units by "\n\n".
2016-02-11 23:15:34 +09:00
Durham Goode
e072959d9e revsetbenchmark: handle exception case
If the revset being benchmarked has an exception, the handling code was
encountering an error because the exception did not always have an "output"
attribute (I think it's a python 2.7 thing).
2016-02-10 12:39:25 -08:00
Ryan McElroy
7172b75ac8 merge: minimize conflicts when common base is not shown (issue4447)
Previously, two changes that were nearly, but not quite, identical would result
in large merge conflict regions that looked very similar, and were thus very
confusing to users, and lead people used to other source control systems to
claim that "mercurial's merge algorithms suck". In the relatively common case
of a new file being introduced in two branches with very slight modifications,
the old behavior would show the entire file as a conflict, and it would be very
difficult for a user to determine what was going on.

In the past, mercurial attempted to solve this with a "very smart" algorithm
that would find all common lines, but this has significant problems as
described in 3d22d20aa950.

Instead, we use a "very dumb" algorithm introduced in the previous patch that
simply matches lines at the periphery of conflict regions. This minimizes most
conflict regions well, though there may still be some degenerate edge cases,
like small modification to the beginning and end of a large file.
2016-02-10 09:06:08 -08:00
Ryan McElroy
a017f9a43a merge: introduce method to minimize merge regions
In the next diff, we will use this to trim down the start and end of conflict
regions where the A and B sides both made the same changes.
2016-02-10 08:25:03 -08:00
Ryan McElroy
f1d55f43db merge: add some useful documentation 2016-02-09 15:25:09 -08:00
Yuya Nishihara
8e19f2cb3f encoding: backport paranoid escaping from templatefilters.jsonescape()
This was introduced by e1e8de66f2e1. It is required to embed JSON data in
HTML page. Convince yourself here:

http://escape.alf.nu/1
2015-12-27 19:58:11 +09:00
Yuya Nishihara
89ded2c8a7 encoding: add option to escape non-ascii characters in JSON
This is necessary for hgweb to embed JSON data in HTML. JSON data must be
able to be embedded in non-UTF-8 HTML page so long as the page encoding is
compatible with ASCII.

According to RFC 7159, non-BMP character is represented as UTF-16 surrogate
pair. This function first splits an input string into an array of UTF-16
code points.

https://tools.ietf.org/html/rfc7159.html#section-7
2015-12-27 19:28:34 +09:00
Yuya Nishihara
2b5d7daa88 encoding: initialize jsonmap when module is loaded
This makes jsonescape() a thread-safe function, which is necessary for hgweb.
The initialization stuff isn't that slow:

  $ python -m timeit -n1000 -s 'from mercurial import encoding as x' 'reload(x)'
  original:   1000 loops, best of 3: 158 usec per loop
  this patch: 1000 loops, best of 3: 214 usec per loop

compared to loading the commands module:

  $ python -m timeit -n1000 -s 'from mercurial import commands as x' 'reload(x)'
  1000 loops, best of 3: 1.11 msec per loop
2016-01-30 19:48:35 +09:00
Yuya Nishihara
edbbf3796b encoding: change jsonmap to a list indexed by code point
This is slightly faster and convenient to implement a paranoid escaping.

  $ python -m timeit \
  -s 'from mercurial import encoding; data = str(bytearray(xrange(128)))' \
  'encoding.jsonescape(data)'

  original:   100000 loops, best of 3: 15.1 usec per loop
  this patch: 100000 loops, best of 3: 13.7 usec per loop
2016-01-30 19:41:34 +09:00
Pierre-Yves David
2dcf98d614 update: change default destination to tipmost descendant (issue4673) (BC)
Bare 'hg update' now brings you to the tipmost descendant (on the same branch).
Leaving the user on the same topological branch. The previous behavior, updating
to the tipmost changeset on the same branch could lead to jump from a
topological branch to another. This was confusing and impractical. As the only
conceivable reason for the old behavior have been address by the recently
introduce message about other heads, we can "safely" change this behavior

All test changes have been reviewed and seen a valid consequences.
2016-02-02 15:24:11 +00:00
Pierre-Yves David
02d6c96efe test: drop useless --update flag in issue1502 tests
The --update is unrelated to the test and has no effect as it fails anyway.
Dropping it reduces the noise in the coming change in default destination for
update.
2016-02-03 15:21:11 +00:00
Martijn Pieters
241d8f86a5 treemanifest: don't use cp -T, not supported on OS X
The OS X cp implementation has no -T switch. Copy directory contents using a
glob instead.
2016-02-11 13:50:38 +00:00
Yuya Nishihara
53de7956c0 chg: use in-tree hg executable to start server for testing 2016-01-03 12:45:32 +09:00
Yuya Nishihara
4f669ecea8 hgignore: ignore chg binary 2016-01-03 12:41:28 +09:00
Yuya Nishihara
58036583d5 chg: import frontend sources
These files are copied from
https://bitbucket.org/yuja/chg/ -r f897faa79687
2016-01-03 12:39:27 +09:00
liscju
b09bcd00b0 debugrevlog: fix dumping manifest fails on empty first revision (issue5062) 2016-02-10 21:01:52 +01:00
Simon Farnsworth
ff988aaa4b help: don't crash in keyword search if an extension fails to provide docs
Not all external extensions provide docs; if you use such an extension, you
will experience a crash if you use "hg help --keyword <word>", and <word>
happens to match the extension name.
2016-02-10 01:48:58 -08:00
timeless
64b5aa82c1 run-tests: factor out _escapepath 2016-01-29 14:35:34 +00:00
Matt Harbison
7d76fe4b73 debugignore: normalize the file before testing dirstate._ignore()
With an ignore pattern containing a '/' and a Windows style path containing '\',
status was properly ignoring the file, but debugignore was stating that it
wasn't ignored.
2016-02-08 12:33:00 -05:00
FUJIWARA Katsunori
5e089ee084 check-code: add rule to detect usage of external diff via extdiff
This rule detects "hg extdiff" invocation without -p/--program and
-o/--option.

This patch specifies "-p diff" explicitly in test-extdiff.t to avoid
false positive matching.
2016-02-11 02:15:45 +09:00
FUJIWARA Katsunori
469ca8bae6 tests: use portable diff script via extdiff extension
Before this patch, some tests using external "diff" command via
extdiff extension fail on Solaris, because of incompatibility of
"diff" command and its output.

For example, system standard "diff" (= /usr/bin/diff) on Solaris
differs from GNU diff in points below:

  - "-N" (treat absent files as empty) option isn't supported

  - files are examined not in dictionary order
    (maybe, in order in storage)

This patch introduces portable diff script "pdiff" and make tests use
it via extdiff extension.

For portability of tests, this patch invokes "pdiff" script with
explicit "sh", because standard shell of runtime platform ("cmd.exe"
on Windows) is used at first to invoke external diff command.
2016-02-08 18:29:17 +09:00
Sébastien Brissaud
9f1189b63a test-patchbomb: ensure hg email write to stdout
With -n/--test and if the PAGER environment variable is set, 'hg email' send its
output to the user defined pager.

If the pager capture the output, the test is unable verify it.

Unsetting the PAGER environment variable force 'hg email' to write to stdout.
2016-02-07 09:36:09 +01:00
FUJIWARA Katsunori
34295148ed check-code: examine magic pattern matching against contents of a file
Before this patch, check-code examines "magic" pattern (e.g.
'^#!.*python') matching against not contents of a file, but name of
it.

This unintentionally omits code checking against Python source file,
of which filename doesn't end with "*.py" or "*.cgi", even though
contents of it starts with "#!/bin/python" or so.

In this change, 'pre' refers contents of file 'f'.
2016-02-10 22:44:29 +09:00
FUJIWARA Katsunori
357c04e06b docchecker: use indentation of 4 spaces
This is fixing for 'must indent 4 spaces' check-code rule.

check-code has overlooked this, because a file isn't recognized as one
to be checked (this problem is fixed by subsequent patch).
2016-02-10 22:44:29 +09:00
FUJIWARA Katsunori
c26e9ad792 docchecker: remove naked except clause
This is fixing for 'naked except clause' check-code rule.

check-code has overlooked this, because a file isn't recognized as one
to be checked (this problem is fixed by subsequent patch).
2016-02-10 22:44:29 +09:00
FUJIWARA Katsunori
0e48f36a63 misc: use modern exception syntax
This is fixing for 'legacy exception syntax; use "as" instead of ","'
check-code rule.

check-code has overlooked these, because files aren't recognized as
one to be checked (this problem is fixed by subsequent patch).
2016-02-10 22:44:29 +09:00
FUJIWARA Katsunori
32db5d850a f: use modern octal number formatting
This is fixing for 'legacy octal syntax; use "0o" prefix instead of
"0"' check-code rule.

check-code has overlooked this, because a file isn't recognized as one
to be checked (this problem is fixed by subsequent patch).
2016-02-10 22:44:28 +09:00
FUJIWARA Katsunori
05a600c8af hg-ssh: parenthesize non-translated message
This is fixing for 'missing _() in ui message (use () to hide
false-positives)' check-code rule.

check-code has overlooked this, because a file isn't recognized as one
to be checked (this problem is fixed by subsequent patch).
2016-02-10 22:44:28 +09:00
FUJIWARA Katsunori
5accfbf33e f: add whitespace around operator
This is fixing for 'missing whitespace in expression' check-code rule.

check-code has overlooked this, because a file isn't recognized as one
to be checked (this problem is fixed by subsequent patch).
2016-02-10 22:44:28 +09:00
FUJIWARA Katsunori
ae585f8a5f check-commit: omit whitespace
This is fixing for 'no whitespace around = for named parameters'
check-code rule.

check-code has overlooked this, because a file isn't recognized as one
to be checked (this problem is fixed by subsequent patch).
2016-02-10 22:44:28 +09:00
FUJIWARA Katsunori
41a375be1e check-commit: wrap too long line
This is fixing for 'line too long' check-code rule.

check-code has overlooked this, because a file isn't recognized as one
to be checked (this problem is fixed by subsequent patch).
2016-02-10 22:44:28 +09:00
timeless
e09049f8f5 run-tests: warn about symlinks to non hg scripts
If you symlink /usr/bin/true to /something/hg and try to run
--with-hg=/something/hg, run-tests will end up running /usr/bin/hg,
not /usr/bin/true.
2016-02-08 22:50:19 +00:00
FUJIWARA Katsunori
c076a02400 tests: make chunk header of external diff glob-ed for portability
Before this patch, some tests using external "diff" command via
extdiff extension fail on Solaris, because system standard "diff" (=
/usr/bin/diff) on Solaris always generates chunk headers below:

  - "@@ -1,0 +1,nnnn @@" for added file
  - "@@ -1,nnnn +1,0 @@" for removed file

even though "diff" on Linux generates:

  - "@@ -0,0 +1,nnnn @@" for added file
  - "@@ -1,nnnn +0,0 @@" for removed file

This patch makes chunk header of external diff glob-ed for portability
of tests.

"hg diff" output follows Linux style, and there are many such diff
output lines in existing tests. This is reason why this patch doesn't
add check-code.py any rule to detect such diff output in tests.

This patch is a part of making tests using external "diff" portable,
and test-subrepo-deep-nested-change.t isn't yet portable even after
this patch.
2016-02-08 18:29:17 +09:00
FUJIWARA Katsunori
bdf197db2e tests: make chunk header of external diff glob-ed for portability
Before this patch, some tests using external "diff" command via
extdiff extension fail on Solaris, because system standard "diff" (=
/usr/bin/diff) on Solaris always formats chunk header in the style
below:

  @@ -X.x +Y.y @@

even though "diff" on Linux sometimes omits ".x" and/or ".y" in it.

This patch makes chunk header of external diff glob-ed for portability
of tests, and adds check-code.py rules to detect such diff output in
tests.

This patch also changes "hg diff" output in test-subrepo-git to
simplify detection rules, even though it is certainly portable because
these lines are generated by "git" command.

This patch is a part of making tests using external "diff" portable,
and tests below aren't yet portable even after this patch.

  test-largefiles-update.t
  test-subrepo-deep-nested-change.t
2016-02-08 18:29:17 +09:00
FUJIWARA Katsunori
4d0ebd5133 tests: make timezone in diff output glob-ed for portability
Before this patch, some tests using external "diff" command via
extdiff extension fail on Solaris, because system standard "diff" (=
/usr/bin/diff) on Solaris doesn't display timezone for timestamp of
each files in diff output.

This patch makes timezone in external diff output glob-ed for
portability of tests, and adds check-code.py a rule to detect such
2016-02-08 18:29:17 +09:00
FUJIWARA Katsunori
91b31cc00a tests: omit -p for external diff via extdiff extension for portability
Before this patch, some tests using external "diff" command via
extdiff extension fail on Solaris, because "-p" (show which C function
each change is in) option isn't supported by system standard "diff" on
Solaris, even though extdiff passes it to external "diff" by default.

Fortunately, this non-portable option isn't important for (current, at
least) tests using external "diff" command via extdiff extension.

This patch omits "-p" for external "diff" command via extdiff
extension for portability of tests, and adds check-code.py a rule to
detect invocation of "diff" with "-p".

Newly added check-code.py rule examines only lines generated by
external "diff" with "-r", because strict examination might
misidentify "hg diff -p" or other complicated lines consisting of
"diff" string as wrong one.

This patch is a part of making tests using external "diff" portable,
and tests below aren't yet portable even after this patch.

  test-graft.t
  test-largefiles-update.t
  test-subrepo-deep-nested-change.t
2016-02-08 18:29:17 +09:00
Martin von Zweigbergk
e106ceb930 update: check command line before modifying repo
A failed command should not have any effect on the repo.
2016-02-07 22:18:24 -08:00
Martin von Zweigbergk
d7ef7dd40a treemanifest: fix debugrebuildfncache
When I taught debugrebuildfncache about dirlogs in ebe9dacc63ba
(treemanifests: fix streaming clone, 2016-02-04), I added a
last-minute "if 'treemanifest' in repo" guard. That should have been
checking for "... in repo.requirements". Fix that and add tests for
it.
2016-02-07 21:44:38 -08:00
Pierre-Yves David
3998c3b144 update: warn about other topological head in pull and unbundle
Other commands have a '--update' triggering a bare update. We now issue the
message introduced into the previous changeset for these too.
2016-02-03 15:12:01 +00:00
Pierre-Yves David
2e0675043e update: warn about other topological heads on bare update
A concern around the user experience of Mercurial is user getting stuck on there
own topological branch forever. For example, someone pulling another topological
branch, missing that message in pull asking them to merge and getting stuck on
there own local branch.

The current way to "address" this concern was for bare 'hg update' to target the
tipmost (also latest pulled) changesets and complain when the update was not
linear. That way, failure to merge newly pulled changesets would result in some
kind of failure.

Yet the failure was quite obscure, not working in all cases (eg: commit right
after pull) and the behavior was very impractical in the common case
(eg: issue4673).

To be able to change that behavior, we need to provide other ways to alert a
user stucks on one of many topological head. We do so with an extra message after
bare update:

  1 other heads for branch "default"

Bookmark get its own special version:

  1 other divergent bookmarks for "foobar"

There is significant room to improve the message itself, and we should augment
it with hint about how to see theses other heads or handle the situation (see
in-line comment). But having "a" message is already a significant improvement
compared to the existing situation. Once we have it we can iterate on a better
version of it. As having such message is an important step toward changing the
default destination for update and other nicety, I would like to move forward
quickly on getting such message.

This was discussed during London - October 2015 Sprint.
2016-02-02 14:49:02 +00:00
timeless
1ee6f788c8 tests: mock getpid to reduce glob usage
With util.getpid, it is now possible to define fixed pids.

Future iterations can define a map of pids on a locked
first come first serve basis to create a more realistic
harness, but for now this is good enough.

This applies to blackbox, but could apply to other
tests as well.
2016-02-03 04:37:04 +00:00
timeless
3502e556ef util: enable getpid to be replaced
This will enable tests to write stable process ids.
2016-02-03 09:11:22 +00:00
timeless
0541bdf700 blackbox: refactor use of vfs as _bbvfs 2016-02-08 00:47:36 +00:00
timeless
6eaedecd28 blackbox: flush output file descriptor
Without this, when there are multiple ui views, each blackbox
will have its own file handle, and the logging will be in
a really bad order.

Also, because of the way blackbox works, it never closes its
file handles, which means the last output before exit is
often lost.
2016-02-03 15:18:29 +00:00
timeless
178005e982 tests: change blackbox test to work cross platform
While it is not easy to make a file 000 on Windows, you can
emulate most of the behaviors by replacing the file with a directory.

Also corrects test description to properly indicate that failing to
read from the log is fatal.
2016-02-03 18:15:18 +00:00
Siddharth Agarwal
33c18c0f15 merge: document checkignored and checkunknown configs again
These options were undocumented for 3.7 because of an issue found during the
freeze (see rev e5c26e4e6ec7). This issue has now been fixed, so we can
document these options again.
2016-02-01 20:28:32 -08:00