Commit Graph

15129 Commits

Author SHA1 Message Date
Christian Delahousse
49f274e0e0 git-subrepos: revert respects specified location to save .orig files
This patch makes revert in git subrepos save .orig files where the user wants
them by using the cmdutil.origpath function.
2015-11-10 14:29:13 -08:00
Christian Delahousse
a53e055553 resolve: choose where .orig file locations are kept
Having your working copy littered with .orig files is a common HG complaint.
This patch uses the cmd.origpath helper function to let the user
specify where they should be kept when using the resolve command.
2015-11-10 14:26:19 -08:00
Christian Delahousse
f5b2078fe3 revert: allow configuring the .orig file location 2015-11-12 17:00:08 -06:00
Christian Delahousse
71afd0e97f cmdutil: add origbackuppath helper 2015-11-12 16:56:06 -06:00
Ryan McElroy
3f80624a78 discovery: pass pushop to _nowarnheads
Previously, we passed only enough information to _nowarnheads to perform the old
calculation. However, extensions may want to use more information in this
calculation. Now that pushop is extensible, extensions will often want access
to the additional fields they have added to the pushop, so pass that through.

Specifically, the remotenames extension will use this information to allow
pushing new heads that are bookmarked without requiring --force.
2015-11-10 11:16:25 -08:00
Ryan McElroy
f7b3bc72e8 exchange: pass pushop to discovery.checkheads
Previously, we passed a bunch of parameters to discovery.checkheads, but all
of the arguments can be fetched out of pushop, which may contain a lot more
useful information for extensions now that pushop is extensible.
2015-11-10 11:13:21 -08:00
Pierre-Yves David
2e9e629297 stream: sort stream capability before serialisation
We want that capability to be stable in our testing. This is currently not an
issue because the set is size 1, but this will be once generaldelta related
data gets in there.
2015-10-20 12:28:42 +02:00
Durham Goode
d0bab13283 phase: improve retractboundary perf
The existing retractboundary implementation computed the new boundary by walking
all descendants of all existing roots and computing the new roots. This is
O(commits since first root), which on long repos can be hundreds of thousands of
commits.

The new algorithm only updates roots that are greater than the new root
locations. For common operations like commit on a repo with the earliest root
several hundred thousand commits ago, this makes retractboundary go from
1 second to 0.008 seconds.

I tested it by running the test suite with both implementations and checking
that the root results were always the identical.

There was some discussion on IRC about the safety of this (i.e. what if the new
nodes are already part of the phase, etc).  I've looked into it and believe this
patch is safe:

1) The old existing code already filters the input nodes to only contain nodes
   that require retracting (i.e. we only make node X a new root if the old phase
   is less than the target phase), so there's no chance of us adding a
   unnecessary root to the phase (unless the input root is made unnecessary by
   another root in the same input, but see point #3).

2) Another way of thinking about this is:  the only way the new algorithm would
   be different from the old algorithm is if it added a root that is a
   descendant of an old root (since the old algorithm would've caught this in
   the big "roots(%ln::)".  At the beginning of the function, when we filter out
   roots that already meet the phase criteria, the *definition* of meeting the
   phase criteria is "not being a descendant of an existing root".  Therefore,
   by definition none of the new roots we are processing are descendants of an
   existing root.

3) If two nodes are passed in as input, and one node is an ancestor of the other
   (and therefore the later node should not be a root), this is still caught by
   the 'roots(%ln::)' revset. So there's no chance of an extra root being
   introduced that way either.
2015-11-07 16:11:49 -08:00
Pierre-Yves David
c8b7676e04 format: introduce 'format.usegeneraldelta`
This option will make repositories created as general delta by default but will
not make Mercurial aggressively recompute deltas for all incoming bundle.
Instead, the delta contained in the bundle will be used. This will allow us to
start having general delta repositories created everywhere without triggering
massive recomputation costs for all new clients cloning from old servers.
2015-11-02 15:59:12 +00:00
Pierre-Yves David
474dfeda7e scmutil: extract general delta config handling in a function
General delta is currently controlled by a single option, we will introduce a
new one in the next changeset.

