Commit Graph

20032 Commits

Author SHA1 Message Date
Brodie Rao
b2b08444eb branchmap: introduce branchtip() method 2013-09-16 01:08:29 -07:00
Brodie Rao
a446720e09 branchmap: cache open/closed branch head information
This lets us determine the open/closed state of a branch without
reading from the changelog (which can be costly over NFS and/or with
many branches).
2013-09-16 01:08:29 -07:00
Stephen Lee
7b97b6250a bookmarks: allow push -B to create a new remote head (issue2372)
Push is currently allowed to create a new head if there is a remote
bookmark that will be updated to point to the new head. If the
bookmark is not known remotely then push aborts, even if a -B argument
is about to push the bookmark. This change allows push to continue in
this case. This does not require a wireproto force.
2013-11-11 21:16:54 +11:00
Matthew Turk
c0982bbb31 template: modify showextras to return a hybrid
This modifies slightly the behavior introduced in fcc482469a3c to allow
showextras to return a hybrid, rather than showlist.  The example in the
template help file now executes and returns meaningful results.
2013-11-21 15:46:49 -05:00
Brodie Rao
56709077ed branches: avoid unnecessary changectx.branch() calls
This requires reading from the changelog, which can be costly over NFS.

Note that this does not totally remove reading from the changelog; we
still do that when calling changectx.closesbranch(). That call will be
removed in a later patch.

Running hg branches on the PyPy repo (with 996) over a busy NFS server,
before this change:

$ time hg --profile branches > /dev/null
   CallCount    Recursive     Total(s)    Inline(s) module:lineno(function)
        2042            0      2.2827      2.2827   <open>
        2036            0      0.9840      0.9840   <method 'close' of 'file' objects>
        2036            0      0.0464      0.0464   <method 'read' of 'file' objects>
        5233            0      0.1985      0.0453   mercurial.repoview:161(changelog)
       10462            0      0.0791      0.0314       mercurial.changelog:133(tip)
        5233            0      0.0388      0.0176       mercurial.localrepo:26(__get__)
       10462            0      0.0250      0.0126       <len>
        5233            0      0.0059      0.0039       mercurial.repoview:112(filterrevs)
       10462            0      0.0029      0.0029       <hash>
        2034            0      0.0444      0.0444   <method 'seek' of 'file' objects>
        5340            0      0.0390      0.0390   mercurial.revlog:296(rev)
        2582            0      0.0371      0.0371   <zlib.decompress>
        3155            0      0.1963      0.0366   mercurial.context:202(__init__)
        3155            0      0.1238      0.0306       mercurial.repoview:161(changelog)
        3155            0      0.0261      0.0080       mercurial.changelog:183(rev)
        9465            0      0.0061      0.0061       <isinstance>
        1096            0      0.0023      0.0023       <binascii.unhexlify>
        4251            0      0.0014      0.0014       <len>
        2059            0      3.7341      0.0332   mercurial.changelog:270(read)
        2059            0      3.6304      0.0307       mercurial.revlog:907(revision)
        2057            0      0.0262      0.0137       mercurial.changelog:28(decodeextra)
        4118            0      0.0094      0.0094       <method 'split' of 'str' objects>
        4118            0      0.0270      0.0048       mercurial.encoding:61(tolocal)
        2059            0      0.0040      0.0040       <method 'index' of 'str' objects>
       10462            0      0.0791      0.0314   mercurial.changelog:133(tip)
       10462            0      0.0289      0.0207       mercurial.changelog:190(node)
       10462            0      0.0188      0.0091       <len>
       52433        20932      0.0478      0.0310   <len>
       20932            0      0.0221      0.0168       mercurial.revlog:262(__len__)
        2059            0      3.6304      0.0307   mercurial.revlog:907(revision)

real    0m4.361s
user    0m0.986s
sys     0m0.237s

After this change:

