Commit Graph

27722 Commits

Author SHA1 Message Date
Mason Malone
081f032818 subrepo: better error messages in _ensuregit
This patch improves the error messages raised when an OSError occurs, since
simply re-raising the exception can be both confusing and misleading. For
example, if "hg identify" is run inside a repository that contains a Git
subrepository and the git binary could not be found, it'll exit with the message
"abort: No such file or directory". That implies "identify" has a problem
reading the repository itself. There's no way for the user to know what the
real problem is unless they dive into the Mercurial source, which is what I
ended up doing after spending hours debugging errors while provisioning a VM
with Ansible (turns out I forgot to install Git on it).

Descriptive errors are especially important on Windows, since it's common for
Windows users to forget to set the "Path" system variable after installing Git.
2016-01-17 22:53:57 -05:00
Anton Shestakov
f6e436f317 hgweb: update canvas.width before dynamically redrawing graph (issue2683)
After 313b8d61b548 graph canvas width is decided once on the initial rendering.
However, after graph page gets scrolled down to load more, it might need more
horizontal space to draw, so it needs to resize the canvas dynamically.

The exact problem that this patch solves can be seen using:

    hg init testfork
    cd testfork
    echo 0 > foo
    hg ci -Am0
    echo 1 > foo
    hg ci -m1
    hg up 0
    echo 2 > foo
    hg ci -m2
    hg gl -T '{rev}\n'

    @  2
    |
    | o  1
    |/
    o  0

    hg serve

And then by navigating to http://127.0.0.1:8000/graph/tip?revcount=1

"revcount=1" makes sure the initial graph contains only revision 2. And because
the initial canvas width takes only that one revision into count, after the
(immediate) AJAX update revision 1 will be cut off from the graph.

We can safely set canvas width to the new value we get from the AJAX request
because every time graph is updated, it is completely redrawn using all the
requested nodes (in the case above it will use /graph/2?revcount=61), so the
value is guaranteed not to decrease.

P.S.: Sorry for parsing HTML with regexes, but I didn't start it.
2016-01-23 17:31:31 +08:00
Bryan O'Sullivan
95a960a422 run-tests: "fix" race condition in race condition fix
Laurent's commit 56cdfddbd2ed still suffers from a race: by the
time the "job" function tries to assign to channels[channel], that
list has been truncated to empty.  The result is that every job
thread raises an IndexError.

Earlier, I tried an approach of correctly locking channels, but
that caused run-tests to hang on KeyboardInterrupt sometimes.

This approach is strictly hackier, but seems to actually work
reliably.
2016-01-22 11:00:13 -08:00
timeless
09414997c3 rebase: restore help for rebase w/o args (issue5059)
Restoring documentation accidentally removed in 0feae227228d.
2016-01-22 20:32:47 +00:00
Martin von Zweigbergk
c28812c552 shelve: use cg3 for treemanifests
Similar to previous change, this teaches shelve to pick the right
changegroup version for repos that use treemanifests.
2016-01-19 15:37:07 -08:00
Martin von Zweigbergk
857d2206c3 repair: use cg3 for treemanifests
The newly created helper changegroup.safeversion() knows to pick
version 03 if the repo uses treemanifests, so just using that means we
pick the right changegroup version.
2016-01-19 15:38:24 -08:00
Martin von Zweigbergk
4208c8682a changegroup: introduce safeversion()
In a few places (at least repair.py and shelve.py), we want to find
the best changegroup version that we can assume users of the repo will
understand. For example, we choose version 01 by default, but if it's
a generaldelta repo, we expect clients to support version 02 anyway,
so we choose that for new bundles (for e.g. "hg strip"). Let's create
a helper for this functionality in changegroup, so we can reuse it
elsewhere later.
2016-01-19 15:32:32 -08:00
Martin von Zweigbergk
fb1b7626e4 changegroup: don't support versions 01 and 02 with treemanifests
Since it would be terribly expensive to convert between flat manifests
and treemanifests, we have decided to simply not support changegroup
version 01 and 02 with treemanifests. Therefore, let's stop announcing
that we support these versions on treemanifest repos.

Note that this means that older clients that try to clone from a
treemanifest repo will fail. What happens is that the server, after
this patch, finds that there are no common versions and raises
"ValueError: no common changegroup version". This results in "abort:
HTTP Error 500: Internal Server Error" on the client.