We extract the logic in a function while it is simple.
2015-11-02 16:52:34 +00:00
Matt Mackall
0a9df707c8 merge with stable 2015-11-11 15:08:08 -06:00
Matt Mackall
2dd39095d7 posix: fix test-permissions regression 2015-11-09 15:53:11 -06:00
Mateusz Kwapich
266a6f869e dirstate: fix filefoldmap incosistency on file delete
The _filefoldmap is not updated in when files are deleted from dirstate. In the
case where the file with the same but differently cased name is added afterwards
it renders _filefoldmap incorrect.  Those steps must occur to for a problem to
reproduce:
 - call status (with listunknown=True),
 - update working rectory to a commit which does a casefolding change (A -> a)
 - call status again (it will show the file "a" as deleted)

Unfortunately I'm unable to write a test for it because I don't know any
core-mercurial command able to reproduce those steps.

The bug was originally spotted when hgwatchman was enabled. It caused the
changeset contents change during hg rebase (one file unrelarted to changeset
was deleted in it after rebase).

The hgwatchman is able to hit it because when hgignore changes the hgwatchmans
overridestatus is calling original status with listunknown=True.
2015-11-09 10:43:23 -08:00
Matt Mackall
8b9a3d960f posix: retry on symlink race in checklink
Multiple threads might attempt to check links with the same temporary
name. This would cause one side to get an EEXIST error and wrongly
fail the support check. Here, we simply retry if our temporary name
exists.
2015-11-06 15:23:10 -06:00
Pierre-Yves David
f89772113f changegroup: back code change of b5988e1d3dcb out
The previous changeset is a simpler way of fixing issue4934 without changing the
spirit of the code. We can remove the dual call to 'delayupdate' but we keep the
tests to show that the issue is still fixed.
2015-11-06 13:01:15 -05:00
Pierre-Yves David
dfd6e44ebe changegroup: call 'prechangegroup' hook before setting up write delay
The 'prechangegroup' interfere with 'delayupdate' logic because it trigger the
one time call of 'changelog._writepending' (see issure4934). There is no reason
not to call that hook before setting up 'delayupdate' so we move the call a bit
earlier to avoid interference.
2015-11-06 12:59:09 -05:00
Pierre-Yves David
107254a73d changegroup: fix the scope of a try finally
The try finally is here to ensure we release the just-created transaction.
Therefore we should not do half a dozen operations before actually entry the try
scope.
2015-11-06 12:39:06 -05:00
Augie Fackler
578db94dcb verify: add a hook that can let extensions manipulate file lists
Without a hook of this nature, narrowhg[0] clones always result in 'hg
verify' reporting terrible damage to the entire repository
history. With this hook, we can ignore files that aren't supposed to
be in the clone, and then get an accurate report of any damage present
(or not) in the repo.

0: https://bitbucket.org/Google/narrowhg
2015-11-04 12:14:18 -05:00
Siddharth Agarwal
85a4c599d3 resolve: don't abort when file is missing
A file being missing is a completely valid situation in which the user may want
to re-resolve merge conflicts. Mercurial already maintains backups of local
data, so this turns out to be easy to handle.
2015-11-10 17:16:59 -08:00
Siddharth Agarwal
32de813627 filemerge: treat EOF at prompt as fail, not abort
Previously we'd abort the merge entirely if there was an EOF at the prompt.
This is unnecessary -- it's much better to simply fail and treat the file as
unresolved instead.
2015-11-10 17:13:16 -08:00
Siddharth Agarwal
6e6f3927e3 error: add structured exception for EOF at prompt
We'll catch this exception for promptchoice queries to provide better error
handling.
2015-11-10 00:46:45 -08:00
Anton Shestakov
90da27730e hgweb: compute changeset parents and children for log pages lazily
Log pages, i.e. changelog, filelog and search results page computed children
and parents for each changeset shown, because spartan hgweb style shows this
info. Turns out, computing all this is heavy and also unnecessary for log pages
in all other hgweb styles.

Luckily, templates allow an easy way to do computations on demand: just pass
the heavy part of code as a callable and it will be only called when needed.

Here are some benchmarks on the mercurial repository (best of 3):

time wget http://127.0.0.1:8021/

before: 0m0.050s
after:  0m0.040s

time wget http://127.0.0.1:8021/?revcount=960

before: 0m1.164s
after:  0m0.389s

time wget http://127.0.0.1:8021/log/tip/mercurial/commands.py

before: 0m0.047s
after:  0m0.042s

time wget http://127.0.0.1:8021/log/tip/mercurial/commands.py?revcount=960