$ time hg --profile branches > /dev/null
   CallCount    Recursive     Total(s)    Inline(s) module:lineno(function)
        1069            0      1.1098      1.1098   <open>
        1063            0      0.4865      0.4865   <method 'close' of 'file' objects>
        4122            0      0.1811      0.0404   mercurial.repoview:161(changelog)
        8240            0      0.0712      0.0272       mercurial.changelog:133(tip)
        4122            0      0.0378      0.0177       mercurial.localrepo:26(__get__)
        8240            0      0.0221      0.0115       <len>
        4122            0      0.0057      0.0033       mercurial.repoview:112(filterrevs)
        8240            0      0.0025      0.0025       <hash>
        3029            0      0.1979      0.0371   mercurial.context:202(__init__)
        3029            0      0.1278      0.0310       mercurial.repoview:161(changelog)
        3029            0      0.0230      0.0081       mercurial.changelog:183(rev)
        9087            0      0.0061      0.0061       <isinstance>
        1096            0      0.0026      0.0026       <binascii.unhexlify>
        4125            0      0.0014      0.0014       <len>
        4229            0      0.0337      0.0337   mercurial.revlog:296(rev)
        1061            0      0.0296      0.0296   <method 'seek' of 'file' objects>
        1063            0      0.0292      0.0292   <method 'read' of 'file' objects>
        8240            0      0.0712      0.0272   mercurial.changelog:133(tip)
        8240            0      0.0271      0.0196       mercurial.changelog:190(node)
        8240            0      0.0169      0.0083       <len>
       40476        16488      0.0422      0.0271   <len>
       16488            0      0.0193      0.0152       mercurial.revlog:262(__len__)
        1342            0      0.0241      0.0241   <zlib.decompress>
        9445            0      0.0336      0.0224   mercurial.changelog:190(node)
        9445            0      0.0112      0.0112       mercurial.revlog:317(node)
        1074            0      1.9102      0.0224   mercurial.changelog:270(read)
        1074            0      1.8397      0.0202       mercurial.revlog:907(revision)
        1073            0      0.0187      0.0099       mercurial.changelog:28(decodeextra)
        2148            0      0.0061      0.0061       <method 'split' of 'str' objects>
        2148            0      0.0184      0.0034       mercurial.encoding:61(tolocal)

real    0m2.402s
user    0m0.735s
sys     0m0.177s
2013-11-15 23:18:08 -05:00
Brodie Rao
b8ea796521 branchmap: add documentation on the branchcache on-disk format 2013-11-15 23:18:08 -05:00
Brodie Rao
43ab01245b revlog: allow tuning of the chunk cache size (via format.chunkcachesize)
Running perfmoonwalk on the Mercurial repo (with almost 20,000 changesets) on
Mac OS X with an SSD, before this change:

$ hg --config format.chunkcachesize=1024 perfmoonwalk
! wall 2.022021 comb 2.030000 user 1.970000 sys 0.060000 (best of 5)

(16,154 cache hits, 3,840 misses.)

$ hg --config format.chunkcachesize=4096 perfmoonwalk
! wall 1.901006 comb 1.900000 user 1.880000 sys 0.020000 (best of 6)

(19,003 hits, 991 misses.)

$ hg --config format.chunkcachesize=16384 perfmoonwalk
! wall 1.802775 comb 1.800000 user 1.800000 sys 0.000000 (best of 6)

(19,746 hits, 248 misses.)

$ hg --config format.chunkcachesize=32768 perfmoonwalk
! wall 1.818545 comb 1.810000 user 1.810000 sys 0.000000 (best of 6)

(19,870 hits, 124 misses.)

$ hg --config format.chunkcachesize=65536 perfmoonwalk
! wall 1.801350 comb 1.810000 user 1.800000 sys 0.010000 (best of 6)

(19,932 hits, 62 misses.)

$ hg --config format.chunkcachesize=131072 perfmoonwalk
! wall 1.805879 comb 1.820000 user 1.810000 sys 0.010000 (best of 6)

(19,963 hits, 31 misses.)

We may want to change the default size in the future based on testing and
user feedback.
2013-11-17 18:04:29 -05:00
Brodie Rao
976b336ba8 revlog: read/cache chunks in fixed windows of 64 KB
When reading a revlog chunk, instead of reading up to 64 KB ahead of the
request offset and caching that, this change caches a fixed window before
and after the requested data that falls on 64 KB boundaries. This increases
cache hits when reading revlogs backwards.

Running perfmoonwalk on the Mercurial repo (with almost 20,000 changesets) on
Mac OS X with an SSD, before this change:

$ hg perfmoonwalk
! wall 2.307994 comb 2.310000 user 2.120000 sys 0.190000 (best of 5)

