Commit Graph

11034 Commits

Author SHA1 Message Date
Lucas Moscovicz
d6c47fdc4c revset: added _intlist method to replace _list for %ld
Now %ld expression goes through _intlist and doesn't do any unnecesary
processing anymore.
2014-02-26 12:36:36 -08:00
Lucas Moscovicz
5e0ec4bc97 scmutil: changed revrange code not to use append
Removed one call to the append method
2014-02-24 09:27:32 -08:00
anuraggoel
aaf6714e39 push: provide a hint when no paths in configured (issue3692)
When user type "hg push" command then this patch helps user by
providing hint if no default path is configured.

Second patch is the test coverage, to test the change behaviour of
first patch.
2014-02-25 04:11:11 +05:30
Mads Kiilerich
de55a8fdda revlog: introduce commonancestors method for getting all common ancestor heads 2014-02-24 22:42:14 +01:00
Mads Kiilerich
8cf3bd4f00 localrepo: commit: avoid calling expensive ancestor function when p1 is nullrev 2014-02-24 22:42:14 +01:00
Mads Kiilerich
451439c52b ancestors: remove unnecessary handling of 'left'
If one of the initial nodes also is an ancestor then that most be the only
ancestor. There is no need for additional bookkeeping.
2014-02-24 22:42:13 +01:00
Mads Kiilerich
e38a229881 parsers: remove unreachable and invalid code in index_ancestors
The function normally returns a list. Returning a single element instead of a
list with one element would be weird.
2014-02-24 22:42:13 +01:00
Lucas Moscovicz
2663ae5f88 cmdutil: implemented new lazy increasingwindows
Now log can work in a lazy way and get results as soon as they are processed.

Performance Benchmarking:

$ time hg log -l1 -qr "branch(default)"
0:3a6a38229d41

real  0m2.303s
user  0m2.252s
sys 0m0.048s

$ time ./hg log -l1 -qr "branch(default)"
0:3a6a38229d41

real  0m0.238s
user  0m0.199s
sys 0m0.037s
2014-02-13 14:27:12 -08:00
Lucas Moscovicz
59ef037f26 revset: added __nonzero__ method to lazyset
Now it doesn't have to go through all the set and can return lazily as soon as
it finds one element.
2014-02-20 10:15:38 -08:00
Lucas Moscovicz
ec3c3a2803 scmutil: changed revrange to return lazysets for new style revsets
When there is an old style revset or both it will still return a baseset. This
may be changed in later patches.
2014-02-12 15:30:27 -08:00
Mads Kiilerich
02d72edf5e phases: make order of debug output 'removing unknown node' deterministic 2014-02-20 02:43:17 +01:00
Mads Kiilerich
92dc407d90 comments: fix minor spelling issues found with spell checker 2014-02-20 02:39:01 +01:00
Mads Kiilerich
906d7f81d3 hooks: for python hooks, consistently use __name__ etc as name, not the repr
There is no reason to expose unnecessary Python implementation details and
memory locations, also not in debug mode.

readablefunc was already creating a nice name - we move that functionality
up and reuse it.

We consider having a __call__ and being types.FunctionType sufficiently
similar and unify these two to just using the existing check for __call__.
2014-02-15 01:23:12 +01:00
Mads Kiilerich
ae52b69f2f hooks: move logging of hook name to after we have found the hook
We do not expect the finding process to take a significant amount of time - it
is the execution time of the hook we care about.
2014-02-15 01:23:12 +01:00
Mads Kiilerich
670469e4bf log: describe graph symbols in the help
I wondered what 'x' meant and didn't find it described anywhere.
2014-02-12 23:44:30 +01:00
Mads Kiilerich
877ecd2425 util: debugstacktrace, flush before and after writing
Close another stream (default stdout, which often is buffered) before writing
to the primary stream (default stderr, which often is unbuffered). The primary
stream is also flushed after writing (in case it is buffered).

This fixes non-deterministic output order, especially on windows.
2014-02-20 02:38:36 +01:00
Lucas Moscovicz
b6ae0f9720 revset: added cached generated list on generatorset
This allows to iterate the generatorset more than once.
2014-02-12 18:45:49 -08:00
Sean Farley
4e69c94634 templater: shorten pure integers
Originally, the addition of the 'shorten' template function in 83d773060c28
would not consider pure integers for shortening. This patch considers two
simple cases: when the integer starts with zero (which is parsed by Mercurial
as a hash first) and when the integer is larger than the tip (obviously not a
rev).
2014-02-20 00:46:13 -06:00
Lucas Moscovicz
e97b3cbf9e revset: fixed bug where log -f was taking too long to return 2014-02-21 13:16:17 -08:00
Matt Mackall
943df77db4 merge with stable 2014-02-20 16:12:27 -06:00
Lucas Moscovicz
bee2c6a618 revset: added generatorset class with cached __contains__ method 2014-02-05 15:23:11 -08:00
Lucas Moscovicz
cf5a2af3df revset: changed last implementation to use lazy classes
Instead of using getitem just reverse the revision list and get the first
'lim' elements. With classes like spanset which are easily reversible this
will work faster.

Performance Benchmarking:

$ time hg log -qr "last(all())"
...

real  0m0.569s
user  0m0.447s
sys 0m0.122s

$ time ./hg log -qr "last(all())"
...

real  0m0.215s
user  0m0.150s
sys 0m0.063s
2014-02-19 12:56:41 -08:00
Matt Mackall
d800d72300 merge with stable 2014-02-19 16:46:47 -06:00
Simon Heimberg
18c74b7667 help: remove last occurrences of ".. note::" without two newlines
When we add two newlines after ".. note::" translators will not see this
entry. And all versions of docutils interpret this paragraph correctly
(details in 89e31d6e438f).
2014-02-19 13:25:28 +01:00
Durham Goode
df5ed0b04d help: add ifcontains, revset, and shortest to template help
Adds help information to the template help doc. Mentions ifcontains, revset,
shortest, and current in bookmarks.
2014-02-18 14:48:56 -08:00
Kaz Nishimura
4b71b65646 win32: improve the performance of win32.unlink() over CIFS
Emulating POSIX unlink() behavior with os.rename() and os.unlink() is often slow
especially over CIFS from Windows clients due to its protocol overhead. This
patch changes win32.unlink() to try first an exclusive open with the Win32
delete-on-close flag, and if a sharing violation is detected, to fall back to
the original emulation.

This patch also removes a test with os.path.isdir() since we expect opening a
directory shall fail as os.unlink() would.

Example measurements (repeated 3-times after 1-time calibration):

(Without this patch: hg update from null to default)
127 files updated, 0 files merged, 0 files removed, 0 files unresolved
time: real 19.871 secs (user 0.328+0.000 sys 1.794+0.000)
time: real 19.622 secs (user 0.312+0.000 sys 2.044+0.000)
time: real 19.138 secs (user 0.250+0.000 sys 1.872+0.000)

(Without this patch: hg update from default to null)
0 files updated, 0 files merged, 127 files removed, 0 files unresolved
time: real 35.158 secs (user 0.156+0.000 sys 2.512+0.000)
time: real 35.272 secs (user 0.250+0.000 sys 2.512+0.000)
time: real 36.569 secs (user 0.203+0.000 sys 2.387+0.000)