before: 0m0.830s
after:  0m0.434s
2015-11-10 23:02:59 +08:00
Siddharth Agarwal
ddc0857ff8 filemerge: move :merge-local/other symlink check to precheck
In upcoming patches we're going to add more checks to the function currently
named _symlinkcheck. This consolidates all those checks.
2015-11-08 23:42:44 -08:00
Matt Mackall
14c5bb7714 merge with stable 2015-11-09 12:49:21 -06:00
Matt Mackall
85a6f7932d encoding: re-escape U+DCxx characters in toutf8b input (issue4927)
This is the final missing piece in fully round-tripping random byte
strings through UTF-8b. While this issue means that UTF-8 <-> UTF-8b
isn't fully bijective, we don't expect to ever see U+DCxx codepoints
in "real" UTF-8 data, so it should remain bijective in practice.
2015-11-05 17:30:10 -06:00
Matt Mackall
09bfc43ef0 encoding: use getutf8char in toutf8b
This correctly avoids the ambiguity of U+FFFD already present in the
input and similar confusion by working a character at a time.
2015-11-05 17:21:43 -06:00
Matt Mackall
cc7a93dfa3 encoding: handle non-BMP characters in fromutf8b 2015-11-05 17:11:50 -06:00
Matt Mackall
001845ef91 posix: use getutf8char to handle OS X filename percent-escaping
This replaces an open-coded utf-8 parser that was ignoring subtle issues
like overlong encodings.
2015-11-05 17:09:00 -06:00
Matt Mackall
322dbe32ca encoding: add getutf8char helper
This allows us to find character boundaries in byte strings when
trying to do custom encodings.
2015-11-05 16:48:46 -06:00
Pierre-Yves David
61ac4561fd unbundle: gratuitous fix white spacing "issue"
We were missing one space on this block.
2015-11-07 16:03:09 -05:00
Durham Goode
9980cf1bdd manifest: skip fastdelta if the change is large
In large repos, the existing manifest fastdelta computation (which performs a
bisect on the raw manifest for every file that is changing), is excessively
slow. This patch makes fastdelta fallback to the normal string delta algorithm
if the number of changes is large.

On a large repo with a commit of 8000 files, this reduces the commit time by 7
seconds (fastdelta goes from 8 seconds to 1).

I tested this change by modifying the function to compare the old and the new
values and running the test suite. The only difference is that the pure
text-diff algorithm sometimes produces smaller (but functionaly identical)
deltatexts than the bisect algorithm.
2015-11-05 18:56:40 -08:00
Siddharth Agarwal
11e83e49ad merge.mergestate: update docstrings for preresolve and resolve
Add a docstring for preresolve, and update the one for resolve.
2015-11-04 23:44:51 -08:00
Yuya Nishihara
44b7401396 demandimport: fix level passed to loader of sub-modules
As the fromlist gives the names of sub-modules, they should be searched in
the parent directory of the package's __init__.py, which is level=1.

I got the following error by rewriting hgweb to use absolute_import, where
the "mercurial" package is referenced as ".." (level=2):

  ValueError: Attempted relative import beyond toplevel package

I know little about the import mechanism, but this change seems correct.
Before this patch, the following code did import the os module with no error:

  from mercurial import demandimport
  demandimport.enable()
  from mercurial import os
  print os.name
2015-11-01 21:19:09 +09:00
Yuya Nishihara
557c963f7b parsers: fix width of datalen variable in fm1readmarkers
Because parsers.c does not define PY_SSIZE_T_CLEAN, "s#" format requires
(const char*, int), not (const char*, Py_ssize_t).

https://docs.python.org/2/c-api/arg.html

This error had no problem before 7d13be5f72c2, where datalen wasn't used.
But now fm1readmarkers() fails with "overflow in obsstore" on Python 2.6.9
(amd64) because upper bits of datalen seem to be filled with 1, making it
a negative integer.

This problem seems not visible on our Python 2.7 environment because upper
bits happen to be filled with 0.
2015-11-07 17:43:20 +09:00
Pierre-Yves David
be4dcab05b hooks: back e7b51de6e8eb out
Changeset e7b51de6e8eb alters the 'HG_PENDING' mechanism to be "always" there.
This change is made under the assumption than we previously did it only when
"writepending() actually wrote something". This assumption was wrong,
'writepending()' informs of pending changes the first time something is written
and for all following calls. We back this change out to restore the former
behavior, which was already correct.
2015-11-06 11:08:11 -05:00
Durham Goode
49c25cc444 hooks: fix hooks not firing if prechangegroup was set (issue4934)
We need to call delayupdate again after writing to the changelog.
Otherwise the prechangegroup hook consumes the delayupdate subscription and
future hooks don't see the pending changes (see issue 4934 for more details).

