Commit Graph

10704 Commits

Author SHA1 Message Date
Siddharth Agarwal
ee30e748c9 commands.bookmarks: hold wlock for write operations
Any invocations of bookmarks other than a plain 'hg bookmarks' will likely
cause a write to the bookmark store. These should be guarded by the wlock.

The repo._bookmarks read should be similarly guarded by the wlock if we're
going to be subsequently writing to it.
2013-11-19 12:33:14 -08:00
Siddharth Agarwal
e1850e1d79 commands.bookmarks: separate out 'no bookmarks set' status messages
Upcoming patches will acquire the wlock for write operations, such as make
inactive, but not read-only ones, such as list bookmarks. Separate out the
status messages so that the code paths can be separated.
2013-11-19 11:47:30 -08:00
Kevin Bullock
6a83843bd3 doc: bump copyright year 2014-01-10 16:26:11 -06:00
Matt Mackall
dd9ef40be6 localrepo: drop unused variable 2014-01-10 17:29:16 -06:00
Pierre-Yves David
df72d3d98f discovery: stop using nodemap for membership testing
Nodemap is not aware of filtering so we need to ask the changelog itself if a
node is known. This is probably a bit slower but such check does not dominated
discovery time. This is necessary if we want to run discovery on filtered repo.
2013-11-15 23:28:43 -05:00
Pierre-Yves David
5cf610755f discovery: enforce filtering into revlogbaseddag._internalizeall
One more step toward discovery running on filtered repo.
2013-11-15 23:27:39 -05:00
Pierre-Yves David
6ebc9feba5 discovery: make revlogdag work on filtered repo
The revlogdag class is a core part of discovery. We need its initialisation to
exclude revision filtered out.
2013-11-15 23:27:15 -05:00
Pierre-Yves David
a296fcdefb pull: run findcommon incoming on unfiltered repo
The discovery is not yet ready for filtered repo. Pull was using filtered for
its discovery which is wrong. It worked by dumb luck because discovery mainly
use funtion that does not respect the filtering.

Trying to makes discovery work on filtered repo revealed this bug.
2013-11-16 11:53:44 -05:00
Pierre-Yves David
a9f4140d91 push: more robust check for bundle fast path
When all changesets in the local repo are either being pushed or remotly known,
we can take a fast path when bundling changeset because we are certain all local
deltas are computed againts base known remotely.

So we have a check to detect this situation, when we did a bare push and nothing
was excluded.

In a coming refactoring, the discovery will run on filtered view and the content
of `outgoing.excluded` will just include unserved (secret) changeset not filtered by the
repoview used to call push (usually "visible"). So we need to check if there is
both no excluded changeset and nothing filtered by the current repoview.
2013-11-05 18:37:44 +01:00
Pierre-Yves David
5567affae0 pull: fix post-pull common computation
Before that changes, pulled revision that happend to be already known locally
(so, not actually added) was not taken into account when computing the new
common set between local and remote.

It appears that we already know the heads of the pulled set. It is in the
`rheads` variable, so we are just using it and everything is works fine.

We are dropping the, now useless, computation of `added` set in the process.
2013-11-16 15:36:50 -05:00
Andrew Shadura
88eaae271b templatekw: allow tagtypes other than global in getlatesttags
hg-git uses tagtype 'git', for example, so it's better
to check for tagtype != 'local', not strictly for 'global'
2013-12-23 14:14:31 +01:00
Durham Goode
b147e53e3f revlog: move file writing to a separate function
Moves the code that actually writes to a file to a separate function in
revlog.py. This allows extensions to intercept and use the data being written to
disk. For example, an extension might want to replicate these writes elsewhere.

When cloning the Mercurial repo on /dev/shm with --pull, I see about a 0.3% perf change.
It goes from 28.2 to 28.3 seconds.
2013-11-26 12:58:27 -08:00
Kevin Bullock
23ff9c2ce1 discovery: prefer loop to double-for list comprehension in changegroupsubset
The double-for form of list comprehensions gets particularly unreadable
when you throw in an 'if' condition. This expands the only remaining
instance of the double-for syntax in our codebase into a loop.
2013-11-24 17:33:39 -06:00
Augie Fackler
acff2f02d0 merge with stable 2014-01-01 18:28:40 -05:00
Pierre-Yves David
bab0fe5a64 obsolete: order of magnitude speedup in _computebumpedset
Reminder: a changeset is said "bumped" if it tries to obsolete a immutable
          changeset.