(With this patch: hg update from null to default)
127 files updated, 0 files merged, 0 files removed, 0 files unresolved
time: real 17.893 secs (user 0.328+0.000 sys 1.700+0.000)
time: real 18.512 secs (user 0.265+0.000 sys 1.529+0.000)
time: real 20.238 secs (user 0.312+0.000 sys 1.685+0.000)

(With this patch: hg update from default to null)
0 files updated, 0 files merged, 127 files removed, 0 files unresolved
time: real 12.312 secs (user 0.250+0.000 sys 0.811+0.000)
time: real 12.471 secs (user 0.156+0.000 sys 0.889+0.000)
time: real 9.727 secs (user 0.125+0.000 sys 0.858+0.000)
2013-10-17 13:27:17 +09:00
Lucas Moscovicz
131799c6de revset: changed mfunc and getset to work with old style revset methods
Now extensions shouldn't break when adding new revsets.
2014-02-18 15:54:46 -08:00
Lucas Moscovicz
ba7cfe4ed4 revset: changed revsets to use spanset
Performance Benchmarking:

$ hg perfrevset "first(all())"
! wall 0.304936 comb 0.300000 user 0.280000 sys 0.020000 (best of 33)

$ ./hg perfrevset "first(all())"
! wall 0.175640 comb 0.180000 user 0.160000 sys 0.020000 (best of 56)
2014-02-03 10:15:15 -08:00
Lucas Moscovicz
6e0e0d512b revset: changed spanset to take a repo argument
This way, we can have by default the length of the repo as the end argument
and less code has to be aware of hidden revisions.
2014-02-18 11:38:03 -08:00
Matt Mackall
0122021cb0 journal: report parsing errors on recover/rollback (issue4172) 2014-02-17 14:49:56 -06:00
Lucas Moscovicz
4961b39b44 revset: changed spanset implementation to take hidden revisions into account
Hidden revisions are now excluded from the spanset.
Now this doesn't break for people using changeset evolution.
2014-02-10 17:38:43 -08:00
Durham Goode
2d869e6a8e template: add 'current' to scope during {bookmarks % ...}
This adds the keyword 'current' to the template scope when processing a
bookmark list. The 'current' keyword resolves to the name of the currently
active bookmark in the repo. This allows us to apply special labels to the
current bookmark to distinguish it (especially in the case where there are
multiple bookmarks on the same commit).

Example: "{bookmarks % '{bookmark}{ifeq(bookmark, current, \"*\")} '}"

Results in a space separated list of bookmarks where the current bookmark has
an asterix.
2014-02-11 21:40:33 -08:00
Durham Goode
f8aca20bcb template: add revset() template function
Adds a template function that executes a revset and returns the list of
revisions as the result. It has the signature 'revset(query [, args...])'. The
args are optional and are applied to the query string using the standard
python string.format(args) pattern. This allows things like:
'{revset("parents({0})", rev)}' to produce the parents of each individual
commit in the log output.  If no args are specified, the revset result is
cached for the duration of the templater; so it's better to not use args if
performance is a concern.

By itself, revset() can be used to print commit parents, print the common
ancestor of a commit with the main branch, etc.

It can be used with the ifcontains() function to do things like
'{ifcontains(rev, revset('.'), label(...), ...)}' to color the working copy
parent, to color certain branches, to color draft commits, etc.
2014-02-11 21:04:12 -08:00
Durham Goode
cb61deed09 template: add ifcontains template function
Adds a template function with the signature 'ifcontains(item, set, then[,
else])'.  It can be used to do things like '{ifcontains('.hgignore',
file_mods, label(...), ...)}' to color commits that edit the .hgignore file.
A future patch will add the revset() function which will combine with
ifcontains to allow us to color commits if they are in the revset.
2014-02-11 21:10:00 -08:00
Pierre-Yves David
1c8096195c createmarkers: allow to pass metadata for a marker only
The `metadata` argument only allow to specify metadata for all new markers. We
extension the format of the `relations` argument to support optional metadata
argument.

The first user of this should be the evolve extension who want to store parent
information of pruned changeset in extra (until we make a second version of the
format)
2014-02-13 17:34:09 -08:00
Pierre-Yves David
098932cf2d obsstore: update create docstring to point to the coder friendly function
The `obsstore` class have a `create` method that create new obsolescence marker
from node. There is another function in the same module `createmarkers`. This
other function is higher level and automatically missing meta data (ultimately
calling the first one)

We add a new comment in the docstring of `obsstore.create` highlighting that
people writing new code probably want to use the top level one.
2014-02-13 17:33:45 -08:00
Lucas Moscovicz
3d8c71a8cc revset: added cache to lazysets
This allows __contains__ to return faster when asked for same value twice.
2014-02-04 15:31:57 -08:00
Mads Kiilerich
8c0ff878d1 discovery: make "note: unsynced remote changes!" less serious than a warning
This situation is not necessarily a problem and do not deserve a warning. It is
just some information that can guide the user in understanding what is going
on.

Making it 'debug' would usually not give the hint when it is relevant so we
make it a 'status' message.
2014-02-07 17:24:12 +01:00
Mads Kiilerich
303021da0b discovery: improve "note: unsynced remote changes!" warning
This message frequently caused confusion. "unsynced" is not a well established
user-facing concept in Mercurial and the message was not very specific or
helpful.

Instead, show a message like:
  remote has heads on branch 'default' that are not known locally: 6c0482d977a3

This message will also (when relevant) be shown before aborting on "push
creates new remote head".

A similar (but actually very different) message was addressed in cbd5a12a601a.
2014-02-06 02:19:38 +01:00
Pierre-Yves David
aa3270ed1f import: move tryone closure in cmdutil
We extract the `tryone` function into the `cmdutil` module. A lot of the command
context have to be passed to the utility function, but having and explicit
declaration will allow extension to wrap it. This will allows use to make
changeset evolution related experiment in dedicated extension.

Improving the API of this function is noble goal but outside of the scope of
this patches.
2014-02-11 16:52:36 -08:00
Siddharth Agarwal
2c51509bb0 revset: optimize missing ancestor expressions
A missing ancestor expression is any expression of the form (::x - ::y) or
equivalent. Such expressions are remarkably common, and so far have involved
multiple walks down the DAG, followed by a set difference operation.

With this patch, such expressions will be transformed into uses of the fast
algorithm at ancestor.missingancestor.

For a repository with over 600,000 revisions, perfrevset for '::tip - ::-10000'
returns:

Before: ! wall 3.999575 comb 4.000000 user 3.910000 sys 0.090000 (best of 3)
After:  ! wall 0.132423 comb 0.130000 user 0.130000 sys 0.000000 (best of 75)
2014-02-13 14:04:47 -08:00
Siddharth Agarwal
2a56880ad4 revset: add an undocumented _missingancestors function
This will be used in an upcoming patch to optimize expressions of the form
(::x - ::y).
2014-02-13 13:54:45 -08:00
Siddharth Agarwal
bf7fddd84c commands.debugrevspec: add an option to print the optimized expression tree
This will be used in an upcoming patch to test that the optimizer works.
2014-02-13 13:52:45 -08:00
Matt Mackall
05f4273a32 merge with crew 2014-02-13 15:33:24 -06:00
Thomas Arendsen Hein
efdcaf3f31 merge with stable 2014-02-13 13:08:50 +01:00
Pierre-Yves David
3f17a93498 pull: move changeset pulling in its own function
pull: move changeset pulling in its own function

