Commit Graph

9562 Commits

Author SHA1 Message Date
Gregory Szorc
280f76fc24 acl: use absolute_import
Continuing the march towards Python 3.
2016-02-09 17:29:39 -08:00
Simon Farnsworth
440b97f84b tests: confirm that a badly documented extension doesn't cause a crash
An external extension whose docstring doesn't conform to Mercurial standards
used to cause crashes. Test that we omit such extensions when you do a
keyword search.
2016-02-12 06:25:05 -08:00
Martijn Pieters
c5a481c317 bookmarks: avoid creating a nested repository during testing
This helps the test to pass with hgwatchman, which would otherwise need to be
taught about a nested .hg directory. hgwatchman already blacklists
test-nested-repo.t which covers the actual usecase
2016-02-12 14:24:48 +00:00
Tony Tung
3ed9c83afd dispatch: strip command line options like config file options
Currently, whitespace in command line --config options are considered
significant while whitespace in config files are not considered
significant.  This diff strips the leading and trailing whitespace from
command line config options.
2016-02-08 15:35:30 -08:00
Siddharth Agarwal
2e2fbd19a4 hook: for python hook ImportErrors, add note to run with --traceback
I personally found it completely non-obvious that --traceback prints out stack
traces for failed imports.
2016-02-11 22:52:23 -08:00
Siddharth Agarwal
d77e1d7bef hook: fewer parentheses for hook load errors
This matches 'hook failed' warnings.

We're also going to add hints to some of the hook load errors. Without this
change we'd have two pairs of parens for a single error message, which looks
really cluttered.
2016-02-11 22:41:20 -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
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
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
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
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
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
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
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
66f60475b8 rebase: respect checkunknown and checkignored in more cases
checkunknown and checkignored are currently respected for updates and regular
merges, but not for certain kinds of rebases. To be precise, they aren't
respected for rebases when:

(1) we're rebasing while currently on the destination commit, and
(2) an untracked or ignored file F is currently in the working copy, and
(3) the same file F is in a source commit, and
(4) F has different contents in the source commit.

This happens because rebases set force to True when calling merge.update.
Setting force to True makes a lot of sense in general, but it turns out the
force option is overloaded: there's a deprecated '--force' option in merge that
allows you to merge in outstanding changes, including changes in untracked
files. We use the 'mergeforce' parameter to tell those two cases apart.

I think the behavior during rebases when checkunknown is 'abort' (the default)
is wrong -- we should abort on or overwrite differing untracked files, not try
to merge them in. However that currently breaks rebases by aborting in the
middle -- we need better handling for that case before we can change the
default.
2016-02-03 13:12:06 -08:00
Siddharth Agarwal
afdc50e948 test-merge-force: add tests for merge.checkunknown=warn
In an upcoming patch we're going to change the behavior of some merges with
merge.checkunknown=warn or ignore -- ensure that the behavior of the deprecated
'merge --force' remains the same.
2016-02-03 13:11:34 -08:00
timeless
8e3dbae060 tests: relax test-devel-warnings to reduce false positives
This test is interested in warning output, so
glob away line numbers and hashes as they aren't relevant
to its core.
2016-02-03 18:59:35 +00:00
Matt Mackall
fd4d3ffdae merge with stable 2016-02-07 00:49:31 -06:00
timeless
2c0eb26137 rebase: update working directory when aborting (issue5084) 2016-02-05 01:56:46 +00:00
Yuya Nishihara
6b8c99a6d3 revset: flatten chained 'list' operations (aka function args) (issue5072)
Internal _matchfiles() function can take bunch of arguments, which would
lead to a maximum recursion depth error. This patch avoids the excessive
stack use by flattening 'list' nodes beforehand.

Since getlist() no longer takes a nested 'list' nodes, _parsealiasdecl()
also needs to flatten argument list, "aliasname($1, $2, ...)".
2016-02-02 23:49:49 +09:00
Siddharth Agarwal
69360ef583 rebase: don't preserve most extra fields
This backs out changeset 5293d4f88aef.

See the previous patches for why.
2016-02-03 09:23:31 -08:00
Siddharth Agarwal
08f24f1f67 graft: don't preserve most extra fields
This backs out changeset 9aa13e9feec8.

See the previous patch for why we're doing this.
2016-02-03 09:06:52 -08:00
Martijn Pieters
9c233476de rebase: better way to detect non-detaching revisions (issue5044)
Rather than look for the lowest revision, see if the rebase state is tracking
the parents of this revision. Otherwise we can't handle multiple revisions in
one rebase that includes a merge revision.

Fixes issue5044.
2016-02-01 15:41:43 +00:00
FUJIWARA Katsunori
a189f9751b histedit: show correct hash ID at verification error
node.short() on 'ha' in verifyactions() causes broken hash ID, because
it is initialized with node.hex()-ed node value.
2016-02-01 20:29:20 +09:00
Yuya Nishihara
c24eb61d0c backout: disable --merge with --no-commit (issue4874)
Because "backout --merge" have to make a commit before merging, it doesn't
work with --no-commit. We could change "backout --merge" to make a merge
commit automatically, and --no-commit to bypass a merge commit, but that
change would be undesirable because:

 a) it's hard to fix bad merges in general
 b) two commits would be created with the same --message