The previous algorithm for computing bumped changeset was:

    1) Get all public changesets
    2) Find all they successors
    3) Search for stuff that are eligible for being "bumped"
       (mutable and non obsolete)

The entry size of this algorithm is `O(len(public))` which is mostly the same as
`O(len(repo))`. Even this this approach mean fewer obsolescence marker are
traveled, this is not very scalable.

The new algorithm is:

    1) For each potential bumped changesets (non obsolete mutable)
    2) iterate over precursors
    3) if a precursors is public. changeset is bumped

We travel more obsolescence marker, but the entry size is much smaller since
the amount of potential bumped should remains mostly stable with time `O(1)`.

On some confidential gigantic repo this move bumped computation from 15.19s to
0.46s (×33 speedup…). On "smaller" repo (mercurial, cubicweb's review) no
significant gain were seen. The additional traversal of obsolescence marker is
probably probably counter balance the advantage of it.

Other optimisation could be done in the future (eg: sharing precursors cache
for divergence detection)
2013-12-23 15:29:51 -08:00
Pierre-Yves David
777603b25a obsolete: add an allprecursors method mirroring allsuccessors one.
Detection of bumped changeset should use `allprecursors(<mutable>)` instead or
`allsuccessors(<immutable>)` so we need the all precursors function to exists.
2013-12-23 13:36:13 -08:00
Pierre-Yves David
04de18abd8 obsolete: improve allsuccessors doc string
The fact original nodes are also yield is not obvious. We update the docstring
to highlight it.
2013-12-23 13:33:21 -08:00
Pierre-Yves David
9cb9a199aa obsolete: fix bad comment
We cannot afford such extra "with" they are far too pricy.
2013-12-23 13:32:03 -08:00
Christian Ebert
a9aa17b61c util: remove unused realpath (issue4063)
util.realpath was in use for only 5 days from 17bc9a6bb165
until it was backed out in e60acde24a62 because it caused
issue3077 and issue3071.
2013-12-29 13:54:04 +00:00
Pierre-Yves David
de4bc2f6f8 filter: add a comment so that people do not forget to update subsettable
Changeset aad678a92970 moved `subsettable` from `mercurial/repoview.py` to
`mercurial/branchmap.py`. This mean that `filtertable` and `subsettable` are no
longer next to each other. So we add a comment to remind people to update both.
2013-12-24 17:44:23 -05:00
Yuya Nishihara
cb7a1dd14c fileset, revset: do not use global parser object for thread safety
parse() cannot be called at the same time because a parser object keeps its
states.  This is no problem for command-line hg client, but it would cause
strange errors in multi-threaded hgweb.

Creating parser object is not too expensive.

original:
% python -m timeit -s 'from mercurial import revset' 'revset.parse("0::tip")'
100000 loops, best of 3: 11.3 usec per loop

thread-safe:
% python -m timeit -s 'from mercurial import revset' 'revset.parse("0::tip")'
100000 loops, best of 3: 13.1 usec per loop
2013-12-21 12:44:19 +09: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
Santiago Pay=C3=A0 i Miralta
42d271f1db help: fix backwards bisect help example 2013-11-27 22:32:01 +01:00
Martin Geisler
6907950b0d glossary: don't mention obsolete graphlog extension 2013-11-22 19:13:07 +01:00
Martin Geisler
8b1b36c645 bisect: don't mention obsolete graphlog extension in help 2013-11-22 19:12:44 +01:00
Matt Mackall
ed6ec26983 help: use progress instead of mq as in 'hg help config' example 2013-11-22 17:12:43 +01:00
Chris Jerdonek
e02a62783a parse_index2: fix crash on bad argument type (issue4110)
Passing a non-string to parsers.parse_index2() causes Mercurial to crash
instead of raising a TypeError (found on Mac OS X 10.8.5, Python 2.7.6):

    import mercurial.parsers as parsers
    parsers.parse_index2(0, 0)

    Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
    0 parsers.so  0x000000010e071c59 _index_clearcaches + 73 (parsers.c:644)
    1 parsers.so  0x000000010e06f2d5 index_dealloc + 21 (parsers.c:1767)
    2 parsers.so  0x000000010e074e3b parse_index2 + 347 (parsers.c:1891)
    3 org.python.python 0x000000010dda8b17 PyEval_EvalFrameEx + 9911

This happens because when arguments of the wrong type are passed to
parsers.parse_index2(), indexType's initialization function index_init() in
parsers.c leaves the indexObject instance in a state that indexType's
destructor function index_dealloc() cannot handle.

This patch moves enough of the indexObject initialization code inside
index_init() from after the argument validation code to before it.
This way, when bad arguments are passed to index_init(), the destructor
doesn't crash and the existing code to raise a TypeError works.  This
patch also adds a test to check that a TypeError is raised.
2013-11-26 16:14:22 -08:00
Sean Farley
a66d57e510 bookmarks: consider successor changesets when moving bookmark (issue4015)
Previously, this required -f because we didn't consider obsolete changesets
(and their children ... or successors of those children, etc.). We now use
obsolete.foreground to calculate acceptable changesets when advancing the
bookmark.

Test coverage has been added.
2013-11-06 19:01:14 -06:00
Simon Heimberg
2143905ef7 util: url keeps backslash in paths
Backslashes (\) in paths were encoded to %C5 when converting from url to
string. This does not look nice for windows paths. And it introduces many
problems when running tests on windows.
2013-11-20 22:03:15 +01:00
Matt Mackall
82c7f5838c subrepo: sanitize non-hg subrepos 2013-11-25 13:50:36 -06:00
Mads Kiilerich
7014dca534 bisect: report "both good and bad" as such, not as "not directly related" 2013-11-10 18:51:21 +01:00
Martin Geisler
934da465b0 phase: better error message when --force is needed
When trying to turn a draft changeset into a secret changeset, I was
told:

  % hg phase -s .
  cannot move 1 changesets to a more permissive phase, use --force
  no phases changed

That message struck me as being backwards -- the secret phase feels
less permissive to me since it restricts the changesets from being
pushed.

We don't use the word "permissive" elsewhere, 'hg help phase' talks
about "lower phases" and "higher phases". I therefore reformulated the
error message to be

  cannot move 1 changesets to a higher phase, use --force

That is not perfect either, but more in line with the help text. An
alternative could be

  cannot move phase backwards for 1 changesets, use --force

which fits better with the help text for --force.
2013-11-08 11:49:13 +01:00
Isaac Jurado
b5e7be1139 hgweb: ignore non numeric "revcount" parameter values (issue4091) 2013-11-08 09:48:01 +01:00
Matt Mackall
fb22d26dbd templater: makes branches work correctly with stringify (issue4108) 2013-11-21 11:30:52 -06:00
Matt Mackall
52dafe7a2a templater: only recursively evaluate string literals as templates (issue4103) 2013-11-18 15:37:09 -05:00
Matt Mackall
c9a233d77e templater: fix escaping in nested string literals (issue4102)
Before the templater got extended for nested expressions, it made
sense to decode string escapes across the whole string. Now we do it
on a piece by piece basis.
2013-11-18 14:02:26 -05:00
Pierre-Yves David
f1f6dad830 obsolete: stop doing membership test on list
According to the Surgeon General, computer should not use list for membership
testing because of the risk of being slow.
2013-11-16 20:34:58 -05:00
Wagner Bruna
b966a63297 hgweb, i18n: do not translate search mode description
The search mode description can't be translated by itself, since
it's displayed as part of a template phrase (the "Assuming ..."
/ "Use ... instead" bits). Just drop the translation markers for
now, since the templates themselves currently do not support
translations.
2013-11-13 16:46:46 -02:00
Mads Kiilerich
32fefa2839 util: warn when adding paths ending with \
Paths ending with \ will fail the verification introduced in 0bc0c17d663e when
checking out on Windows ... and if it didn't fail it would probably not do what
the user expected.
2013-11-08 12:35:50 +01:00
Simon Heimberg
25ae76fc48 documentation: add an extra newline after note directive
Like this no docutils version interprets any line in the following text as
argument of note.
2013-11-05 08:59:55 +01:00
Simon Heimberg
386dcc916f minirst: do not add a 2nd empty paragraph
This does not add a separating block after a separated note directive.