Now that every necessary information is held in the `pulloperation` object, we
can finally extract the changeset pulling to it's own function.

This changeset is pure code movement only.
2014-01-31 01:39:59 -08:00
Pierre-Yves David
9f09184d30 pull: move fetch subset into the object
Tree discovey use a `fetch` variable to know what is being pulled. We move this
information in the `pulloperation` object. This make it possible to extract the
changeset pulling logic into its own function.
2014-02-11 14:51:38 -08:00
Pierre-Yves David
af185d32f5 pull: make pulled subset a propertycache of the pull object
The computation of the subset is simple operation using two useful pull
information (1) the set of common changeset before the pull (2) the set of
pulled changeset. We move this data into the `pulloperation` object since some
phase will need them. And we turn the pulled subset computation behind a
property case as multiple pull phase will need it.
2014-01-31 01:34:00 -08:00
Pierre-Yves David
ad09bf1d2b pull: move phases synchronisation in its own function
Now that every necessary information is held in the `pulloperation` object, we
can finally extract the phase synchronisation phase to it's own function.

This changeset is pure code movement only.
2014-01-31 01:25:56 -08:00
Pierre-Yves David
542abb260f pull: move pulled subset into the object
We compute the set of local changeset that were target of the pull. This is then
used by phases logic to decide which part of the history should have it phase
updated.

We move this information into the object to allow extraction of phase
synchronisation in its own function.

I expect obsolete marker exchange to use it too in the future.
2014-01-31 01:21:42 -08:00
Lucas Moscovicz
3a2188dac4 revset: added operations to spanset to duck type baseset
Added more operations which are not lazy but only used so far to duck type
baseset.
2014-02-06 15:56:25 -08:00
Lucas Moscovicz
e8f60a5520 revset: added basic operations to spanset
Added methods __add__, __sub__ and __and__ to duck type more methods in
baseset
2014-02-12 10:22:43 -08:00
Lucas Moscovicz
9ce7f8243d revset: added spanset class to represent revision ranges 2014-02-12 10:16:21 -08:00
Lucas Moscovicz
97db49c09a revset: added lazyset implementation to extra revset 2014-02-06 08:36:11 -08:00
Lucas Moscovicz
1d43685667 revset: added lazyset implementation to converted revset 2014-02-06 08:32:40 -08:00
Lucas Moscovicz
a871b2cef1 revset: added lazyset implementation to closed revset 2014-02-06 08:31:55 -08:00
Pierre-Yves David
9e5b5327f1 push: feed pulloperation object to _pullobsolete function
We now have all necessary information in the `pulloperation` object itself.
2014-01-31 01:12:35 -08:00
Pierre-Yves David
f0ae9ab368 pull: move transaction logic into the pull object
Most local change that occurs during a pull are doing within a `transaction`.
Currently this mean (1) adding new changeset (2) adding obsolescence markers. We
want the two operations to be done in the same transaction. However we do not
want to create a transaction if nothing is added to the repo. Creating an empty
transaction would drop the previous transaction data and confuse tool and people
who are still using rollback.

So the current pull code has some logic to create and handle this transaction on
demand. We are moving this logic in to the `pulloperation` object itself to
simplify this lazy creation logic through all different par of the push.

Note that, in the future, other part of pull (phases, bookmark) will probably
want to be part of the transaction too.
2014-01-31 01:04:05 -08:00
Pierre-Yves David
33b568da08 pull: move obsolescence marker exchange in the exchange module
The obsolescence marker exchange code was already extracted during a previous
cycle. We are moving the extracted functio in this module. This function will
read and write data in the `pulloperation` object and I prefer to have all core
function collaborating through this object in the same place.

This changeset is pure code movement only. Code change for direct consumption of
the `pulloperation` object will come later.
2014-01-30 17:38:41 -08:00
Pierre-Yves David
b3035d77ba pull: move force argument into pull object
One more step toward a more modular pulh function.
2014-02-01 03:49:29 -08:00
Pierre-Yves David
f36dde4c52 pull: move heads argument into pull object
One more step toward a more modular pull function.
2014-01-30 17:35:55 -08:00
Pierre-Yves David
586b7945da pull: move remote argument into pull object
One more step toward a more modular pull function.
2014-01-30 17:32:04 -08:00
Pierre-Yves David
9191d202bb pull: introduce a pulloperation object
This object will hold all data and state gathered through the pull. This will
allow us to split the long function into multiple small one. Smaller function
will be easier to maintains and wrap.  The idea is to blindly store all
information related to the pull in this object so that each step and extension
can use them if necessary.

We start by putting the `repo` variable in the object. More migration in other
function.
2014-01-30 17:24:49 -08:00
Pierre-Yves David
e54cd58994 debugobsolete: extract marker display in a dedicated function
We want to be able to reuse and extend it from other function or
extension while working on markers exchange.

This changeset is pure core movement.
2014-02-11 16:30:23 -08:00
Pierre-Yves David
790a805eac exchange: extract pull function from localrepo
The localrepo class if far too big. Push and pull logic are extracted and
reworked to better fit with the fact we exchange more than bundle now.

This changeset extract the pulh code. later changeset will slowly slice it into
smaller brick.

The localrepo.pull method is kept for now to limit impact on user code. But it
will be ultimately removed, now that the public API is hold by peer.
2014-01-30 16:12:49 -08:00
Pierre-Yves David
19dbca86d4 push: extract new common set computation from phase synchronisation
Now that every necessary information is held in the `pushoperation` object, we
can extract the new common set computation to it's own function.

This changeset is pure code movement only.
2014-01-30 23:12:03 -08:00
Pierre-Yves David
00a8d606ca push: move commonheads into the push object
The phase synchronisation start by computing the new set of common head between
local and remote and then do the phase synchronisation on this set. This new
common set logic will eventually be used by the obsolescence markers exchange.
So we are going to split the long phase synchronisation in two.
2014-01-30 23:16:43 -08:00
Pierre-Yves David
54bbace959 push: move discovery in its own function
Now that every necessary information is held in the `pushoperation` object, we
can extract the discovery logic to it's own function.

This changeset is pure code movement only.
2014-01-30 21:05:29 -08:00
Pierre-Yves David
9e52053ef7 push: move outgoing check logic in its own function
Now that every necessary information is held in the `pushoperation` object, we
can extract the part responsible of aborting the push to it's own function.

This changeset is mostly pure code movement. the exception is the fact this
function returns a value to decide if changeset bundle should be pushed.
2014-01-30 21:01:21 -08:00
Pierre-Yves David
6d2b03f7d5 push: move incoming into the push object
The fact that there is some unknown changes on remote one of the result of
discovery. It is then used by some push validation logic.

We move it in the object to be able to extract the said logic.
2014-01-30 21:01:13 -08:00
Pierre-Yves David
a2cf760f9e push: move changeset push logic in its own function
Now that every necessary information is held in the `pushoperation` object, we
can extract the logic pushing changeset  to it's own function.

This changeset is pure code movement only.
2014-01-30 20:44:55 -08:00
Pierre-Yves David
e83b253ec0 push: move remoteheads into the push object
The heads of the remote repository are used to detect race when pushing
changeset. We now store this information in `pushoperation` object  to allow
extraction of the changeset pushing part.
2014-01-30 20:34:35 -08:00
Lucas Moscovicz
082b56b0fb revset: added lazyset implementation to contains revset 2014-02-04 15:07:03 -08:00
Lucas Moscovicz
7a6459e30d revset: added lazyset implementation to secret revset 2014-02-04 09:29:19 -08:00
Lucas Moscovicz
c27606d6ba revset: added lazyset implementation to matching revset
Performance Benchmarking:

$ time hg log -qr "first(matching(0))"
0:3a6a38229d41

real  0m2.213s
user  0m2.149s
sys 0m0.055s

$ time ./hg log -qr "first(matching(0))"
0:3a6a38229d41

real  0m0.177s
user  0m0.137s
sys 0m0.038s
2014-02-04 09:14:45 -08:00
Lucas Moscovicz
2f1f581a8c revset: added lazyset implementation to _matchfiles
Performance Benchmarking:

$ time hg log -qr "first(file(README))"
0:3a6a38229d41

real  0m2.234s
user  0m2.180s
sys 0m0.044s

$ time ./hg log -qr "first(file(README))"
0:3a6a38229d41

real  0m0.172s
user  0m0.129s
sys 0m0.042s
2014-02-04 08:51:07 -08:00
Lucas Moscovicz
3bfbd34602 revset: added lazyset implementation to checkstatus
This improves the performance of the revsets 'adds' 'modifies' and 'removes'

Performance benchmarking:

$ time hg log -qr "first(adds(README))"
0:3a6a38229d41

real  0m2.279s
user  0m2.222s
sys 0m0.053s

$ time ./hg log -qr "first(adds(README))"
0:3a6a38229d41

real  0m0.172s
user  0m0.131s
sys 0m0.041s

$ time hg log -qr "first(modifies(README))"
1:692bee203f23

real  0m2.292s
user  0m2.227s
sys 0m0.061s

$ time ./hg log -qr "first(modifies(README))"
1:692bee203f23

real  0m0.178s
user  0m0.130s
sys 0m0.038s

$ time hg log -qr "first(removes(README))"
2379:f24de2acd560

real  0m2.297s
user  0m2.235s
sys 0m0.058s

$ time ./hg log -qr "first(removes(README))"
2379:f24de2acd560

real  0m0.975s
user  0m0.797s
sys 0m0.056s
2014-01-31 10:47:51 -08:00
Lucas Moscovicz
8cb1ccfe44 revset: added lazyset implementation to public revset
Performance Benchmarking:

$ time hg log -qr "first(public())"
...

real  0m1.184s
user  0m1.051s
sys 0m0.130s

$ time ./hg log -qr "first(public())"
...

real  0m0.548s
user  0m0.427s
sys 0m0.118s
2014-01-30 17:46:08 -08:00
Lucas Moscovicz
69d62676c5 revset: added lazyset implementation to merge revset
Performance benchmarking:

$ time hg log -qr "first(merge())"
102:1634643e0cd8

real  0m0.276s
user  0m0.208s
sys 0m0.047s

$ time ./hg log -qr "first(merge())"
102:1634643e0cd8

real  0m0.192s
user  0m0.154s
sys 0m0.027s
2014-01-30 16:47:29 -08:00
Lucas Moscovicz
f18b7c26e0 revset: added lazyset implementation to grep revset
Performance benchmarking:

$ time hg log -qr "first(grep(hg))"
0:3a6a38229d41

real  0m2.214s
user  0m2.163s
sys 0m0.045s

$ time ./hg log -qr "first(grep(hg))"
0:3a6a38229d41

real  0m0.211s
user  0m0.146s
sys 0m0.035s
2014-01-30 16:03:18 -08:00
Lucas Moscovicz
ab42b4bbc5 revset: added lazyset implementation to desc revset
Performance benchmarking:

$ time hg log -qr "first(desc(hg))"
changeset:   0:3a6a38229d41

real  0m2.210s
user  0m2.158s
sys 0m0.049s

$ time ./hg log -qr "first(desc(hg))"
changeset:   0:3a6a38229d41

real  0m0.171s
user  0m0.131s
sys 0m0.035s
2014-01-30 15:39:56 -08:00
Lucas Moscovicz
6ba591c77e revset: added lazyset implementation to draft revset 2014-02-03 16:15:25 -08:00
Lucas Moscovicz
57e67b73a7 revset: added lazyset implementation bookmark revset 2014-01-29 15:23:16 -08:00
Lucas Moscovicz
28688b6d54 revset: added lazyset implementation to date revset
Performance Benchmarking:

$ time hg log -qr "first(date(05/03/2005))"
0:3a6a38229d41

real  0m3.157s
user  0m2.994s
sys 0m0.087s

$ time ./hg log -qr "first(date(05/03/2005))"
0:3a6a38229d41

real  0m0.509s
user  0m0.289s
sys 0m0.070s
2014-02-03 16:02:48 -08:00
Lucas Moscovicz
d80d16c98c revset: added lazyset implementation to author revset
Performance benchmarking:

$ time hg log -qr "first(author(mpm))"
0:3a6a38229d41

real  0m3.486s
user  0m3.317s
sys 0m0.077s

$ time ./hg log -qr "first(author(mpm))"
0:3a6a38229d41

real  0m0.551s
user  0m0.295s
sys 0m0.072s
2014-01-29 09:22:31 -08:00
Lucas Moscovicz
fe40abc599 revset: added lazyset implementation to keyword revset
Performance benchmarking:

$ time hg log -qr "first(keyword(changeset))"
0:3a6a38229d41

real  0m3.466s
user  0m3.345s
sys 0m0.072s

$ time ./hg log -qr "first(keyword(changeset))"
0:3a6a38229d41

real  0m0.365s
user  0m0.199s
sys 0m0.083s
2014-01-29 09:04:03 -08:00
Lucas Moscovicz
303bd9d554 revset: changed limit revset implementation to work with lazy revsets
Performance benchmarking:

$ time hg log -qr "first(branch(default))"
0:3a6a38229d41

real  0m3.130s
user  0m3.025s
sys 0m0.074s

$ time ./hg log -qr "first(branch(default))"
0:3a6a38229d41

real  0m0.300s
user  0m0.198s
sys 0m0.069s
2014-01-28 16:19:30 -08:00
Lucas Moscovicz
7a6ce89407 revset: added lazyset implementation to branch revset
Performance Benchmarking:

$ time hg log -l1 -qr "branch(default)"
0:3a6a38229d41

real  0m3.366s
user  0m3.217s
sys 0m0.095s

$ time ./hg log -l1 -qr "branch(default)"
0:3a6a38229d41

real  0m0.389s
user  0m0.199s
sys 0m0.061s
2014-02-05 16:12:03 -08:00
Lucas Moscovicz
0ff716dae6 revset: changed getset so that it can return a lazyset
Not converting it manually to a baseset anymore. At this point every revset
method should return a baseset typed structure.
2014-01-28 15:19:14 -08:00
Pierre-Yves David
48473f3287 push: move phases synchronisation function in its own function
Now that every necessary information is held in the `pushoperation` object, we
can finally extract the phase synchronisation phase to it's own function. This
is the first concrete block of code we extract from the huge push function.
Hooray!

This changeset is pure code movement only.
2014-01-30 20:22:43 -08:00
Pierre-Yves David
a17a66f49e push: move outgoing object in the push object
The set of outgoing and common changeset are used by phases to compute the new
common set between local and remote. So we need to move it into the object to
extract the phase sync from the god function.