So, this patch simply disables "--merge --no-commit".
2016-01-30 18:00:11 +09:00
Martin von Zweigbergk
86ca76bafe changegroup: fix pulling to treemanifest repo from flat repo (issue5066)
In b89de5ee5b31 (changegroup: don't support versions 01 and 02 with
treemanifests, 2016-01-19), I stopped supporting use of cg1 and cg2
with treemanifest repos. What I had not considered was that it's
perfectly safe to pull *to* a treemanifest repo using any changegroup
version. As reported in issue5066, I therefore broke pull from old
repos into a treemanifest repo. It was not covered by the test case,
because that pulled from a local repo while enabling treemanifests,
which enabled treemanifests on the source repo as well. After
switching to pulling via HTTP, it breaks.

Fix by splitting up changegroup.supportedversions() into
supportedincomingversions() and supportedoutgoingversions().
2016-01-27 09:07:28 -08:00
Martin von Zweigbergk
19285a7ebc tests: minor cleanup to treemanifest test 2016-01-28 13:49:05 -08:00
FUJIWARA Katsunori
07d633b500 commands: advance current active bookmark at pull --update correctly
Before this patch, "hg pull --update" doesn't advance current active
bookmark correctly, if pulling itself doesn't advance it, even though
"hg pull" + "hg update" does so.

Existing test for "pull --update works the same as pull && update" in
test-bookmarks.t doesn't examine this case, because pulling itself
advance current active bookmark before actual updating the working
directory in that test case.

To advance current active bookmark at "hg pull --update" correctly,
this patch examines 'movemarkfrom' instead of 'not checkout'.

Even if 'not checkout' at the invocation of postincoming(), 'checkout'
is overwritten by "the revision to update to" value returned by
destutil.destupdate() in such case. Therefore, 'not checkout'
condition means "update destination is revision #0", and isn't
suitable for examining whether active bookmark should be advanced.

Even though examination around "movemarkfrom == repo['.'].node()" may
seem a little redundant just for this issue, this makes it easier to
compare (and unify in the future, maybe) with the same logic to update
bookmark at "hg update" below.

        if not ret and movemarkfrom:
            if movemarkfrom == repo['.'].node():
                pass # no-op update
            elif bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
                ui.status(_("updating bookmark %s\n") % repo._activebookmark)
            else:
                # this can happen with a non-linear update
                ui.status(_("(leaving bookmark %s)\n") %
                          repo._activebookmark)
                bookmarks.deactivate(repo)
2016-01-28 20:10:06 +09:00
Matt Harbison
6d46368119 largefiles: prevent committing a missing largefile
Previously, if the largefile was deleted at the time of a commit, the standin
was silently not updated and its current state (possibly garbage) was recorded.
The test makes it look like this is somewhat of an edge case, but the same thing
happens when an `hg revert` followed by `rm` changes the standin.

Aside from the second invocation of this in lfutil.updatestandinsbymatch()
(which is what triggers this test case), the three other uses are guarded by
dirstate checks for added or modified, or an existence check in the filesystem.
So aborting in lfutil.updatestandins() should be safe, and will avoid silent
skips in the future if this is used elsewhere.
2016-01-24 00:10:19 -05:00
Augie Fackler
db82034373 changegroup: fix treemanifest exchange code (issue5061)
There were two mistakes: one was accidental reuse of the fclnode
variable from the loop gathering file nodes, and the other (masked by
that bug) was not correctly handling deleted directories. Both cases
are now fixed and the test passes.
2016-01-27 10:24:25 -05:00
Matt Harbison
49d08bc58e largefiles: report the missing file count after a commit that does nothing
This is the same warning that is printed for normal files.
2016-01-23 23:32:49 -05:00
Matt Harbison
9906cb44b6 largefiles: fix an explicit largefile commit after a remove (issue4969)
The change in 6fce9a02f069 to handle a normal -> largefile switch was too
aggressive in preserving the original matcher names.  If a largefile is
explicitly provided by the user, but only the standin exists in dirstate, then
only the standin can be committed.

There's still maybe an issue when the largefile is deleted outside of Mercurial:

  $ rm large
  $ hg ci -m "oops" large
  large: The system cannot find the file specified
  nothing changed
  [1]
2016-01-23 20:51:17 -05:00
Matt Mackall
9b78d1a779 check-commit: check for double-addition of blank lines
Previously, we were only checking for a blank line being added next to
an existing one. Now we also check for two being added at the same time.
2016-02-05 16:54:01 -06:00
Durham Goode
4834302703 merge: add file ancestor linknode to mergestate
During a merge, each file has a current commitnode+filenode, an other
commitnode+filenode, and an ancestor commitnode+filenode. The ancestor
commitnode is not stored though, and we rely on the ability for the filectx() to
look up the commitnode by using the filenode's linkrev. In alternative backends
(like remotefilelog), linkrevs may have restriction that prevent arbitrary
linkrev look up given a filenode.

This patch accounts for that by storing the ancestor commitnode in
the merge state so that it is available later at resolve time.

This results in some test changes because the ancestor commitnode we're using at
resolve time changes slightly. Before, we used the linkrev commit, which is the
earliest commit that introduced that particular filenode (which may not be the
latest common ancestor of the commits being merged). Now we use the latest
common ancestor of the merged commits as the commitnode. This is fine though,
because that commit contains the same filenode as the linkrev'd commit.
2016-02-05 10:22:14 -08:00