.. note::

    text

is formatted to

Note:
    text
2013-11-04 10:23:06 +01:00
Simon Heimberg
664e8c41fe minirst: find admonitions before pruning comments and adding margins
Lines with only a directive are not deleted anymore because they are detected
before comments are deleted by prunecomments().
addmargins() will be adapted later.
2013-11-04 10:23:06 +01:00
Simon Heimberg
c5557c2259 minirst: do not fail on an empty admonition block 2013-11-04 10:23:06 +01:00
Simon Heimberg
0e05d277a4 minirst: do not interpret a directive as a literal block
When a directive was on its own line, it was interpreted as a literal block.

Example of problematic input:

.. note::

    a note text
2013-11-04 10:23:06 +01:00
Siddharth Agarwal
5fa78a0d83 merge: move forgets to the beginning of the action list
Forgets need to be in the beginning of the action list, same as removes. This
lets us avoid clashes in the dirstate where a directory is forgotten and a
file with the same name is added, or vice versa.
2013-11-06 10:20:18 -08:00
Durham Goode
64d690fd9a rebase: fix rebase aborts when 'tip-1' is public (issue4082)
When aborting a rebase where tip-1 is public, rebase would fail to undo the merge
state. This caused unexpected dirstate parents and also caused unshelve to
become unabortable (since it uses rebase under the hood).