Before this patch, it was no better: The server would instead find
that there were directory manifest nodes to put in the changegroup 01
or 02 and raise an AssertionError on changegroup.py#668 (assert not
tmfnodes), which would also appear as a 500 to the client.
2016-01-19 14:27:18 -08:00
Laurent Charignon
bdac46ce5b run-tests: fix crash when --json and --blacklist are both used (issue5050)
This patch fixes a crash when both --json and --blacklist were given as
arguments of run-tests.py. Now, instead of crashing, we add an entry for
blacklisted tests in the json output to show that the tests were skipped.
2016-01-19 08:22:27 -08:00
Laurent Charignon
fb718d23a0 run-tests: fix race condition
Before this patch, it was possible for run-tests to crash on a race condition.
The race condition happens in the following case:
- the last test finishes and calls: done.put(None)
- the context switches to the main thread that clears the channels list
- the context switches to the last test mentioned above, it tries to access
channels[channel] and crashes
This happened to me while running run-tests.

This patch fixes the issue by clearing the channel before considering that the
test is done.
2016-01-21 12:37:12 -08:00
timeless
7c2842e773 copyright: update to 2016 2016-01-21 21:15:52 +00:00
Durham Goode
64267e6e4d transaction: abort transaction during hook exception
The new transaction context did not handle the case where an exception during
close should still call release. This cause pretxnclose hooks that failed to
cause the transaction to fail without aborting, thus requiring a hg recover.

I've added a test.
2016-01-19 15:18:21 -08:00
Matt Mackall
9f6bbc6ab6 Added signature for changeset 908046639c50 2016-01-20 22:39:51 -06:00
timeless
8d9186074f shelve: lowercase flag description
The help for --unknown is the *only* command that started with a capital letter
2016-01-21 00:20:19 +00:00
Martin von Zweigbergk
2e9366a5ee changegroup: cg3 has two empty groups *after* manifests
changegroup.getchunks() determines the end of the stream by looking
for an empty chunk group (two consecutive empty chunks). It ignores
empty groups in the first two groups. Changegroup 3 introduced an
empty chunk between the manifests and the files, which confuses
getchunks(). Since it comes after the first two, getchunks() will stop
there.

Fix by rewriting getchunks so it first counts two groups (empty or
not) and then keeps antostarts counting empty groups. With this counting,
changegroup 1 and 2 have exactly one empty group after the first two
groups, while changegroup 3 has two (one for directories and one for
files).

It's a little hard to test this at this point, but I have verified
that this patch fixes narrowhg (which was broken before this
patch). Also, future patches will fix "hg strip" with treemanifests,
and once that's done, getchunks() will be tested through tests of "hg
strip".
2016-01-19 17:44:25 -08:00
Mads Kiilerich
e251ec4f82 mq: check for reserved patch name with qimport -r (issue5033)
Fix regression from fd27c5170cac.

Catching aborts might not be pretty but it works and is a small change.
2016-01-19 06:00:59 +01:00
Mads Kiilerich
68f8e91ce2 mq: refactor makepatchname into class method 2016-01-19 06:00:30 +01:00
Laurent Charignon
7dcb9bf272 repoview: fix corrupted hiddencache crash Mercurial (issue5042)
Before this patch if the hiddencache existed but was empty, it would crash
mercurial. This patch adds exception handling when reading the hiddencache to
avoid the issue.
When encountering a corrupted cache file we print a devel warning. There would
be no point in issuing a normal warning as the user wouldn't be able to do
anything about the situation.

The warning looks like:

devel-warn: corrupted hidden cache, removing it at: /path/to/repoview.py
2016-01-20 13:43:01 -08:00
Laurent Charignon
71a4d24c5d repoview: add missing newline character in debug prints 2016-01-20 13:40:59 -08:00
Yuya Nishihara
558df9ce0f commandserver: drop tell() and seek() from channels (issue5049)
These operations are obviously invalid for file-like channels because they
will read or write protocol headers.

This patch works around the issue that "hg archive" generates a corrupted
zip file on Windows commandserver because of unusable tell() implementation.
But the problem still occurs without using a commandserver.

  $ hg archive -R not-small-repo -t zip - | cat > invalid.zip

So, this patch cannot fix the issue5049 completely.
2016-01-20 00:08:00 +09:00
Laurent Charignon
9f20d61491 crecord: edit during hg crecord should preserve cursor position (issue5041)
This patch adds a variable to keep track of what hunk was selected
before the edit. We use that variable to select the hunk or its
replacement after the edit.
2016-01-20 11:21:13 -08:00
FUJIWARA Katsunori
cd5e04a455 templates: use canvaswidth instead of fixed width for canvas (issue2683)
Before this patch, template files for "graph" web page use fixed width
size "480" for canvas element.