Adds a test that triggers the prechangegroup hook before the pretxnchangegroup
hook and verifies that the output of pretxnchangegroup doesn't change.
2015-11-03 17:13:27 -08:00
Durham Goode
8bdfd3d55c hooks: always include HG_PENDING
Previously we would only include HG_PENDING in the hook args if the
transaction's writepending() actually wrote something. This is a bad criteria,
since it's possible that a previous call to writepending() wrote stuff and the
hooks want to still see that.

The solution is to always have hooks execute within the scope of the pending
changes by always putting HG_PENDING in the environment.
2015-11-03 16:58:13 -08:00
Gregory Szorc
61b9ffeec8 wireproto: move clonebundles command from extension (issue4931)
The SSH peer class accesses wireproto.commands[cmd] as part of encoding
command arguments. Previously, the wire protocol command was defined in
the clonebundles extension. If the client didn't have this extension
enabled (which it likely doesn't since it is meant as a server-side
extension), then clients attempting to clone via ssh:// would get a
crash due to a KeyError accessing wireproto.commands['clonebundles']
when cloning from a server that is advertising clone bundles.

Moving the definition of the wire protocol command to wireproto.py makes
this problem go away.

A side effect of this code move is servers will always respond to
"clonebundles" wire protocol command requests. This should be fine: the
server will return an empty response unless a clone bundles manifest
file is present and clients shouldn't call the command unless the server
is advertising the capability, which only happens if the clonebundles
extension is enabled and the manifest file exists.
2015-11-03 12:31:33 -08:00
Yuya Nishihara
dda890d7ab templatefilters: try round-trip utf-8 conversion by json filter (issue4933)
As JSON string is known to be a unicode, we should try round-trip conversion
for localstr type. This patch tests localstr type explicitly because
encoding.fromlocal() may raise Abort for undecodable str, which is probably
not what we want. Maybe we can refactor json filter to use encoding module
more later.

Still "{desc|json}" can't round-trip because showdescription() modifies a
localstr object.
2015-11-04 23:48:15 +09:00
Gregory Szorc
9a4b9852b5 exchange: do not attempt clone bundle if local repo is non-empty (issue4932) 2015-11-03 12:16:54 -08:00
Matt Harbison
de09629866 scmutil: abort if an empty revision is given to revpair()
When using 'extdiff --patch' to check the changes in a rebase, 'precursors(x)'
evaluated to an empty set because I forgot the --hidden flag, so the other
revision was used as the replacement for the empty set.  The result was the
patch for the other revision was diffed against itself, and the tool saying
there were no differences.  That's misleading since the expected diff args were
silently changed, so it's better to bail out.

The other uses of scmutil.revpair() are commands.diff and commands.status, and
it doesn't make sense to allow an empty revision there either.  The code here
was suggested by Yuya Nishihara.
2015-10-31 21:45:46 -04:00
Anton Shestakov
04c432b846 hgweb: escape class keyword when used as a js object property (issue4913) 2015-10-27 12:34:05 +08:00
FUJIWARA Katsunori
f850c84e84 localrepo: discard objects in _filecache at transaction failure (issue4876)
'repo.invalidate()' deletes 'filecache'-ed properties by
'filecache.__delete__()' below via 'delattr(unfiltered, k)'. But
cached objects are still kept in 'repo._filecache'.

    def __delete__(self, obj):
        try:
            del obj.__dict__[self.name]
        except KeyError:
            raise AttributeError(self.name)

If 'repo' object is reused even after failure of command execution,
referring 'filecache'-ed property may reuse one kept in
'repo._filecache', even if reloading from a file is expected.