The problem was that rebase uses -2 as a marker rev, and when it checked for
immutableness during the abort, -2 got resolved to the second to last entry in
the phase cache.

Adds a test for the fix. Add exception to phase code to prevent this in the
future.
2013-11-04 19:59:00 -08:00
Johan Bjork
6055bcdec2 patch: ensure valid git diffs if source/destination file is missing (issue4046)
This is arguably a workaround, a better fix may be in the repo to
ensure that it won't list a file 'modified' unless there is a file
context for the previous version.
2013-10-13 08:38:30 -04:00
Pavlos Touboulidis
7e1d441f10 doc: fix internal date sample (issue4072) 2013-10-29 21:54:49 +02:00
Matt Mackall
a40dbdbbc6 bdiff: avoid a memory error on malloc failure 2013-10-30 16:03:42 -05:00
FUJIWARA Katsunori
2151b431ba doc: put text into header of 1st column in table to generate page correctly
>From the table without header text of 1st column, docutils generates
the table with fully empty header row.
2013-10-25 01:14:18 +09:00
FUJIWARA Katsunori
23f95aaedb doc: use double quotation mark to quote arguments in examples for Windows users
On Windows, only double quotation mark can quote command line
arguments.

So, this patch uses double quotation mark to quote command line
arguments in all examples of online help document.
2013-10-25 01:14:18 +09:00
FUJIWARA Katsunori
19e586921c doc: end line preceding command line example with double colon 2013-10-25 01:14:18 +09:00
Takumi IINO
56ac953b3c hgweb: add missing semicolon 2013-10-24 21:37:13 +09:00
Mads Kiilerich
eabc047878 spelling: random spell checker fixes 2013-10-24 01:49:56 +08:00
Yuya Nishihara
4a2a9b7d3a cmdutil: fix makefileobj not to clobber default modemap dict
Problem occurs if "hg cat -o" is invoked more than once in the same process.
The output of "hg cat" will be appended because of modemap[fn] = 'ab'.
2013-10-22 23:38:58 +09:00
Matt Mackall
6ddd78602b help: minor tweak to push help 2013-10-21 10:26:38 -07:00
FUJIWARA Katsunori
9246c0599a discovery: revise hint message introduced by changeset 49ed20ea8da0
This patch revises hint message from "for detail about" introduced by
changeset 49ed20ea8da0 to "for details about", to unify it with the
hint message introduced by proceeding patch.
2013-10-03 23:16:07 +09:00
FUJIWARA Katsunori
ad1b5de6ff push: add more detailed explanation about "--force" to online help document
This patch adds more detailed explanation about "--force" to online
help document of "hg push" to prevent novice users to execute "push
--force" easily without understanding about problems of multiple
branch heads in the repository.
2013-10-03 23:16:06 +09:00
FUJIWARA Katsunori
3198fa3830 push: hide description about "-f" in the hint to prevent from using it easily
"use push -f to force" in the hint at abortion of "hg push" may cause
novice users to execute "push -f" easily without understanding about
problems of multiple branch heads in the repository.