This causes pruned lanes and invisible vertexes, if there are 16 or
more vertical lanes at once. In such case, part of graph in right side
area over 480 is invisible, even though corresponded summary text
blocks are visible correctly.

This limitation isn't reasonable for workflow using many branches at
once (e.g. "one branch per issue" workflow).

There were changes below related to width of canvas:

  - 6c855f5350cd (templates: widen the graph canvas (issue2683)),
    released as a part of Mercurial 1.8.2

    According to the description, this assumed that 15 parallel
    branches was enough for ordinary workflow, and bumped width of
    canvas up from 224 to 480.

  - f5506d2a674c (hgweb: make graph data suitable for template usage),
    released as a part of Mercurial 2.3

    This introduced "canvaswidth" template keyword as a part of
    refactoring around graph rendering.

    But 'width="480"' of canvas element in template files wasn't
    replaced by 'width="{canvaswidth}"' in it (or subsequent one).

This patch uses dynamic value "{canvaswidth}" instead of fixed width
size "480" for canvas element.

This is posted for "stable", because:

  - this is re-fixing issue2683

  - this is simple enough for stable

  - using "{canvaswidth}" doesn't require any additional cost

    Calculation of canvaswidth is already implied as a part of "graph"
    web command.
2016-01-21 02:42:01 +09:00
Ruslan Sayfutdinov
f9fd350906 backout: fix --no-commit option (issue5054) 2016-01-20 08:16:58 -08:00
Durham Goode
4ce51c3927 bundle: exit early when there are no commits to bundle
Previously, if you passed a revset that resolved to no nodes, it would get
interpreted by the changegroup discovery logic as 'bundle all my heads', which
is not what the user asked.

Let's exit early when we notice this case.

It could be argued that the changeset discovery logic should be smarter and only
assume 'all heads' if the incoming heads parameter is None, but that's a much
riskier change.
2016-01-19 13:43:50 -08:00
Gregory Szorc
e2e4daeff4 zeroconf: access repo on hgweb_mod properly (issue5036)
hgweb_mod.hgweb.repo disappeared in 4d6522c4ac11 (hg: establish
a cache for localrepository instances) and the code for accessing repo
instances from hgweb was later refactored to go through a cache-aware
context manager.

Adapt zeroconf to access the repo instance via the new API.
2016-01-17 20:37:29 -08:00
Simon Farnsworth
bbec8fe980 shelve: permit shelves to contain unknown files
If an emergency comes in while you're in the middle of an experimental
change, it can be useful to shelve not just files hg already tracks but
also your unknown files while you handle the emergency. This is
especially true if you have hooks intended to prevent you from
forgetting to add new code before you push.

Teach "hg shelve" to optionally shelve unknown files, not just tracked
files. This is functionally similar to --addremove, but with two
differences:

 1) Deleted files are not removed.
 2) Files added during shelve creation are tracked in extra so that they
    can be forgotten by "hg unshelve".

When unshelving, we take care to only forget files if they've been
created during the unshelve operation; if you add a file that's being
tracked in a shelve as an unknown file, it should not become unknown
again when the shelve is unshelved.
2016-01-14 10:03:31 -08:00
Gregory Szorc
b16347f628 localrepo: don't reference transaction from hook closure (issue5043)
Before, the hook() closure (which is called as part of locking hooks)
would maintain a reference to a transaction instance (which should be
finalized by the time lock hooks are called). Because we accumulate
hook() instances when there are multiple transactions per lock, this
would result in holding references to the transaction instances which
would lead to higher memory utilization.

Creating a reference to the hook arguments dict minimizes the number
of objects that are kept alive until the lock release hook runs,
minimizing memory "leaks."
2016-01-17 14:14:15 -08:00
Gregory Szorc
fbab5f0c4c context: don't use util.cachefunc due to cycle creation (issue5043)
util.cachefunc stores all arguments as the cache key. For filectxfn
functions, the arguments include the memctx instance. This creates a
cycle where memctx._filectxfn references self. This causes a memory
leak.