Executing command sequence on command server is a typical case of this
situation (e0a0f9ad3e4c also tried to fix this issue). For example:

  1. start a command execution

  2. 'changelog.delayupdate()' is invoked in a transaction scope

     This replaces own 'opener' by '_divertopener()' for additional
     accessing to '00changelog.i.a' (aka "pending file").

  3. transaction is aborted, and command (1) execution is ended

     After 'repo.invalidate()' at releasing store lock, changelog
     object above (= 'opener' of it is still replaced) is deleted from
     'repo.__dict__', but still kept in 'repo._filecache'.

  4. start next command execution with same 'repo'

  5. referring 'repo.changelog' may reuse changelog object kept in
     'repo._filecache' according to timestamp of '00changelog.i'

     '00changelog.i' is truncated at transaction failure (even though
     this truncation is unintentional one, as described later), and
     'st_mtime' of it is changed. But 'st_mtime' doesn't have enough
     resolution to always detect this truncation, and invalid
     changelog object kept in 'repo._filecache' is reused
     occasionally.

     Then, "No such file or directory" error occurs for
     '00changelog.i.a', which is already removed at (3).

This patch discards objects in '_filecache' other than dirstate at
transaction failure.

Changes in 'invalidate()' can't be simplified by 'self._filecache =
{}', because 'invalidate()' should keep dirstate in 'self._filecache'

'repo.invalidate()' at "hg qpush" failure is removed in this patch,
because now it is redundant.

This patch doesn't make 'repo.invalidate()' always discard objects in
'_filecache', because 'repo.invalidate()' is invoked also at unlocking
store lock.

  - "always discard objects in filecache at unlocking" may cause
    serious performance problem for subsequent procedures at normal
    execution

  - but it is impossible to "discard objects in filecache at unlocking
    only at failure", because 'releasefn' of lock can't know whether a
    lock scope is terminated normally or not

    BTW, using "with" statement described in PEP343 for lock may
    resolve this ?

After this patch, truncation of '00changelog.i' still occurs at
transaction failure, even though newly added revisions exist only in
'00changelog.i.a' and size of '00changelog.i' isn't changed by this
truncation.

Updating 'st_mtime' of '00changelog.i' implied by this redundant
truncation also affects cache behavior as described above.

This will be fixed by dropping '00changelog.i' at aborting from the
list of files to be truncated in transaction.
2015-10-24 18:58:57 +09:00
Gábor Stefanik
9c2ffda81c demandimport: fix TypeError when importing Python regex library (issue4920) 2015-10-28 16:27:09 +01:00
Anton Shestakov
001b2cf88b hgweb: remove unused colorPart() from mercurial.js
Looks like the function wasn't ever used since its introduction in
083571f47ff6, since setColor() below always used "rgb(255, 255, 255)" notation
which doesn't need hex digits.
2015-10-24 09:47:33 +01:00
Gregory Szorc
059667a51c bundle2: attribute remote failures to remote (issue4788)
Before bundle2, hook output from hook failures was prefixed with
"remote: ". Up to this point with bundle2, the output was converted to
the message to print in an Abort exception. This had 2 implications:

1) It was unclear whether an error message came from the local repo
   or the remote
2) The exit code changed from 1 to 255

This patch changes the handling of error:abort bundle2 parts during push
to prefix the error message with "remote: ". This restores the old
behavior.

We still preserve the behavior of raising an Abort during bundle2
application failure. This is a regression from pre-bundle2 because the
exit code changed.

Because we no longer raise an Abort with the remote's message, we needed
to insert a message for the new Abort. So, I invented a new error
message for that. This is another change from pre-bundle2. However, I
like the new error message because it states unambiguously who aborted
the push failed, which I think is important for users so they can decide
what's next.
2015-10-24 00:39:22 +01:00
Yuya Nishihara
0ef9d443e7 help: mention alias and revsetalias in description of HGPLAINEXCEPT 2015-10-24 06:59:26 +01:00
Augie Fackler
8501cbfa05 debugrevlog: cope with empty revlog files
I have no idea where it came from, but my clone of Mercurial has an
empty filelog for `contrib/hgfixes/__init__.py` - it's *valid*, just
contains no nodes. Without this change, debugrevlog crashes with a
zero division error.
2015-10-23 11:04:53 -04:00
Augie Fackler
86f88ad861 merge: improve clarity of table in update docstring 2015-10-23 06:06:22 -04:00
Gregory Szorc
51ee0dd173 ui: support paths.default-push without paths.default set (issue4914)
This behavior regressed as part of the paths API refactoring. Previous
behavior was to accept "default-push" without "default" defined. Current
behavior aborts with "default repository not configured!." This patch
restores the old behavior and adds test coverage for the scenario, which
was absent before.
2015-10-22 18:59:03 +00:00