This patch hides description about "-f" in the hint, and leads into
seeing "hg help push" for details about pushing new heads.
2013-10-03 23:16:06 +09:00
FUJIWARA Katsunori
d01f604fec demandimport: allow extensions to import own modules by absolute name
Before this patch, python modules of each extensions can't import
another one in own extension by absolute name, because root modules of
each extensions are loaded with "hgext_" prefix.

For example, "import extroot.bar" in "extroot/foo.py" of "extroot"
extension fails, even though "import bar" in it succeeds.

Installing extensions into site-packages of python library path can
avoid this problem, but this solution is not reasonable in some cases:
using binary package of Mercurial on Windows, for example.

This patch retries to import with "hgext_" prefix after ImportError,
if the module in the extension may try to import another one in own
extension.

This patch doesn't change some "_import()"/"_origimport()" invocations
below, because ordinary extensions shouldn't cause such invocations.

    - invocation of "_import()" when root module imports sub-module by
      absolute path without "fromlist"

      for example, "import a.b" in "a.__init__.py".

      extensions are loaded with "hgext_" prefix, and this causes
      execution of another (= fixed by this patch) code path.

    - invocation of "_origimport()" when "level != -1" with "fromlist"

      for example, importing after "from __future__ import
      absolute_import" (level == 0), or "from . import b" or "from .a
      import b" (0 < level),

      for portability between python versions and environments,
      extensions shouldn't cause "level != -1".
2013-10-05 01:02:22 +09:00
FUJIWARA Katsunori
24ac3edef8 demandimport: support "absolute_import" for external libraries (issue4029)
Before this patch, demandimport of Mercurial may fail to load external
libraries using "from __future__ import absolute_import": for example,
importing "foo" in "bar.baz" module will load "bar.foo" if it exists,
even though "absolute_import" is enabled in "bar.baz" module.

So, extensions for Mercurial can't use such external libraries.

This patch saves "level" of import request for on-demand module
loading in the future: default value of level is -1, and level is 0
when "absolute_import" is enabled.

"level" value is passed to built-in import function in
"_demandmod._load()" and it should load target module correctly.

This patch changes only one "_demandmod" construction case other than
cases below:

    - construction in "_demandmod._load()"

      this code path should be used only in relative sub-module
      loading case

    - constructions other than patched one in"_demandimport()"

      these code paths shouldn't be used in "level != -1" case
2013-10-05 01:02:22 +09:00
Siddharth Agarwal
69eb5c00b0 merge: exit early during a no-op update (BC)
hg update . (or equivalents) are effectively no-ops in just about all
circumstances.  These sorts of updates can be especially common in a
bookmark-oriented workflow. This saves us a status check and a manifest
decompression, which means that on a repo with over 210,000 files, this brings
hg update . down from 2.5 seconds to 0.15.

There is one change in behavior: a file that was added, not committed, and then
deleted but not removed used to be removed from the dirstate. With this patch
it isn't. This is what causes the change in test-mq-qpush-exact.t. This seems
like it's enough of an edge case to not be worth handling.

The output of test-empty.t changes because those files are not yet created.
2013-10-01 17:43:54 -07:00
FUJIWARA Katsunori
fb1d8fd59b localrepo: invoke only feature setup functions for enabled extensions
Before this patch, each feature setup functions for localrepository
class should examine whether corresponding extension is enabled or not
by themselves.

