Commit Graph

27905 Commits

Author SHA1 Message Date
Martin von Zweigbergk
cc3e946787 match: override 'visitdir' in subdirmatcher
The manifest.manifest class has a _treeinmem member than one can
manually set to True to test that the treemanifest class works as a
drop-in replacement for manifestdict (which is mostly a requirement
for treemanifest repos to work). However, it doesn't quite work at the
moment. These tests fail:

test-largefiles-misc.t
test-rebase-newancestor.t
test-subrepo.t
test-subrepo-deep-nested-change.t
test-subrepo-recursion.t

All but test-rebase-newancestor.t fail because they trigger calls to
subdirmatcher.visitdir(), which tries to access a _excluderoots field
that does not exist on the subdirmatcher. Let's fix that by overriding
visitdir() in a similar way to how matchfn is overridden, i.e. by
prepending the directory before calling the superclass method.
2016-02-05 21:25:44 -08:00
Yuya Nishihara
cf3e9474ef run-tests: remove useless "failed" flag from addOutputMismatch()
It never be set to True.
2016-01-09 13:22:26 +09:00
Yuya Nishihara
ad2de493a5 tests: load json with no fallback
The json module should be available in Python 2.6 or newer.
2016-01-09 13:20:15 +09:00
Yuya Nishihara
b14e0888a3 config: drop progress extension from sample hgrc as it is in core now 2015-12-15 23:50:48 +09:00
timeless
9a9c421b30 shelve: suggest the correct tool to continue (not unshelve)
Suggest committing (or whatever the current activity is), via
wrongtooltocontinue which uses howtocontinue.
2016-02-04 03:47:38 +00:00
timeless
8f5f0dd31d histedit: suggest the correct tool to continue (not histedit)
Suggest committing (or whatever the current activity is), via
wrongtooltocontinue which uses howtocontinue.
2016-02-04 03:47:00 +00:00
timeless
6afbee8966 rebase: suggest the correct tool to continue (not rebase)
Suggest committing (or whatever the current activity is), via
wrongtooltocontinue which uses howtocontinue.
2016-02-04 03:46:38 +00:00
timeless
08040e612b graft: suggest the correct tool to continue (not graft)
Add test coverage for graft --continue without starting.
Suggest committing (or whatever the current activity is), via
wrongtooltocontinue which uses howtocontinue.
2016-02-04 03:45:44 +00:00
timeless
35e2ff1d7c cmdutil: provide a way to report how to continue
checkafterresolved allows Mercurial to suggest what command to
use next. If users try to continue the wrong command, there
wasn't a good way for the command to suggest what to do next.

Split checkmdutil into howtocontinue and checkafterresolved.
Introduce wrongtooltocontinue which handles raising an Abort with
the hint from howtocontinue.
2016-02-14 16:16:17 +00:00
FUJIWARA Katsunori
7164ed4e18 hg: make cachedlocalrepo cache appropriate repoview object
Before this patch, 'cachedlocalrepo' always caches "visible" repoview
object, because 'cachedlocalrepo' uses "visible" repoview returned by
'hg.repository()' without any additional processing.

If the client of 'cachedlocalrepo' wants "served" repoview, some
objects to be cached are discarded unintentionally.

    1. 'cachedlocalrepo' newly caches "visible" repoview object
       (call it VIEW1)

    2. 'cachedlocalrepo' returns VIEW1 to the client of it at 'fetch()'

    3. the client gets "served" repoview object by 'filtered("served")'
       on VIEW1 (call this "served" repoview VIEW2)

    4. accessing to 'repo.changelog' implies:
       - instantiation of changelog via 'localrepository.changelog'
       - instantiation of "filtered changelog" via 'repoview.changelog'

    5. "filtered changelog" above is cached in VIEW2

    6. VIEW2 is discarded after processing, because there is no
       reference to it

    7. 'cachedlocalrepo' returns VIEW1 cached at (1) above to the
       client at next 'fetch()'

    8. 'filtered("served")' on VIEW1 at the client side creates new
       "served" repoview again, because VIEW1 is "visible"
       (call this new "served" repoview VIEW3)

    9. accessing to 'repo.changelog' implies instantiation of filtered
       changelog again, because "filtered changelog" is cached in
       VIEW2 at (5), but not in VIEW3 currently used

    10. (go to (7) above)

As described above, "served" repoview object and "filtered changelog"
cached in it are discarded always, even if the repository itself
hasn't been changed since last access.