We break the cycle by implementing our own memoizing function that
only uses the path as the cache key. Since each memctx has its own
cache instance, there is no concern about invalid cache hits.
2016-01-17 12:10:30 -08:00
Mads Kiilerich
86e0c59b98 largefiles: actions will now always have a file - drop check 2016-01-17 19:29:27 +01:00
Mads Kiilerich
ac2e1602ce largefiles: make prompt order deterministic
c23a6f1bb59b introduced iteration of a set. Make it stable.
2016-01-17 19:29:27 +01:00
Mads Kiilerich
76651c0e10 largefiles: fix commit of missing largefiles
92117e4f6f8d improved merging of standin files referencing missing largefiles.
It did however not test or fix commits of such merges; it would abort.

To fix that, change copytostore to skip and warn about missing largefiles
with a message similar the one for failing get from remote filestores. (It
would perhaps in both cases be better to emit a more helpful warning like
"warning: standin file for large1 references 58e24f733a which can't be found in
the local store".)

To test this, make sure commit doesn't find the "missing" largefile in the global
usercache. For further testing, verify that update and status works as expected
after this.

This will also effectively backout 159c82dd6523.
2016-01-17 17:23:32 +01:00
Martin von Zweigbergk
216d0e41ef diff: don't crash when merged-in addition is copied
Similar to what was explained in the previous commit, the diff code
expected copy source to be in "ctx1", which is not always the case
during a merge. This has been broken since before hg 2.0.

Also similar to the previous commit, we fix the problem by fixing up
the copy dict.
2016-01-14 10:22:55 -08:00
Martin von Zweigbergk
0c3407d70e diff: don't crash when merged-in addition was removed (issue4786)
During a merge, if the user removes a file that came from parent 2 and
did not exist in parent 1, the file's status will be "removed". This
surprises the diff code, which crashes because it expects removed
files exist in parent 1. This has been broken since ff976121fb34
(trydiff: use 'not in addedset' for symmetry with 'not in removedset',
2014-12-23).

Fix by fixing up the list of removed file, similar to how we currently
fix up the list of modified and added files during a merge.
2016-01-14 10:14:24 -08:00
Martin von Zweigbergk
cf817770b1 diff: move status fixup earlier, out of _filepairs()
This prepares for future patches, and it also lets us remove the ugly
"ctx1" argument to _filepairs() (ugly because of its assymmetry --
there's no "ctx2" argument).
2016-01-14 10:02:34 -08:00
Mads Kiilerich
9f1efa7c96 graft: warn when -r is combined with revisions as positional arguments
The behaviour in this case is undefined. Instead of silently doing something
"random" and surprising, at least issue a warning.

(This should perhaps be considered a "deprecation" and turned into an error in
a future release.)
2016-01-17 19:33:02 +01:00
Mads Kiilerich
200157f1b5 graft: clarify in help that -r is not just optional
Positional parameters are also treated as revisions, but the order of revisions
matters and it will often be wrong if the user understands it as `-r` taking
multiple revisions as `-r REV1 REV2`.

(Alternatively, `-r` could be turned into a no-op flag as the documentation
suggests. That would however be less "semantic markup" and I agree with the
implementation in 40cbb25097c8 but not the documentation.)
2016-01-17 19:33:02 +01:00
Gregory Szorc
a05892eae0 streamclone: use backgroundfilecloser (issue4889)
Closing files that have been appended to is slow on Windows/NTFS.
CloseHandle() calls on this platform often take 1-10ms - and that's
on my i7-6700K Skylake processor with a modern and fast SSD. Contrast
with other I/O operations, such as writing data, which take <100us.

This means that creating/appending thousands of files can add
significant overhead. For example, cloning mozilla-central creates
~232,000 revlog files. Assuming 1ms per CloseHandle(), that yields
232s (3:52) of wall time waiting for file closes!

The impact of this overhead can be measured most directly when applying
stream clone bundles. Applying these files is effectively uncompressing
a tar archive (read: it's very fast).

Using a RAM disk (read: no I/O wait), the difference in wall time for a
`hg debugapplystreamclonebundle` for a ~1731 MB mozilla-central bundle
between Windows and Linux from the same machine is drastic:

Linux:    ~12.8s (128MB/s)
Windows: ~352.0s (4.7MB/s)

Windows is ~27.5x slower. Yikes!

After this patch:

Linux:    ~12.8s (128MB/s)
Windows: ~102.1s (16.1MB/s)

Windows is now ~3.4x faster. Unfortunately, it is still ~8x slower than
Linux. Profiling reveals a few hot code paths that could likely be
improved. But those are for other patches.

This patch introduces test-clone-uncompressed.t because existing tests
of `clone --uncompressed` are scattered about and adding a variation for
background thread closing to e.g. test-http.t doesn't feel correct.
2016-01-14 13:44:01 -08:00
Gregory Szorc
ba2d05e908 streamclone: indent code
This will make the subsequent patch easier to read.
2016-01-02 16:11:36 -08:00
Gregory Szorc
49c61f06be scmutil: support background file closing
Closing files that have been appended to is relatively slow on
Windows/NTFS. This makes several Mercurial operations slower on
Windows.

The workaround to this issue is conceptually simple: use multiple
threads for I/O. Unfortunately, Python doesn't scale well to multiple
threads because of the GIL. And, refactoring our code to use threads
everywhere would be a huge undertaking. So, we decide to tackle this
problem by starting small: establishing a thread pool for closing
files.

This patch establishes a mechanism for closing file handles on separate
threads. The coordinator object is basically a queue of file handles to
operate on and a thread pool consuming from the queue.

When files are opened through the VFS layer, the caller can specify
that delay closing is allowed.

A proxy class for file handles has been added. We must use a proxy
because it isn't possible to modify __class__ on built-in types. This
adds some overhead. But as future patches will show, this overhead
is cancelled out by the benefit of closing file handles on background
threads.
2016-01-14 13:34:59 -08:00
Yuya Nishihara
c998aff68a templatekw: add {namespaces} keyword
This provides a general-purpose interface to all custom namespaces.

The {namespaces} keyword honors the definition order of namespaces as they
are kept by sortdict.
2016-01-12 23:56:48 +09:00
Yuya Nishihara
dbf185d983 templatekw: move shownames() helper to be sorted alphabetically
I'll add shownamespaces(), which is similar to this function. I want to put
them nearby.
2016-01-12 23:53:56 +09:00
Yuya Nishihara
e2a7f69128 templater: make get(dict, key) return a single value
This is necessary to obtain a _hybrid object from a dict. If get() yields
a value, it would be stringified.

I see no benefit to make get() lazy, so this patch just changes "yield" to
"return".
2016-01-16 13:53:32 +09:00
Yuya Nishihara
20aed11e76 templater: make _hybrid not callable to avoid conflicting semantics
In templater, a callable symbol exists for lazy evaluation, which should have
f(**mapping) signature. On the other hand, _hybrid.__call__(), which was
introduced by 4e182fb53989, generates mapping for each element.

This patch renames _hybrid.__call__() to _hybrid.itermaps() so that a _hybrid
object can be a value of a mapping dict.

  {namespaces % "{namespace}: {names % "{name }"}\n"}
                               ~~~~~
                               a _hybrid object
2016-01-16 13:42:37 +09:00
Ruslan Sayfutdinov
3f980f0f17 backout: commit changeset by default (BC)
Add --no-commit flag to prevent it. This should make the hg user
experience a little better. Some discussion can be found here:
http://markmail.org/message/7jm7ro2ias6hxywy
2016-01-15 13:46:33 -08:00
Danek Duvall
66247223e5 help: move Windows 9x information to appropriate place 2016-01-15 13:01:37 -08:00
Simon Farnsworth
1d446c79cb shelve: move commitfunc closer to use site
Supporting shelving of unknown files needs this code motion.

No functional changes.
2016-01-14 12:52:59 -08:00
Gregory Szorc
05359af187 commands: document clone bundles hooks and rollback behavior
The added content is inside a verbose container.

I figure it makes sense to explicitly document behavior, including
with the caveat it may change later. People can't say they weren't
warned!
2016-01-14 21:21:59 -08:00
Gregory Szorc
bdc9fb8c76 clonebundles: improve BUNDLESPEC documentation
Before the existence of `hg debugbundle --spec`, the process for
defining the BUNDLESPEC value in manifests was not very clear and not
trivial to automate, especially in the case of stream clone bundles.

This patch adds documentation to note the existence of
`hg debugbundle --spec`. We drop the reference to stream clone
requirements handling because it is now redundant with
`hg debugbundle --spec`. While we are here, we further reinforce the
importance of defining BUNDLESPEC.
2016-01-14 22:50:55 -08:00
Gregory Szorc
3a890f3e32 commands: teach debugbundle to print bundle specification
This seems like the most logical place to put this functionality.

Test coverage over existing known bundle specs has been added.
2016-01-14 22:57:55 -08:00
Gregory Szorc
274b1c944c commands: use context manager for opened bundle file 2016-01-14 21:27:53 -08:00