(Each run has 10,668 cache hits and 9,304 misses.)

After this change:

$ hg perfmoonwalk
! wall 1.814117 comb 1.810000 user 1.810000 sys 0.000000 (best of 6)

(19,931 cache hits, 62 misses.)

On a busy NFS share, before this change:

$ hg perfmoonwalk
! wall 17.000034 comb 4.100000 user 3.270000 sys 0.830000 (best of 3)

After:

$ hg perfmoonwalk
! wall 1.746115 comb 1.670000 user 1.660000 sys 0.010000 (best of 5)
2013-11-17 18:04:28 -05:00
Brodie Rao
aba805d85d perf: add perfmoonwalk command to walk the changelog backwards
This lets us test the effectiveness (or ineffectiveness) of the revlog chunk
cache when walking revlogs backwards.
2013-11-17 18:04:28 -05:00
Long Vu
718cfe2dd3 largefiles: call super class method with proper kwargs to respect API
Since the localrepositoyry.push() method in mercurial/localrepo.py is defined
this way:

  def push(self, remote, force=False, revs=None, newbranch=False):

it is better for largefiles to call push() on the super class with proper
kwargs to respect the API.

This will avoid breaking other extensions overriding the push method this way:

  def push(self, remote, force=False, **kwargs):
2013-12-03 13:28:04 -05:00
FUJIWARA Katsunori
bcc53deece subrepo: check phase of state in each subrepositories before committing
Before this patch, phase of newly created commit is determined by
"phases.new-commit" configuration regardless of phase of state in each
subrepositories.

For example, this may cause the "public" revision in the parent
repository referring the "secret" one in subrepository.

This patch checks phase of state in each subrepositories before
committing in the parent, and aborts or changes phase of newly created
commit if subrepositories have more restricted phase than the parent.

This patch uses "follow" as default value of "phases.checksubrepos"
configuration, because it can keep consistency between phases of the
parent and subrepositories without breaking existing tool chains.
2013-11-13 15:55:30 +09:00
Matt Mackall
684b14efd3 merge with crew 2013-12-16 12:59:32 -06:00
Augie Fackler
d5ef0d1bf2 http: backout df58533adb15, which breaks on Python 2.4 2013-12-14 12:48:12 -05:00
Augie Fackler
e5f635905e test-module-imports: try and detect virtualenv breakage (issue4129)
virtualenvs (among other things) break the stdlib module detection in
the import checker, and I don't see a good way to work around that for
now.
2013-12-14 11:58:26 -05:00
Matt Mackall
b73357aaab merge with stable 2013-12-13 17:23:02 -06:00
Matt Mackall
03adb7cbe4 hgweb: avoid initialization race (issue3953) 2013-12-04 13:42:28 -06:00
Matt Mackall
c4f5764d33 mpatch: rewrite pointer overflow checks 2013-12-11 18:33:42 -06:00
Chris Jerdonek
ebe058e6c3 parsers: clarify documentation of test-parseindex2.py
This change updates and improves the description of test-parseindex2.py.
In particular, it removes language that can be interpreted to mean that the
test module checks only the C implementation of parsers.parse_index2().
Rather, the module checks parsers.parse_index2(), which can be either the
C or pure Python implementation, depending on which version is being used.