Note that this information will be used by obsolescence markers too.
2014-01-30 20:18:26 -08:00
Pierre-Yves David
d37c15cc69 push: move push return value in the push object
The return code convey information about the success of changeset push. This is
used by phases to compute the new common set between local and remote. So we
need to move it into the object to extract the phase sync from the god
function.

Note that this information will be used by obsolescence markers too.
2014-01-30 19:43:28 -08:00
Pierre-Yves David
01ce069d96 push: move local phase move in a normal function
We now have the modularity for simpler approach `localphasemove`.
2014-01-30 20:10:59 -08:00
Pierre-Yves David
cad91f44e1 push: explicitly feed pushop to localphasemove
Now that pushop is holding all the push related data, we do not really need a
closure anymore. So we start feeding the object to `localphasemove` and will
make it a normal function in the next commit.
2014-01-30 20:09:21 -08:00
Pierre-Yves David
229e0e4cb0 push: move local lock logic in pushoperation
During push, we try to lock the local repo to move local phase according to what
we saw/pushed on the remote repo. Locking the repo may fail, in that case we let
the push proceed without local phase movement (printing warning).

This mean we have code in phase synchronisation that will check if the local repo is
locked or not. we need to move this information in the push object to be able to
extract the phase synchronisation in its own function. This is done as a boolean
because putting reference to the actual lock outside of the main function
sounded a bad idea.
2014-01-30 20:00:34 -08:00
Pierre-Yves David
018f4f94d4 push: move obsolescence related message into _pushobsolescence function
No good reason to have them in the main fonction.
2014-01-30 19:55:09 -08:00
Pierre-Yves David
fdca8c570d push: drop now outdated comment
This `_pushobsolete` now exist for modularity purpose.
2014-01-30 19:51:21 -08:00
Pierre-Yves David
0259725b46 push: feed pushoperation object to _pushobsolete function
This will allow the obsolete marker synchronisation to have full
information on the ongoing push and pass information to other
operation.
2014-01-30 17:56:09 -08:00
Pierre-Yves David
97a8524afb push: move obsolescence marker exchange in the exchange module
The obsolescence marker exchange code was already extracted during a previous
cycle. We are moving the extracted functio in this module. This function will
read and write data in the `pushoperation` object and I prefer to have all core
function collaborating through this object in the same place.

This changeset is pure code movement only. Code change for direct consumption of
the `pushoperation` object will come later.
2014-01-30 17:54:47 -08:00
Pierre-Yves David
d2cbf08f57 push: feed pushoperation object to _pushbookmark function
This will able the bookmark synchronisation to have full information on the
ongoing push and pass information to other operation.
2014-01-30 17:51:41 -08:00
Matt Mackall
fd00785c66 merge with stable 2014-02-10 17:31:26 -06:00
Lucas Moscovicz
fb15b99ea8 revset: added operations to duck type baseset
Added more operations which are not lazy but only used so far to duck type
baseset.

Their implementations will be changed in future patches.
2014-02-06 14:29:37 -08:00
Lucas Moscovicz
dd14a88eaa revset: added basic operations to lazyset
Added methods __add__, __sub__ and __and__ to duck type more methods in
baseset
2014-02-06 14:25:37 -08:00
Lucas Moscovicz
939eba25eb revset: added lazyset class with basic operations
This class allows us to return values from large revsets as soon as they are
computed instead of having to wait for the entire revset to be calculated.
2014-02-06 14:19:40 -08:00
Simon Heimberg
7b0d35f51c win32: spawndetached returns pid of detached process and not of cmd.exe
win32.spawndetached starts the detached process by `cmd.exe` (or COMSPEC). The
pid it returned was the one of cmd.exe and not the one of the detached process.
When this pid is used to kill the process, the detached process is not killed,
but only cmd.exe.

With this patch the pid of the detached process is written to the pid file.
Killing the process works as expected.

The pid is only evaluated on writing the pid file. It is unnecessary to search
the pid when it is not needed. And more important, it probably does not yet
exist right after the cmd.exe process was started. When the pid is written to
the file, waiting for the start of the detached process has already happened.
Use this functionality instead of writing a 2nd wait function.

Many tests on windows will not fail anymore, all those with the first failing
line "abort: child process failed to start". (The processes still hanging
around from previous test runs have to be killed first. They still block a
tcp port.)
A good test for the functionality of this patch is test-treediscovery.t,
because it starts and kills `hg serve -d` several times.
2014-02-08 14:35:07 +01:00
Lucas Moscovicz
5ea4d9b527 revset: minor changes adding baseset to revsets
Changed bits of code to work with baseset implementations.
2014-02-06 14:57:25 -08:00
Matt Mackall
35b203d694 merge with stable 2014-02-09 18:36:37 -06:00
Lucas Moscovicz
c5d089f8a5 revset: minor changes adding baseset to revsets
Changed bits of code to work with baseset implementations.
2014-02-06 14:57:25 -08:00
Lucas Moscovicz
91dcdf4e40 revset: added __add__ method to baseset class 2014-02-06 11:37:16 -08:00
Lucas Moscovicz
03857b594a revset: added docstring to baseset class 2014-02-06 11:33:36 -08:00
Mads Kiilerich
a649a1436b localrepo: make it clear that changegroupsubset doesn't take bases but roots
changegroupsubset will take the parents of the roots to find the bases.

Other parts of Mercurial do not expect that, and a result of that is that some
bundles contain more changesets than necessary.

No real changes here - just renaming a parameter to document what it is.
2014-02-10 00:52:16 +01:00
Augie Fackler
859551f9b1 repoview: use repo.revs() instead of a private revset method
Breaks an import cycle.
2014-02-04 17:13:45 -05:00
Augie Fackler
888bc814fa commands: use ctx.getfileset instead of fileset.getfileset 2014-02-04 14:55:04 -05:00
Matt Mackall
5a04f42dce push: backout b359130ef1bc due to test failures 2014-02-09 17:31:26 -06:00
Augie Fackler
edc98c0164 match: use ctx.getfileset() instead of fileset.getfileset()
Resolves an import cycle involving match and merge.
2014-02-04 14:54:42 -05:00
Augie Fackler
550a17aab3 context: add a getfileset() method so fewer things need fileset directly
Allows me to break an import cycle in a subsequent change.
2014-02-04 15:27:49 -05:00
Mads Kiilerich
fee088299f discovery: improve "note: unsynced remote changes!" warning
This note (which actually is a warning) frequently caused confusion.
"unsynced" is not a well established user-facing concept in Mercurial and the
message was not very specific or helpful.

Instead, show a messages like:
  remote has heads on branch 'default' that are not known locally: 6c0482d977a3
and show it before aborting on "push creates new remote head". This will also
give more of a hint in the case where the branch has been closed remotely and
'hg heads' thus not would show any new heads after pulling.

A similar (but actually very different) message was addressed in cbd5a12a601a.
2014-02-06 02:19:38 +01:00
Lucas Moscovicz
0c945a320b revset: fixed bug where revset returning order was being changed
Some revsets were innecesarily turning the subset into a set before iterating
over it. This led to returning order changing in some cases.
2014-02-07 15:01:33 -08:00
Augie Fackler
8bfe6ea1ed itersubrepos: move to scmutil to break a direct import cycle 2014-02-03 18:36:00 -05:00
Simon Heimberg
d11bb41a51 commands: hg debuginstall checks missing templates (issue4151)
Missing templates where not reported as a problem, only an empty bracket
were shown as indication of no found template directory:
  $ hg debuginstall
  *...some lines*
  checking templates ()...
  *...some lines*
  no problems detected