For example, in the case of 'hgweb_mod.hgweb', "newly caching" occurs,
when:

  - all cached objects are already assigned to another threads
    (in this case, repoview is created in 'cachedlocalrepo.copy()')

  - or, stat of '00changelog.i' is changed from last access
    (in this case, repoview is created in 'cachedlocalrepo.fetch()')

    once changes are pushed via HTTP, this always occurs.

The root cause of this inefficiency is that 'cachedlocalrepo' always
caches "visible" repoview object, even if the client of it wants
another view.

To make 'cachedlocalrepo' cache appropriate repoview object, this
patch adds additional filtering on the repo object returned by
'hg.repository()'. It is assumed that initial repoview object should
be already filtered by expected view.

After this patch:

  - 'filtered("served")' on VIEW1 at (3)/(7) above returns VIEW1
    itself, because VIEW1 is now "served", and

  - VIEW2 and VIEW3 equal VIEW1

  - therefore, "filtered changelog" is cached in VIEW1, and reused
    intentionally
2016-02-14 01:33:55 +09:00
Pierre-Yves David
93af21fe85 rebase: perform update through the 'update' command
The update logic have grow more and more complicated over time (eg bookmark
movement, new destination logic, warning on other head, etc). The rebase
extension was reimplementing its own basic version of update to be used by 'hg
pull --rebase'. We remove the custom code and use a combination of higher level
functions.

A test is added to check that the update is properly warning about other branch
heads.
2016-02-14 00:45:17 +00:00
Pierre-Yves David
0e26e4a437 rebase: 'hg pull --rebase' now update only if there was nothing to rebase
I recently discovered that 'hg pull --rebase' was also running an update. And it
was running it in all cases as long as the update would move the working copy
somewhere else...

This felt wrong and it actually is. This 'update' call is introduced in
8bea699a182c. In that commit the intent is very clear. The update should happen
only when there was nothing to rebase. The implementation did not check if a
rebase was performed because, at that time, rebase would always leave you on the
top most changeset. Being on that top most changeset result in a no-op update
and the step was skipped.

However 642dc7838453d changed rebase behavior to preserve the working copy
parent, so if we are not on a head at pull time, the code performs both a rebase
and an update.

This changeset introduce a test for this case and restore the intended behavior.

There are other issues with this custom update code but they will be addressed
in later changeset (eg: own destination logic, lack of heads warning).

I'm not super happy with the explicitly comparison 'rebase(...) == 1' but a
later series will have a cleaner way to handle it anyway (while making 'rebase'
pick its default destination like 'merge').
2016-02-13 16:59:32 +00:00
Durham Goode
a6b3658fd5 filectx: replace use of _filerev with _filenode
_filerev depends on the filelog implementation using revlogs and linkrevs.
Alternative implementations, like remotefilelog, do not have rev numbers, so
this call fails. Replacing it with _filenode means it doesn't rely on rev
numbers, and doesn't cost anything extra, since _filerev is using _filenode
under the hood anyway.
2016-02-08 14:17:11 -08:00
Martin von Zweigbergk
73fc56cffe verify: extract "manifest" constant into variable
The "manifest" label that's used in error messages will instead be the
directory path for subdirectory manifests (not the root manifest), so
let's extract the constant to a variable already to make future
patches simpler.
2016-02-03 15:53:48 -08:00
Martin von Zweigbergk
8868dab63d verify: use similar language for missing manifest and file revisions
When a changeset refers to a manifest revision that's not found in the
manifest log, we say "changeset refers to missing revision X", but
when a manifest refers to file revision that's not found in the
filelog, we say "X in manifests not found". The language used for
missing manifest revisions seems clearer, so let's use that for
missing filelog revisions too.
2016-02-07 22:46:20 -08:00
Martin von Zweigbergk
0e98867ba2 verify: include "manifest" prefix in a few more places
We include the "manifest" prefix on most other errors, so it seems
consistent to add them to the remaining messages too. Also, having the
"manifest" prefix will be more consistent with having the directory
prefix there when we add support for treemanifests. With the
"manifest" at the beginning, let's remove the now-redundant
"manifest" in the message itself.
2016-02-02 10:42:28 -08:00
Martin von Zweigbergk
bb06be61b6 verify: drop unnecessary check for nullid
In 1f64dad11884 (verify: filter messages about missing null manifests
(issue2900), 2011-07-13), we started ignoring nullid in the list of
manifest nodeids to check. Then, in 954b09a82a61 (verify: do not choke
on valid changelog without manifest, 2012-08-21), we stopped adding
nullid to the list to start with. So let's drop the left-over check
now.
2016-02-02 09:46:14 -08:00
Martin von Zweigbergk
d138e53179 verify: move cross-checking of changeset/manifest out of _crosscheckfiles()
Reasons:

 * _crosscheckfiles(), as the name suggests, is about checking that
   the set of files files mentioned in changesets match the set of
   files mentioned in the manifests.

 * The "checking" in _crosscheckfiles() looked rather strange, as it
   just emitted an error for *every* entry in mflinkrevs. The reason
   was that these were the entries remaining after the call to
   _verifymanifest(). Moving all the processing of mflinkrevs into
   _verifymanifest() makes it much clearer that it's the remaining
   entries that are a problem.

