Commit Graph

9513 Commits

Author SHA1 Message Date
Pierre-Yves David
7443f70cc2 bundlerepo: properly handle hidden linkrev in filelog (issue4945)
The bundlerepository have to do some special magic to handle linkrev of the
bundlerepo filerev. That logic was done from a repoview and obsolescence marker
affecting bundled changeset could lead to a crash. We now ensure we operate on
unfiltered repository.
2016-02-22 18:35:40 +01:00
Pierre-Yves David
afc2550500 revert: properly revert to ancestor of p2 during merge (issue5052)
During merge, added (from one perspective) file can be reported as "modified".
To work around that, revert was testing if modified file were present in the
parent manifest and marking them as "added" in this case. However, we should be
checking against the target revision manifest instead. Otherwise see file as
"newly added" even if they exist in the target revision.

That revert behavior regressed in 3657ae7519b7.
2016-02-23 11:41:47 +01:00
Yuya Nishihara
02e214117d ui: fix crash by non-interactive prompt echo for user name
Since we've dropped a str cast at write() by 7dbd3db608c5, ui.prompt() should
convert default to '' if it is None. Otherwise, write() would fail with
"TypeError: object of type 'NoneType' has no len()".

This patch includes the tests for both interactive and non-interactive cases
because "ui.askusername" was never tested.
2016-02-06 20:43:20 +09:00
Yuya Nishihara
61b45241f5 zeroconf: forward all arguments passed to ui.configitems() wrapper
cf6cc5344afa added 'ignoresub' argument to ui.configitems(), but zeroconf
wrapper wasn't updated. It caused the following crash:

  Traceback (most recent call last):
    File "bin/hg", line 43, in <module>
      mercurial.dispatch.run()
    File "lib/python/mercurial/dispatch.py", line 54, in run
      sys.exit((dispatch(request(sys.argv[1:])) or 0) & 255)
    File "lib/python/mercurial/dispatch.py", line 120, in dispatch
      ret = _runcatch(req)
    File "lib/python/mercurial/dispatch.py", line 191, in _runcatch
      return _dispatch(req)
    File "lib/python/mercurial/dispatch.py", line 924, in _dispatch
      cmdpats, cmdoptions)
    File "lib/python/mercurial/dispatch.py", line 681, in runcommand
      ret = _runcommand(ui, options, cmd, d)
    File "lib/python/mercurial/extensions.py", line 195, in closure
      return func(*(args + a), **kw)
    File "lib/python/hgext/zeroconf/__init__.py", line 180, in cleanupafterdispatch
      return orig(ui, options, cmd, cmdfunc)
    File "lib/python/mercurial/dispatch.py", line 1055, in _runcommand
      return checkargs()
    File "lib/python/mercurial/dispatch.py", line 1015, in checkargs
      return cmdfunc()
    File "lib/python/mercurial/dispatch.py", line 921, in <lambda>
      d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
    File "lib/python/mercurial/util.py", line 991, in check
      return func(*args, **kwargs)
    File "lib/python/mercurial/commands.py", line 5405, in paths
      pathitems = sorted(ui.paths.iteritems())
    File "lib/python/mercurial/util.py", line 723, in __get__
      result = self.func(obj)
    File "lib/python/mercurial/ui.py", line 619, in paths
      return paths(self)
    File "lib/python/mercurial/ui.py", line 1099, in __init__
      for name, loc in ui.configitems('paths', ignoresub=True):
    File "lib/python/mercurial/extensions.py", line 195, in closure
      return func(*(args + a), **kw)
  TypeError: configitems() got an unexpected keyword argument 'ignoresub'

We have no test coverage for zeroconf, so I've added a minimal test that
could reproduce this problem.
2016-02-10 22:53:17 +09: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
Yuya Nishihara
1f60c51fa5 templater: abort if infinite recursion detected while compiling
In this case, a template is parsed recursively with no thunk for lazy
evaluation. This patch prevents recursion by putting a dummy of the same name
into a cache that will be referenced while parsing if there's a recursion.

  changeset = {files % changeset}\n
                       ~~~~~~~~~
                        = [(_runrecursivesymbol, 'changeset')]
2015-07-23 23:41:29 +09:00
Yuya Nishihara
554208ae8f templater: abort if infinite recursion detected while evaluation (issue4758)
It would be nice if we could detect recursion at the parsing phase, but we
can't because a template can refer to a keyword of the same name. For example,
"rev = {rev}" is valid if rev is a keyword, and we don't know if rev is a
keyword or a template while parsing.
2015-07-22 23:29:41 +09:00
Martin von Zweigbergk
d1531da666 exchange: set 'treemanifest' param on pushed changegroups too
In 7a1ccfe03f74 (treemanifests: set bundle2 part parameter indicating
treemanifest, 2016-01-08), I didn't realize I had to set the parameter
separately for getbundle and unbundle. Having the parameter there on
push allows us to push to an empty repo and have the requirements
updated correctly.
2016-01-22 16:31:50 -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
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
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
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
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
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
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
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
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
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
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
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
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
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
timeless
fafbbff385 run-tests: skip threading for a single test (issue5040)
This version backs out 69d5cadd84a0 and implements it in
a more consistent manner.
2016-01-14 04:14:50 +00:00
Matt Mackall
a8fcfbf03d copies: fix detection of divergent directory renames
If we move all the files out of one directory, but into two different
directories, we should not consider it a directory rename. The
detection of this case was broken.
2016-01-13 10:10:05 -06:00
Danek Duvall
6a2d89e5fb tests: non-GNU mv can't move a file onto a hardlink of itself
On Solaris, when you try to mv a file to another path that is a hardlink to
the original, it complains that they're identical.  GNU mv doesn't
complain, but it's simpler to just remove the original file instead.
2016-01-14 13:33:08 -08:00
Bryan O'Sullivan
95772fe4ca test-ctxmanager: fix Python 2.6 compatibility problem 2016-01-14 09:31:03 -08:00
Bryan O'Sullivan
506a2494ba util: rename ctxmanager's __call__ method to enter 2016-01-14 09:31:01 -08:00
timeless
6128260f9d check-commit: sort errors by line number 2016-01-12 08:34:38 +00:00