Now the problem is reported and extended with some information. The style
of the messages is adapted to the other messages of debuginstall.

When no templates directories exist, it writes:
  $ hg debuginstall
  *...some lines*
  checking templates ()...
   no template directories found
   (templates seem to have been installed incorrectly)
  *...some lines*
  1 problems detected, please check your install!

When the template map is not found, it writes:
  $ hg debuginstall
  *...some lines*
  checking templates (/path/to/mercurial/templates)...
   template 'default' not found
   (templates seem to have been installed incorrectly)
  *...some lines*
  1 problems detected, please check your install!

When the template map is buggy the message is the same as before. The error
message is shown before the line "(templates seem ...)".


No test is added because testing this failure is complicated. It would
require to modify the templates directory of the mercurial installation,
or to monkey patch a function (os.listdir or any from mercurial.templater)
by a test extension.
2014-01-27 11:17:07 +01:00
Mads Kiilerich
a2af430785 discovery: cleanup of variable names and comments 2014-02-06 02:17:48 +01:00
Mads Kiilerich
2e26bbb4c8 localrepo: give a sigh of relief when getting lock after waiting for it
A message like this was sometimes shown when pushing:
  remote: waiting for lock on repository foo held by 'mercurial:20858'
That could scare users, making them wonder whether the push actually succeeded.

To mitigate that fear, issue an additional "warning" such as:
  got lock after 2 seconds

The return value from lock.lock.lock() was unused - instead we return the
delay.

This also adds the first test coverage for waiting for locks.
2014-02-06 01:55:09 +01:00
Durham Goode
41c61c62a7 template: fix shortest(node) function in pure mercurial
Pure mercurial (i.e. without c extensions) does not support partialmatch() on
the revlog index, so we must fall back to use revlog._partialmatch() to handle
that case for us. The tests caught this.

We don't use revlog._partialmatch() for the normal case because it performs a
very expensive index iteration when the string being tested fails to find a
unique result via index.partialmatch(). It does this in order to filter
out hidden revs in hopes of the string being unique amongst non-hidden revs.
For the shortest(node) case, we'd prefer performance over worrying about
hidden revs.
2014-02-05 20:22:28 -08:00
Durham Goode
fe9653ca83 template: add pad function for padding output
Adds a pad template function with the following signature:

pad(text, width, fillchar=' ', right=False)

This uses the standard python ljust and rjust functions to produce a string
that is at least a certain width. This is useful for aligning variable length
strings in log output (like user names or shortest(node) output).
2014-01-17 00:16:48 -08:00
Durham Goode
156d6da226 template: add shortest(node) template function
Adds a '{shortest(node)}' template function that results in the shortest hex node
that uniquely identifies the changeset at that time. The minimum length can be
specified as an optional second argument and defaults to 4.

This is useful for producing prettier log output, like so:

@  durham  shortestnode
|  77cf    template: add pad function for padding output
|
o  durham
|  b183    template: add shortestnode keyword
|
o  pierre-yves @
|  6545    backout: add a message after backout that need manual commit
|
| o  durham   manifestcache
|/   93f0    manifest cache
|
| o  durham   catperf
| |  c765    cat: increase perf when catting single files
| |
| o  durham
|/   9c53    changectx: increase perf of walk function
|
2014-01-17 00:10:37 -08:00
Matt Mackall
b81a4c8743 merge with stable 2014-02-05 18:09:07 -06:00
Lucas Moscovicz
3d0344901f revset: added intersection to baseset class
Added the method __and__ to the baseset class to be able to intersect with
other objects in a more efficient way.
2014-01-24 16:57:44 -08:00
Lucas Moscovicz
f1e6aec1ef revset: added substraction to baseset class
Added __sub__ method to the baseset class to be able to compare it with other
subsets more efficiently.
2014-01-23 14:20:58 -08:00
Lucas Moscovicz
e0e3b9efa2 revset: implemented set caching for revset evaluation
Added set caching to the baseset class. It lazily builds the set whenever it's
needed and keeps a reference which is returned when the set is requested
instead of being built again.
2014-01-22 10:46:02 -08:00
Lucas Moscovicz
ef8bd69f5f revset: added baseset class (still empty) to improve revset performance
This class is going to be used to cache the set that is created from this list
in many cases while evaluating a revset.
2014-01-21 11:39:26 -08:00
Matt Mackall
5d2087f28a merge with stable 2014-02-03 18:09:08 -06:00
Pierre-Yves David
971cefa104 push: move bookmarks exchange in the exchange module
The bookmark exchange code was already extracted during a previous cycle. This
changesets moves the extracted function in this module. This function will read
and write data in the `pushoperation` object and It  is preferable to have all
core function collaborating through this object in the same place.

This changeset is pure code movement only. Code change for direct consumption of
the `pushoperation` object will come later.
2014-01-30 17:46:51 -08:00
Pierre-Yves David
49e928ef6b push: move newbranch argument into the push object
One more step toward a more modular push function.
2014-01-30 17:08:29 -08:00
Pierre-Yves David
579d48c27b push: move revs argument into the push object
One more step toward a more modular push function.
2014-01-30 17:04:23 -08:00
Pierre-Yves David
99860f7215 push: move force argument into the push object
One more step toward a more modular push function.
2014-01-30 16:59:25 -08:00
Pierre-Yves David
ab2b4d5db8 push: move remote argument in the push object
One more step toward a more modular push function.
2014-01-30 16:57:01 -08:00
Pierre-Yves David
97abb80300 push: ease access to current ui object
The `pushoperation.repo.ui` attribute is very commonly used. we offer a faster way
to access it directly through the push operation object.
2014-01-30 16:46:30 -08:00
Pierre-Yves David
836dd3b929 push: introduce a pushoperation object
This object will hold all data and state gathered through the push. This will
allow us to split the long function into multiple small one. Smaller function
will be easier to maintains and wrap.  The idea is to blindly store all
information related to the push in this object so that each step and extension
can use them if necessary.

We start by putting the `repo` variable in the object. More migration in other
changeset.
2014-01-30 16:43:11 -08:00
Pierre-Yves David
f35f0a3cb0 exchange: extract push function from localrepo
The localrepo class if far too big. Push and pull logic will be extracted and
reworked to better fit with the fact they now exchange more than plain changeset
bundle.

This changeset extract the push code. later changeset will slowly slice this
over 200 hundred lines and 8 indentation level function into smaller saner
brick.

The localrepo.push method is kept for now to limit impact on user code. But it
will be ultimately removed, now that the public supposed API is hold by peer.
2014-01-30 15:34:01 -08:00
Pierre-Yves David
4a16e8a21b phase: properly compute ancestors of --rev on push (issue3786)
Now that discovery is working on unfiltered changeset, I had a good occasion to
look at that bug again. This let me realise that a trivial node vs rev
comparision was the cause of this two years old bugs…

Happy second birthday phases!
2013-01-28 15:16:49 +01:00
Simon Heimberg
f9ed3a6ac4 templater: selecting a style with no templates does not crash (issue4140)
Running `hg log --style compact` (or any other style) raised a traceback when
no template directory was there. Now there is a message:

Abort: style 'compact' not found
(available styles: no templates found, try `hg debuginstall` for more info)


There is no test because this would require to rename the template directory.
But this would influence other tests running in parallel. And when the test
would be aborted the wrong named directory would remain, especially a problem
when running with -l.
2014-01-23 01:29:50 +01:00
Matt Mackall
47af0ab954 localrepo: drop dead comment 2014-01-19 22:58:33 -06:00
Pierre-Yves David
0420ab83f5 phases: add a formal note that hash of secret changeset may leak out
For technical reason (discovery, obsolescence marker) the hash of secret
changeset are communicated outside of your repo. We clarifie that in the help so
that people does not used hash of secret changeset as nuclear launch code.
2013-11-17 11:30:17 -05:00
Mads Kiilerich
3ee1a27c56 diff: search beyond ancestor when detecting renames
This removes an optimization that was introduced in 5a644704d5eb but was too
aggressive - as indicated by how it changed test-mq-merge.t .

We are walking filelogs to find copy sources and we can thus not be sure to hit
the base revision and find the renamed file there - it could also be in the
first ancestor of the base ... in the filelog.

We are walking the filelog and can thus not easily know when we hit the first
ancestor of the base revision and which filename to look for there. Instead, we
use _findlimit like mergecopies do: The lower bound for how far we have to go
is found from the lowest changelog revision that is an ancestor of only one of
the compared revisions. Any filelog ancestor with a revision number lower than
that revision will be the ancestor of both compared revisions, and there is
thus no reason to go further back than that.
2013-11-16 15:46:29 -05:00
Durham Goode
8db38e4850 cat: increase perf when catting single files
Special case the single file case in hg cat. This allows us to avoid
parsing the manifest, which shaves 15% off hg cat perf. This is worth
it, since automation often uses hg cat for retrieving single files.
2014-01-14 13:38:16 -08:00
Durham Goode
ffaaebd787 changectx: increase perf of walk function
When running 'hg cat -r . <file>' it was doing an expensive ctx.walk(m) which
applied the regex to every file in the manifest.

This changes changectx.walk to iterate over just the files in the regex, if no
other patterns are specified. This cuts hg cat time by 50% in our repo and
probably benefits a few other commands as well.
2014-01-14 13:49:19 -08:00
Lucas Moscovicz
178ffcb15d url: added authuri when login information is requested (issue3209)
When users are using a revset they can get multiple password prompts.
This prompts have no extra information about which password is being requested
so I added the authuri to the prompt to make it recognizable.

As in:
$ hg log -r "outgoing('https://bitbucket.org/mg/test') -
outgoing('https://bitbucket.org/nesneros/test')"
http authorization required
realm: Bitbucket.org HTTP
user: interrupted!

I changed it to describe the url when prompting for password.
As in:
$ hg log -r "outgoing('https://bitbucket.org/mg/test') -
outgoing('https://bitbucket.org/nesneros/test')"
http authorization required for https://bitbucket.org/mg/test
realm: Bitbucket.org HTTP
user: interrupted!
2014-01-15 16:46:20 -08:00
FUJIWARA Katsunori
f7f94c0f06 doc: add description about pattern matching against directories
Before this patch, there is no explicit description about pattern
matching against directories, even though users may understand it from
"plain examples" in "hg help patterns".

This patch adds description about pattern matching against
directories.
2014-01-17 23:55:11 +09:00
FUJIWARA Katsunori
9baf47cf1a revset: add explanation about the pattern without explicit kind
Before this patch, online help of "adds()", "contains()", "filelog()",
"file()", "modifies()" and "removes()" predicates doesn't explain
about how the pattern without explicit kind like "glob:" is treated,
even though each predicates treat it differently:

  - as "relpath:" by "adds()", "modifies()" and "removes()"

  - as "glob:" by "file()"

  - as special by "contains()" and "filelog()"
    - be relative to cwd, and
    - match against a file exactly
      ("relpath:" matches also against a directory)

This may confuse users.

This patch adds explanation about the pattern without explicit kind
to these predicates.
2014-01-17 23:55:11 +09:00
FUJIWARA Katsunori
92ff577d38 revset: use "canonpath()" for "filelog()" pattern without explicit kind
Before this patch, revset predicate "filelog()" uses "match.files()"
to get filename also for the pattern without explicit kind.

But in such case, only canonicalization of relative path is required,
and other initializations of "match" object including regexp
compilation are meaningless.

This patch uses "pathutil.canonpath()" directly for "filelog()"
pattern without explicit kind like "glob:", for efficiency.

This patch also does below as a part of introducing "canonpath()":

  - move location of "matchmod.match()" invocation, because "m" is no
    more used in "if not matchmod.patkind(pat)" code path

  - omit passing "default" argument to "matchmod.match()", because
    "pat" should have explicit kind of pattern in this code path
2014-01-17 23:55:03 +09:00
FUJIWARA Katsunori
4d5d9b1517 revset: avoid loop for "match.files()" having always one element for efficiency
This patch avoids the loop for "match.files()" having always one
element in revset predicate "filelog()" for efficiency: "match" object
"m" is constructed with "[pat]" as "patterns" argument.
2014-01-17 23:42:12 +09:00
FUJIWARA Katsunori
7e4fbdb87b revset: make default kind of pattern for "contains()" rooted at cwd
Before this patch, default kind of pattern for revset predicate
"contains()" is treated as the exact file path rooted at the root of
the repository. This decreases usability, because:

  - all other predicates taking pattern argument (also "filelog()")
    treat such pattern as the path rooted at the current working
    directory

  - "contains()" doesn't describe this difference in its help

  - this difference may confuse users

    for example, this prevents revset aliases from sharing same
    argument between "contains()" and other predicates


This patch makes default kind of pattern for revset predicate
"contains()" be rooted at the current working directory.

This patch uses "pathutil.canonpath()" instead of creating "match"
object for efficiency.
2014-01-17 23:42:12 +09:00
FUJIWARA Katsunori
43338be810 revset: narrow scope of the variable referred only in specific code path
This patch narrows scope of the variable "m" in the function for
revset predicate "contains()", because it is referred only in "else"
code path of "if not matchmod.patkind(pat)" examination.
2014-01-17 23:42:12 +09:00
Sean Farley
673b0dd879 commands: use bookmarks.validdest instead of duplicating logic
Now that bookmarks.py has grown a validdest method that even handles successor
changesets, we use that instead of duplicating the logic in commands.py
2014-01-15 17:55:13 -06:00
Sean Farley
8973f827ab update: consider successor changesets when moving active bookmark
Previously, when an obsolete changeset was bookmarked, successor changesets were not considered
when moving the bookmark forward. Now that a bare update will move to the tip most of the
successor changesets, we also update the bookmark logic to allow the bookmark to move with this
update.

Tests have been updated and keep issue4015 covered as well.
2014-01-15 17:48:48 -06:00
Sean Farley
eb5399916a merge: consider successor changesets for a bare update
Previously, a bare update would ignore any successor changesets thus
potentially leaving you on an obsolete head. This happens commonly when there
is an old bookmark that hasn't been moved forward which is the motivating
reason for this patch series.

Now, we will check for successor changesets if two conditions hold: 1) we are
doing a bare update 2) *and* we are currently on an obsolete head.

If we are in this situation, then we calculate the branchtip of the successor
set and update to that changeset.