Functional change: progress is no longer reported for "crosschecking"
of missing manifest entries. Since the crosschecking phase takes a
tiny fraction of the verification, I don't think this is a
problem. Also, any reports of "changeset refers to unknown manifest"
will now come before "crosschecking files in changesets and
manifests".
2016-01-31 00:10:56 -08:00
Martin von Zweigbergk
7eefa4f76d tests: add tests for missing revlogs and revlog entries
The verify code is pretty poorly tested. It's easy to test missing
revlogs and missing revlog entries, so let's add tests for that.

Also add some more tests corrupting each type of revlog, so we test
the messages presented when reading a revision fails. The pure and
native implementations produce different error messages, so we have to
use (glob) in the tests.
2016-01-31 21:55:52 -08:00
Siddharth Agarwal
392dc5ff01 hook: don't crash on syntax errors in python hooks
We had some real-world cases where syntax errors in Python hooks would crash
the whole process and leave it in an indeterminate state. Handle those better.
2016-02-12 14:50:10 -08:00
Siddharth Agarwal
e25b5c0e93 hook: for python hook exceptions, add note to run with --traceback
Just like with ImportErrors, it isn't obvious that --traceback will produce
helpful debugging output here.
2016-02-12 11:44:35 -08:00
Siddharth Agarwal
4c6bcdf4ed hook: add tests for failing post- python hooks
I couldn't find any tests for this.
2016-02-12 11:42:18 -08:00
Siddharth Agarwal
1605280a66 hook: even fewer parentheses for load errors
Missed this one.
2016-02-12 11:34:04 -08:00
Pierre-Yves David
530d9d0362 destutil: document various failure cases
We document what various conditional branch mean and clarify that they are
exclusive (since they all end up in with exception raised).
2016-02-08 17:34:32 +01:00
Pierre-Yves David
58a2a17b1f destutil: consistently retrieve 'p1' and 'branch'
We already read p1 from the dirstate so let's read the branch from it too.
2016-02-08 14:56:28 +01:00
Pierre-Yves David
5f9bab17c1 merge: give priority to "not at head" failures for bare 'hg merge'
We refuse to pick a destination for a bare 'hg merge' if the working copy is not
at head. This is meant to prevent strange merge from user who forget to update.
(Moreover, such merge does not reduce actually the number of heads)

However, we were doing that as the last possible failure type. So user were
recommended to merge with an explicit head (from this bad location) if the
branch had too many heads.

We now make "not on branch heads" class of failure the first things to check
and fail on. The one test that change was actually trying to check for these
failure (and did not). The new test output is correct.
2016-02-08 14:55:58 +01:00
Pierre-Yves David
45bbc38fe5 destutil: extract all 'mergedest' abort messages into a dictionary
We plan to be able to reuse this function for rebase. The error
message explicitly refers to "merge" in multiple places. So we'll need
to be able to use different messages. The first step of that is to
extract all messages in a dedicated dictionary and use them
indirectly.

As a side effect it clarifies the actual function and opens the way to
various cleanups and fixes in future changesets.
2016-02-09 21:14:37 +00:00
Pierre-Yves David
7a525b7661 tests: add an explicit destination in some rebase tests
As we will make 'rebase' behave more like 'merge', it will no longer pick
'max(branch(.))' as the default destination. We have to hard code the expected
destination is multiple tests where it matters. After a careful inspection none
of theses tests really cares about the default destination behavior and just
omitted one out of laziness.
2016-02-08 14:03:45 +01:00
Pierre-Yves David
b51f101980 tests: remove third head in some of the 'rebase-parameters' tests
These tests do not care about that extra branch at all. In future changeset we
will make rebase behave like merge and abort in case of an ambiguous destination
(eg: multiple other heads) and that extra branch will make the command
invocation breaks.