This patch invokes only feature setup functions defined in module of
enabled extensions, and it makes implementation of feature setup
functions easier and simpler.
2013-10-17 21:45:17 +09:00
Yuya Nishihara
a87a5e29b1 lock: handle race in trylock/testlock on Windows
readlock may raise IOError if the system does not support symlink.
2013-10-02 21:16:40 +09:00
Mads Kiilerich
a971393dbd commands: refactor 'serve', extract the http service class 2013-10-10 04:32:36 +02:00
Brodie Rao
c42d4c5508 localrepo: remove unused repo.branchtags()/_branchtip() methods 2013-09-16 01:08:29 -07:00
Brodie Rao
7dec608ff1 hgweb: simplify branches with repo.branchmap().iterbranches() 2013-09-16 01:08:29 -07:00
Brodie Rao
adc7ea02cb hgweb: simplify summary with repo.branchmap().iterbranches() 2013-09-16 01:08:29 -07:00
Brodie Rao
899e66fafb branches: simplify with repo.branchmap().iterbranches()
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)
        1069            0      1.2955      1.2955   <open>
        1063            0      0.5576      0.5576   <method 'close' of 'file' objects>
        4122            0      0.1993      0.0449   mercurial.repoview:161(changelog)
        8240            0      0.0771      0.0299       mercurial.changelog:133(tip)
        4122            0      0.0422      0.0204       mercurial.localrepo:26(__get__)
        8240            0      0.0252      0.0131       <len>
        4122            0      0.0060      0.0037       mercurial.repoview:112(filterrevs)
        8240            0      0.0028      0.0028       <hash>
        3029            0      0.2139      0.0390   mercurial.context:202(__init__)
        3029            0      0.1402      0.0339       mercurial.repoview:161(changelog)
        3029            0      0.0240      0.0087       mercurial.changelog:183(rev)
        9087            0      0.0067      0.0067       <isinstance>
        1096            0      0.0025      0.0025       <binascii.unhexlify>
        4125            0      0.0015      0.0015       <len>
        4229            0      0.0344      0.0344   mercurial.revlog:296(rev)
        1061            0      0.0343      0.0343   <method 'seek' of 'file' objects>
        1063            0      0.0339      0.0339   <method 'read' of 'file' objects>
       40476        16488      0.0479      0.0311   <len>
       16488            0      0.0216      0.0168       mercurial.revlog:262(__len__)
        8240            0      0.0771      0.0299   mercurial.changelog:133(tip)
        8240            0      0.0281      0.0203       mercurial.changelog:190(node)
        8240            0      0.0191      0.0095       <len>
        1342            0      0.0278      0.0278   <zlib.decompress>
        1074            0      2.2143      0.0266   mercurial.changelog:270(read)
        1074            0      2.1328      0.0230       mercurial.revlog:907(revision)
        1073            0      0.0208      0.0108       mercurial.changelog:28(decodeextra)
        2148            0      0.0072      0.0072       <method 'split' of 'str' objects>
        2148            0      0.0211      0.0038       mercurial.encoding:61(tolocal)
        1074            0      0.0028      0.0028       <method 'index' of 'str' objects>
        1061            0      1.9811      0.0237   mercurial.revlog:817(_loadchunk)

real    0m2.742s
user    0m0.811s
sys     0m0.188s

After this change:

$ time hg --profile branches > /dev/null
   CallCount    Recursive     Total(s)    Inline(s) module:lineno(function)
        2092            0      0.1444      0.0292   mercurial.context:202(__init__)
        2092            0      0.0908      0.0216       mercurial.repoview:161(changelog)
        2092            0      0.0164      0.0057       mercurial.changelog:183(rev)
        6276            0      0.0045      0.0045       <isinstance>
        1096            0      0.0024      0.0024       <binascii.unhexlify>
        3188            0      0.0013      0.0013       <len>
        2218            0      0.0230      0.0230   mercurial.revlog:296(rev)
        2111            0      0.1028      0.0218   mercurial.repoview:161(changelog)
        4218            0      0.0387      0.0146       mercurial.changelog:133(tip)
        2111            0      0.0238      0.0104       mercurial.localrepo:26(__get__)
        4218            0      0.0122      0.0062       <len>
        2111            0      0.0038      0.0021       mercurial.repoview:112(filterrevs)
        4218            0      0.0014      0.0014       <hash>
       20240         8444      0.0233      0.0149   <len>
        8444            0      0.0110      0.0084       mercurial.revlog:262(__len__)
        4218            0      0.0387      0.0146   mercurial.changelog:133(tip)
        4218            0      0.0144      0.0103       mercurial.changelog:190(node)
        4218            0      0.0097      0.0048       <len>
        2398            1      0.0271      0.0115   mercurial.localrepo:26(__get__)
        2398            1      0.0146      0.0046       mercurial.scmutil:939(__get__)
        2124            0      0.0009      0.0009       mercurial.localrepo:330(unfiltered)
         274            0      0.0002      0.0002       mercurial.repoview:192(unfiltered)
           4            0      0.1409      0.0112   mercurial.branchmap:19(read)
        1096            0      0.1113      0.0028       mercurial.localrepo:407(__contains__)
        1098            0      0.0020      0.0020       <method 'split' of 'str' objects>
        1097            0      0.0019      0.0019       <binascii.unhexlify>
        1096            0      0.0093      0.0018       mercurial.encoding:61(tolocal)
        1096            0      0.0010      0.0010       <method 'append' of 'list' objects>
        4349            0      0.0150      0.0105   mercurial.changelog:190(node)
        4349            0      0.0045      0.0045       mercurial.revlog:317(node)

real    0m0.362s
user    0m0.329s
sys     0m0.024s
2013-09-16 01:08:29 -07:00
Brodie Rao
38cd6d3329 debuglabelcomplete: simplify with repo.branchmap().iterbranches() 2013-09-16 01:08:29 -07:00
Brodie Rao
34af0d72ea branchmap: introduce iterbranches() method 2013-09-16 01:08:29 -07:00
Brodie Rao
af45025c76 localrepo: refactor repo.branchheads() to use repo.branchmap().branchheads() 2013-09-16 01:08:29 -07:00
Brodie Rao
f0a5d60210 branchmap: introduce branchheads() method 2013-09-16 01:08:29 -07:00
Brodie Rao
b351ef136e localrepo: refactor repo.branchtip() to use repo.branchmap().branchtip() 2013-09-16 01:08:29 -07:00
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
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
Matt Mackall
b73357aaab merge with stable 2013-12-13 17:23:02 -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
4223982ebe merge with stable 2013-12-01 14:10:53 -06: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
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
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
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
Steve Hoelzer
3de6d4f403 help: fix formatting of template example 2013-12-11 11:33:58 -06:00
Sean Farley
96ae01bd26 dispatch: turn off custom debugger for HGPLAIN mode
Some debuggers, such as ipdb, load escape codes and color codes even when later
turned off. This will affect scripts that do simple parsing and can't handle
escape codes. Therefore, we only load a custom debugger if ui.plain() is false.
2013-11-25 12:20:39 -05:00
Martin Geisler
865c68aba2 hg: remove outdated comment
The graphlog functionality has been in core since Mercurial 2.3.
2013-11-22 19:13:26 +01:00
Bryan O'Sullivan
0fb3ccb7e6 Merge 2013-11-26 21:55:21 -08:00
Abhay Kadam
fbe291d0cf mercurial/parsers.c: fix compiler warning
When try to compile on x64 OS X, I get this warning:

mercurial/parsers.c:931:27: warning: implicit conversion loses integer precision
: 'long' to 'int' [-Wshorten-64-to-32]
                        ? 4 : self->raw_length / 2;

The patch verifies if value of self->raw_length falls bellow INT_MAX; if not,
it raises the ValueError exception.

If value of self->raw_length is greater than 4, it's casted to int type, to
eliminate the warning.
2013-11-19 23:49:11 +05:30
Matt Mackall
05fd1f2542 merge with stable 2013-11-25 16:15:44 -06:00
Siddharth Agarwal
9b0eab9940 bookmarks: make setcurrent with None an error 2013-11-15 18:41:40 -08:00