Tests coverage has been added.
2014-01-15 16:41:18 -06:00
Sean Farley
17f6cfcd6f merge: refactor initialization of variables in update
There is no code change here but this helps prepare for future commits that
will fix a bare update with obsolete markers.
2013-11-06 17:02:07 -06:00
Sean Farley
26332808a6 merge: update comment for future devs 2013-11-06 10:26:25 -06:00
Sean Farley
ef93a468a7 obsolete: clarify documentation for succcessorssets 2014-01-15 18:14:12 -06:00
Pierre-Yves David
605b367f84 backout: add a message after backout that need manual commit
In some case Backout silently succeeded to back out but left all the change
uncommitted. This may be confusing for user so this changeset  add a note
reminding to commit. Other backout case already actively informs the user about
created commit.
2014-01-08 17:23:26 -08:00
Pierre-Yves David
75c6a1c8fa backout: avoid update on simple case.
Before the changeset the backout process was:
1) go to <target>
2) revert to <target> parent
3) update back to changeset we came from

The two update steps can takes a very long time to move back and forth unrelated
file change between <target> and current working directory.

The new process is just merging current working directory with the parent of
<target> using <target> as ancestor. This give the very same result but skip
the two updates. On big repo with a lot of files and changes that save a lots of
time (x20 for one week window).

The "merge" version (hg backout --merge) is still done with upgrades. We could
imagine using in memory commit to speed it up but this is another fish.
2014-01-08 14:53:46 -08:00
FUJIWARA Katsunori
1629d4ee7f ui: add "extractchoices()" to share the logic to extract choices from prompt 2013-12-02 00:50:29 +09:00
Pierre-Yves David
f0e0234ea1 branchmap: use set for update code
We are doing membership test and substraction. new code is marginally faster.
2014-01-06 15:19:31 -08:00
Pierre-Yves David
fc97641ca7 branchmap: simplify update code
We drop iterrevs which are not needed anymore. The know head are never a
descendant of the updated set. It was possible with the old strip code. This
simplification make the code easier to read an update.
2014-01-06 14:26:49 -08:00
Pierre-Yves David
7641136888 branchmap: stop useless rev -> node -> rev round trip
We never use the node of new revisions unless in the very specific case of
closed heads. So we can just use the revision number.

So give another handfull of percent speedup.
2014-01-03 16:44:23 -08:00
Pierre-Yves David
4a3c0bd301 branchmap: stop membership test in update logic
Now that no user try to update the cache on a truncated repo we can drop the
extra lookup. Give an handfull percent speedup on big branchmap update.
2013-01-15 20:04:12 +01:00
Pierre-Yves David
f4aa184d64 branchmap: remove silly line break
The line fit in 80 character limit without it. It is even shorter without it.
2014-01-03 17:06:07 -08:00
Takumi IINO
22fc622e5e hgweb: infinite scroll support for coal style 2014-01-08 00:47:45 +09:00
Takumi IINO
95ecbefdae hgweb: infinite scroll support for monoblue style 2014-01-08 00:47:44 +09:00
Takumi IINO
e51fef56f2 hgweb: infinite scroll support for gitweb style 2014-01-08 00:47:43 +09:00
Takumi IINO
db72b3b5e8 hgweb: avoid invalid infinity scroll request when overwritten web.style
Infinity scroll is broken when you override the web.style in the following ways:

    $ hg --config='web.style=gitweb' serve
    $ open http://localhost:8080/shortlog?style=paper

ajaxScrollInit should use http://localhost:8080/shortlog/%next%?style=paper.
however, http://localhost:8080/shortlog/%next% is used actually.
It is missing style parameter.

This patch add style parameter to request url.
2014-01-08 00:35:03 +09:00
Takumi IINO
96e1c44734 hgweb: fix regexp for other styles like monoblue
Some styles have indentation.
2014-01-08 00:26:55 +09:00
Mads Kiilerich
1428b73c06 help: branch names primarily denote the tipmost unclosed branch head
Was the behavior correct and the description wrong so it should be updated as
in this patch? Or should the code work as the documentation says?

Both ways could make some sense ... but none of them are obvious in all cases.

One place where it currently cause problems is when the current revision has
another branch head that is closer to tip but closed. 'hg rebase' refuses to
rebase to that as it only see the tip-most unclosed branch head which is the
current revision.

/me kind of likes named branches, but no so much how branch closing works ...
2013-11-21 15:17:18 -05:00
Mads Kiilerich
771c21f193 util: introduce util.debugstacktrace for showing a stack trace without crashing
This is often very handy when hacking/debugging.

Calling util.debugstacktrace('hey') from a place in hg will give something like:
  hey at:
   ./hg:38                                     in <module>
   /home/user/hgsrc/mercurial/dispatch.py:28   in run
   /home/user/hgsrc/mercurial/dispatch.py:65   in dispatch
   /home/user/hgsrc/mercurial/dispatch.py:88   in _runcatch
   /home/user/hgsrc/mercurial/dispatch.py:740  in _dispatch
   /home/user/hgsrc/mercurial/dispatch.py:514  in runcommand
   /home/user/hgsrc/mercurial/dispatch.py:830  in _runcommand
   /home/user/hgsrc/mercurial/dispatch.py:801  in checkargs
   /home/user/hgsrc/mercurial/dispatch.py:737  in <lambda>
   /home/user/hgsrc/mercurial/util.py:472      in check
...
2014-01-12 23:28:21 +01:00
Mads Kiilerich
9f5571e9f8 bisect: --command without --noupdate should flag the parent rev it tested
b33db384a66e not only introduced the 'bisect(current)' revset predicate, it
also changed how the 'current' revision is used in combination with --command.
The new behaviour might be ok for --noupdate where the working directory and
its revision shouldn't be used, but it also did that when --command is used to
run a command on the currently checked out revision then it could register the
test result on the wrong revision.

An example:

Before, bisect with --command could use the wrong revision when recording the
test result:

  $ hg up -qr 0
  $ hg bisect --command "python \"$TESTTMP/script.py\" and some parameters"
  changeset 31:58c80a7c8a40: bad
  abort: inconsistent state, 31:58c80a7c8a40 is good and bad

Now it works as before and as expected and uses the working directory revision
for the --command result:

  $ hg up -qr 0
  $ hg bisect --command "python \"$TESTTMP/script.py\" and some parameters"
  changeset 0:b99c7b9c8e11: bad
  ...
2013-11-16 15:46:29 -05:00
Mads Kiilerich
48b69add79 context: drop caching 'copies' method
The 'copies' method has no test coverage and calls copies.pathcopies with an
incorrect number of parameters and is thus (fortunately) not used. Kill it.
2013-11-16 15:46:29 -05:00
Siddharth Agarwal
c88be819e2 commands.bookmarks: move hexfn to inside list block
This isn't used outside this block, nor is it expected to be.
2013-11-19 12:43:29 -08:00
Siddharth Agarwal
cc6a9ec3f3 commands.bookmarks: move cur initialization to inside wlock
This is more correct because we now fetch '.' while nothing else can interfere
with it.
2013-11-19 12:42:17 -08:00
Siddharth Agarwal
6504db9dff commands.bookmarks: pass cur in explicitly to checkconflict
cur will be moved inside the wlock in a future patch, so we need to pass it
into checkconflict explicitly.
2013-11-21 17:11:04 -08:00
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