We preventively remove this extra branch from the relevant tests in an
independant changeset to reduce noise and increase confidence in the final
change.
2016-02-08 14:02:53 +01:00
Yuya Nishihara
cd561eb91a run-tests: allow to specify executable of any name by --with-hg
If the executable is not named as "hg", TTest runner inserts alias. This
way, we can run tests with chg. But it is still warned because the alias
does not always work. We do "$BINDIR"/hg in a few places.
2016-02-07 15:21:39 +09:00
Yuya Nishihara
3ba5dbc55e run-tests: drop redundant assignment to BINDIR
We do it a few lines after.
2016-02-07 16:02:41 +09:00
Yuya Nishihara
0d8272a88a run-tests: cast --with-hg option to bytes consistently at parseargs()
parseargs() sets bytes to options.with_hg if --local is specified, so do
the same for --with-hg.
2016-02-07 16:00:05 +09:00
Yuya Nishihara
fd68b16ac6 run-tests: do not compare bytes with str while ordering tests
It failed on Python 3.
2016-02-07 15:53:02 +09:00
Gregory Szorc
44166bddc4 clonebundles: use absolute_import 2016-02-09 17:51:44 -08:00
Gregory Szorc
e3a6f51297 churn: use absolute_import 2016-02-09 17:50:45 -08:00
Gregory Szorc
2679f2b06a children: use absolute_import 2016-02-09 17:34:32 -08:00
Gregory Szorc
e63b301993 censor: use absolute_import 2016-02-09 17:33:10 -08:00
Gregory Szorc
6dc0d92138 bugzilla: use absolute_import 2016-02-09 17:31:50 -08:00
Gregory Szorc
7670e7605d blackbox: use absolute_import 2016-02-09 17:30:38 -08:00
Gregory Szorc
280f76fc24 acl: use absolute_import
Continuing the march towards Python 3.
2016-02-09 17:29:39 -08:00
Durham Goode
b46992b939 checkunknown: audit path before checking if it's a file or link
Previously we would lstat the file to see if it was a file or a link before
attempting to process it. If the file happened to exist across a symlink, and if
that symlink was pointing to a network file system, that check could be very
expensive.

The new logic audit's the path to avoid symlinks before performing the lstat on
the file itself.

In our situation, this shaved 10 minutes off of certain hg updates.
300 files * (2 seconds - the network filesystem lookup time)
2016-02-11 17:23:10 -08:00
Durham Goode
19cf6eada4 pathauditor: change parts verification order to be root first
Previously, when we verified the parts of a path in the auditor, we would
validate the deepest directory first, then it's parent, and so on up to the
root. If there happened to be a symlink in the chain, that meant our first check
would likely traverse that symlink.  In some cases that symlink might point to
a network filesystem that is expensive, and therefore this simple check could be
very slow.

The fix is to check the path parts starting at the root and working our way
down.

This has a minor performance difference in that we used to be able to short
circuit from the audit if we reached a directory that had already been checked.
Now we can't, but the cost is N dictionary look ups, where N is the number of
parts in the path, which should be fairly minor.
2016-02-11 17:04:33 -08:00
Yuya Nishihara
cf8afe35a3 chg: forward job control signals to worker process (issue5051)
This is necessary to suspend/resume long pulls, interactive curses session,
etc.

The implementation is based on emacsclient, but our version doesn't test if
chg process is foreground or not before propagating SIGCONT. This is because
chg isn't always an interactive session. If we copy the SIGTTIN/SIGTTOU
emulation from emacsclient, non-interactive session can't be moved to a
background job.

  $ chg pull
  ^Z
  suspended
  $ bg %1
  [1] continued
  [1] suspended (tty input)  # wrong

https://github.com/emacs-mirror/emacs/blob/0e96320/lib-src/emacsclient.c#L1094
2016-01-19 22:31:59 +09:00
Yuya Nishihara
31584a86d7 chg: verify return value of sigaction() and sigemptyset()
They should never fail, but it couldn't hurt to be a paranoid.
2016-01-29 22:52:16 +09:00
Yuya Nishihara
f80facd9d0 chg: initialize sigaction fields more reliably
It seems calling memset() and sigemptyset() is common pattern to initialize
sigaction. And strictly speaking, sigset_t must be initialized by sigemptyset()
or sigfillset(). I saw git and uwsgi do that way, so let's follow them.
2016-01-29 22:42:22 +09: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