As of 23b69fd11636, the module also does more than just compare the return
value with the original Python implementation.
2013-12-02 07:49:49 -08:00
Matt Mackall
5c689e700e merge with stable 2013-12-01 21:24:48 -06:00
Matt Mackall
68554e4b42 tests: fix missing import in check-translations 2013-12-01 21:24:26 -06:00
Matt Mackall
e98ed07767 merge with stable 2013-12-01 20:54:02 -06:00
Matt Mackall
e539bfb887 Added signature for changeset b000784e52a9 2013-12-01 20:51:15 -06:00
Matt Mackall
68d26422e4 merge with stable 2013-12-01 20:47:09 -06:00
Matt Mackall
30d6dbb217 parsers: backout version mismatch detection from 5f712fe8433d
This introduced mandatory recompilations and breaks pure mode in tests
2013-12-01 20:46:36 -06:00
Matt Mackall
a7756031f0 tests: fix Mac doctest escape code garbage for check-translations 2013-12-01 20:39:11 -06:00
Wagner Bruna
1f2bdd921d i18n-pt_BR: synchronized with 5d367afa6755 2013-12-01 18:26:42 -02:00
Matt Mackall
4223982ebe merge with stable 2013-12-01 14:10:53 -06:00
Andrew Shadura
e4287fe436 hgk: fix tag list parser (issue4101)
As tags may have embedded spaces, and "hg tags" command doesn't escape them,
the output of the command doesn't make a well-formed list, so we can't just
iterate over it. Instead, apply a simple regexp to transform it to a list
which we actually use. Line boundary matching should be enabled.
2013-12-01 13:53:24 -06:00
Matt Mackall
c6b13a6bbd merge with i18n 2013-12-01 13:45:00 -06:00
Wagner Bruna
d61a68e7a9 i18n-pt_BR: fix wording in tag command help text 2013-11-30 21:50:40 -02:00
Chris Jerdonek
030ca96e57 parsers: fail fast if Python has wrong minor version (issue4110)
This change causes an informative ImportError to be raised when importing
the extension module parsers if the minor version of the currently-running
Python interpreter doesn't match that of the Python that was used when
compiling the extension module.  Here is an example of what the new error
looks like:

  Traceback (most recent call last):
    File "test.py", line 1, in <module>
      import mercurial.parsers
  ImportError: Python minor version mismatch: The Mercurial extension
  modules were compiled with Python 2.7.6, but Mercurial is currently using
  Python with sys.hexversion=33883888: Python 2.5.6
  (r256:88840, Nov 18 2012, 05:37:10)
  [GCC 4.2.1 Compatible Apple Clang 4.1 ((tags/Apple/clang-421.11.66))]
   at: /opt/local/Library/Frameworks/Python.framework/Versions/2.5/Resources/
    Python.app/Contents/MacOS/Python

The reason for raising an error in this scenario is that Python's C API
is known not to be compatible from minor version to minor version, even
if sys.api_version is the same.  See for example this Python bug report
about incompatibilities between 2.5 and 2.6+:

  http://bugs.python.org/issue8118

These incompatibilities can cause Mercurial to break in mysterious,
unforeseen ways.  For example, when Mercurial compiled with Python 2.7 was
run with 2.5, the following crash occurred when running "hg status":

  http://bz.selenic.com/show_bug.cgi?id=4110

After this crash was fixed, running with Python 2.5 no longer crashes, but
the following puzzling behavior still occurs:

    $ hg status
      ...
      File ".../mercurial/changelog.py", line 123, in __init__
        revlog.revlog.__init__(self, opener, "00changelog.i")
      File ".../mercurial/revlog.py", line 251, in __init__
        d = self._io.parseindex(i, self._inline)
      File ".../mercurial/revlog.py", line 158, in parseindex
        index, cache = parsers.parse_index2(data, inline)
    TypeError: data is not a string

which can be reproduced more simply with:

    import mercurial.parsers as parsers
    parsers.parse_index2("", True)

Both the crash and the TypeError occurred because the Python C API's
PyString_Check returns the wrong value when the C header files from
Python 2.7 are run with Python 2.5.  This is an example of an
incompatibility of the sort mentioned in the Python bug report above.

Failing fast with an informative error message will result in a better
user experience in cases like the above.  The information in the ImportError
will also simplify troubleshooting for those on Mercurial mailing lists,
the bug tracker, etc.

This patch only adds the version check to parsers.c, which is sufficient
to affect command-line commands like "hg status" and "hg summary".
An idea for a future improvement is to move the version-checking C code
to a more central location, and have it run when importing all
Mercurial extension modules and not just parsers.c.
2013-11-29 12:36:28 -08:00
FUJIWARA Katsunori
4f41aff6b6 i18n-ja: synchronized with 5cdd099776c7 2013-11-28 20:10:47 +09:00
Augie Fackler
e35b88d480 test-import-git.t: work around check-code hating on ^ and $( in tests 2013-11-27 16:43:02 -05:00
Nicolas Vigier
a9bf6787d2 patch: add support for git delta hunks
When creating patches modifying binary files using "git format-patch",
git creates 'literal' and 'delta' hunks. Mercurial currently supports
'literal' hunks only, which makes it impossible to import patches with
'delta' hunks.

This changeset adds support for 'delta' hunks. It is a reimplementation
of patch-delta.c from git :
http://git.kernel.org/cgit/git/git.git/tree/patch-delta.c
2013-11-27 18:39:00 +01:00
FUJIWARA Katsunori
3535aee6e1 i18n: add the tool to check Mercurial specific translation problems in *.po
Existing tool like "msgfmt --check" can check typical translation
problems (missing "%s" in msgstr, for example), but can't check
Mercurial specific ones.

For example, "msgfmt --check" can't check whether the translated
string given to "ui.promptchoice()" is correct or not, even though
problems like below cause run-time error or unexpected behavior:

  - less or more choices than msgid,
  - choices without '&', or
  - choices with '&' followed by none

This patch adds the tool to check Mercurial specific translation
problems in *.po files.
2013-11-27 22:47:32 +09:00
Santiago Pay=C3=A0 i Miralta
42d271f1db help: fix backwards bisect help example 2013-11-27 22:32:01 +01:00
Durham Goode
3357a8eb2b unshelve: add tests for unknown files
Adds a basic test for shelving/unshelving with an unknown file present.

Adds a test for unshelving on top of an existing unknown file.
2013-11-26 16:30:52 -08:00
Durham Goode
0b43211792 unshelve: don't commit unknown files during unshelve (issue4113)
Previously, unshelve would temporarily commit unknown files (via addremove) in
an attempt to allow unshelving into unknown files.  This produced unexpected
results, like the file time stamp changing and a .i file being created.

This change makes it no longer use addremove.  It ignores unknown files
completely.  If an unshelve would overwrite an unknown file, the unknown file is
moved to *.orig

The shelve continue/abort format is changed, but it just removes stuff from the
end of the file, so it can still read the old format.
2013-11-26 16:23:05 -08:00
Mads Kiilerich
f2255e8146 largefiles: don't crash on 'local renamed directory' actions
a8386b4c47b1 introduced splitstandin on all action filenames. It would however
crash on 'd' actions where the filename is None.

Fix that and add test coverage for that case.
2013-11-26 15:38:33 +01:00
Wagner Bruna
22b11e7b78 i18n-pt_BR: synchronized with 5131f2755f60 2013-11-26 11:00:49 -02:00
Sean Farley
5f6b3d5623 pathcomplete: remove ambiguous entries for sole completion on a directory
Previously, directories were added with the trailing slash and, if there was
only one completion, then another ambiguous entry was created using '.', as
follows:

$ hg rm mer<TAB>
mercurial/./  mercurial//

This was added in bc559aff745c (though, some logic existed before that) to work
around bash completion adding a space after the sole entry because we treated
directories and files the same. We no longer do that now so we remove this
unneeded code.

Tests have been updated to match this new behavior.
2013-11-25 12:12:42 -05:00
Sean Farley
337aa76166 bash_completion: add global support for -b|--branch
Previously, only -r|--rev was parsed globally which meant 'hg push -b <tab>'
would try to complete a path instead of a branch.
2013-11-26 14:33:18 -06:00
Sean Farley
fa42f28d41 bash_completion: add global support for -B|--bookmark
Previously, only -r|--rev was parsed globally which meant 'hg push -B <tab>'
would try to complete a path instead of a bookmark.
2013-11-26 14:31:40 -06:00
Sean Farley
2c4a9fc383 bash_completion: change --rev if-else block into a case
Again, this doesn't change behavior but does make it easy to add cases in the
next patch.
2013-11-26 14:04:12 -06:00
Sean Farley
fdb3859999 bash_completion: simplify if-else logic
There is no change in functionality here but this makes refactoring this later
easier.
2013-11-26 13:55:33 -06:00
Sean Farley
dd1a68daaa bash_completion: add _hg_branches for list of branches 2013-11-25 11:38:14 -05:00
Sean Farley
894084345f bash_completion: add -B|--bookmark support for strip 2013-11-26 14:38:14 -06:00
Stéphane Klein
f4f9ffdc0e http: reuse authentication info after the first failed request (issue3567)
Context: mercurial access to repository server with http access, and this
server is protected by basic auth.

Before patch:

* mercurial try an anonymous access to server, server return 401 response and
  mercurial resend request with login / password information

After patch:

* mercurial try an anonymous access to server, server return 401
  response. For all subsequent requests, mercurial keep in memory this
  information (this server need basic auth information).

This patch reduce the number of http access against mercurial server.

Example, before patch :

10.10.168.170 - - [25/Oct/2013:15:44:51 +0200] "GET /hg/testagt?cmd=capabilities
HTTP/1.1" 401 260 "-" "mercurial/proto-1.0"
10.10.168.170 - - [25/Oct/2013:15:44:52 +0200] "GET /hg/testagt?cmd=capabilities
HTTP/1.1" 200 147 "-" "mercurial/proto-1.0"
10.10.168.170 - - [25/Oct/2013:15:45:00 +0200] "GET /hg/testagt?cmd=capabilities
HTTP/1.1" 401 260 "-" "mercurial/proto-1.0"
10.10.168.170 - - [25/Oct/2013:15:45:01 +0200] "GET /hg/testagt?cmd=capabilities
HTTP/1.1" 200 147 "-" "mercurial/proto-1.0"
10.10.168.170 - - [25/Oct/2013:15:45:03 +0200] "GET /hg/testagt?cmd=batch
HTTP/1.1" 401 260 "-" "mercurial/proto-1.0"
10.10.168.170 - - [25/Oct/2013:15:45:04 +0200] "GET /hg/testagt?cmd=batch
HTTP/1.1" 200 42 "-" "mercurial/proto-1.0"
10.10.168.170 - - [25/Oct/2013:15:45:06 +0200] "GET /hg/testagt?cmd=getbundle
HTTP/1.1" 401 260 "-" "mercurial/proto-1.0"
10.10.168.170 - - [25/Oct/2013:15:45:07 +0200] "GET /hg/testagt?cmd=getbundle
HTTP/1.1" 200 61184 "-" "mercurial/proto-1.0"
10.10.168.170 - - [25/Oct/2013:15:45:09 +0200] "GET /hg/testagt?cmd=listkeys
HTTP/1.1" 401 260 "-" "mercurial/proto-1.0"
10.10.168.170 - - [25/Oct/2013:15:45:10 +0200] "GET /hg/testagt?cmd=listkeys
HTTP/1.1" 200 15 "-" "mercurial/proto-1.0"
10.10.168.170 - - [25/Oct/2013:15:45:12 +0200] "GET /hg/testagt?cmd=listkeys
HTTP/1.1" 401 260 "-" "mercurial/proto-1.0"
10.10.168.170 - - [25/Oct/2013:15:45:12 +0200] "GET /hg/testagt?cmd=listkeys
HTTP/1.1" 200 - "-" "mercurial/proto-1.0"

Example after patch :

10.10.168.170 - - [28/Oct/2013:11:49:14 +0100] "GET /hg/testagt?cmd=capabilities
HTTP/1.1" 401 260 "-" "mercurial/proto-1.0"
10.10.168.170 - - [28/Oct/2013:11:49:15 +0100] "GET /hg/testagt?cmd=capabilities
HTTP/1.1" 200 147 "-" "mercurial/proto-1.0"
10.10.168.170 - - [28/Oct/2013:11:49:17 +0100] "GET /hg/testagt?cmd=batch
HTTP/1.1" 200 42 "-" "mercurial/proto-1.0"
10.10.168.170 - - [28/Oct/2013:11:49:19 +0100] "GET /hg/testagt?cmd=getbundle
HTTP/1.1" 200 61184 "-" "mercurial/proto-1.0"
10.10.168.170 - - [28/Oct/2013:11:49:22 +0100] "GET /hg/testagt?cmd=listkeys
HTTP/1.1" 200 15 "-" "mercurial/proto-1.0"
10.10.168.170 - - [28/Oct/2013:11:49:24 +0100] "GET /hg/testagt?cmd=listkeys
HTTP/1.1" 200 - "-" "mercurial/proto-1.0"

In this last example, you can see only one 401 response.
2013-11-25 17:18:12 +01:00
Prasoon Shukla
7c782e5502 record: --user/-u now works with record when ui.username not set (issue3857)
The -u flag didn't work when ui.username was not set and resulted in an
abort message. This was fixed by checking for the 'user' key in the opts
dictionary. If the key is present, the step causing the exception is not
executed.
2013-12-12 12:25:56 +05:30
Steve Hoelzer
3de6d4f403 help: fix formatting of template example 2013-12-11 11:33:58 -06:00