Commit Graph

194 Commits

Author SHA1 Message Date
Gregory Szorc
5ca0f908bf py3: add __bool__ to every class defining __nonzero__
__nonzero__ was renamed to __bool__ in Python 3. This patch simply
aliases __bool__ to __nonzero__ for every class implementing
__nonzero__.
2017-03-13 12:40:14 -07:00
Jun Wu
4a76b6f405 obsolete: avoid using revset language to compute the obsolete revset
This is part of a refactoring that moves some phase query optimization from
revset.py to phases.py. See previous patches for the motivation.

Now we have APIs in phasecache to get the non-public set efficiently, let's
use it directly instead of going through the "not public()" revset language
in "obsolete()" computation.

This patch was meaured using:

  for i in 'public()' 'not public()' 'draft()' 'not draft()'; do
      hg perfrevset "$i"; hg perfrevset "$i" --hidden;
  done

and no noticeable (> 1%) performance difference was observed.
2017-02-18 00:55:20 -08:00
timeless
1634eaae85 obsolete: use single quotes in use warning 2016-09-20 23:48:19 +00:00
liscju
338add4253 obsolete: fix minor module documentation issues 2016-09-02 10:18:56 +02:00
liscju
c7ec9d159e i18n: translate abort messages
I found a few places where message given to abort is
not translated, I don't find any reason to not translate
them.
2016-06-14 11:53:55 +02:00
timeless
3d2ce9ca5a obsolete: fix grammar 2016-05-27 05:24:45 +00:00
Kostia Balytskyi
47727221bc obsstore: move delete function from obsstore class to repair module
Since one of the original patches was accepted already and people on the
mailing list still have suggestions as to how this should be improved, I'm
implementing those suggestions in the following patches (this and the ones that
might follow).
2016-04-12 04:06:50 -07:00
Kostia Balytskyi
ab0e2307c2 debugobsolete: style fixes to debugobsolete that slipped from original commit 2016-04-12 03:40:53 -07:00
Kostia Balytskyi
379ba461ec commands: allow debugobsolete to delete arbitrary obsmarkers
Sample usage is:
  '$ hg debugobsolete --delete 0 5'

This is a debug feature that will help people working on evolution and
obsolescense.
2016-04-01 15:12:50 -07:00
Durham Goode
196a302117 obsolete: fix n^2 marker computation behavior
Previously, if you ran obsolete.createmarkers with a bunch of markers that did
not have successors (like when you do a prune), it encountered a n^2 computation
behavior because the loop would read the changelog (to get ctx.parents()), then
add a marker, in a loop.  Adding a marker invalidated the computehidden cache,
and reading the changelog recomputed it.

This resulted in pruning 150 commits taking 150+ seconds in a large repo.

The fix is to break the reading part of the loop to be separate from the writing
part.
2016-02-04 15:38:04 -08:00
Laurent Charignon
b304274518 obsolete: make _computeobsoleteset much faster
This patch makes _computeobsoleteset much faster by looping
over the draft and secrets as opposed to looping over the
successors.
This works because "number of draft and secret" is typically
way smaller(<100) than the number of successor in the repo (~90k in
my checkout of core mercurial as of today). And also because
it is very fast to compute "not public()".

I timed the code with the following setup:
"""
from mercurial import hg, ui, obsolete
ui = ui.ui()
repo = hg.repository(ui, "~/hg")
l = repo.obsstore.successors # This caches the result
"""

With about 90k successors.

k=obsolete._computeobsoleteset(repo) before this patch:
10 loops, best of 3: 33.9 ms per loop

k=obsolete._computeobsoleteset(repo) after this patch:
10000 loops, best of 3: 83.3 µs per loop
2016-01-13 21:52:26 -08:00
Gregory Szorc
06ebc04a42 obsolete: use absolute_import 2015-12-12 13:30:47 -05:00
Pierre-Yves David
61d6614168 obsstore: make the readonly attribute accessible
We want to gracefully handle the read only case in some case (current target:
advisory obsmarkers parts in bundle2). So we expose the attribute in a clean
way.
2015-10-15 12:45:34 +01:00
Pierre-Yves David
30913031d4 error: get Abort from 'error' instead of 'util'
The home of 'Abort' is 'error' not 'util' however, a lot of code seems to be
confused about that and gives all the credit to 'util' instead of the
hardworking 'error'. In a spirit of equity, we break the cycle of injustice and
give back to 'error' the respect it deserves. And screw that 'util' poser.

For great justice.
2015-10-08 12:55:45 -07:00
Yuya Nishihara
6f9580fded obsstore: fast path to check if obsstore is empty 2015-09-13 18:01:01 +09:00
Yuya Nishihara
74171779ed obsstore: delay loading markers from obsstore file
This will allow us to use cached revisions without parsing obsstore.

Because _version isn't determined at __init__, the debugobsconvert command no
longer works correctly. I'll fix it by a separate patch for the evolve
extension.
2015-09-13 17:52:37 +09:00
Yuya Nishihara
38f9712584 obsstore: initialize _all markers without using _addmarkers()
The next patch will make _all variable propertycached to avoid costly parsing
of obsstore. This means we can't call _addmarkers() to initialize _all.

Because all cached markers depend on _all, it isn't necessary to update these
caches when _all is initially loaded.
2015-09-13 17:47:18 +09:00
Yuya Nishihara
7761cb387f obsolete: remove unused _knownrevs function
The call site was removed at 17733696f80a.
2015-09-13 22:34:58 +09:00
Pierre-Yves David
c27b91f154 obsolete: clarify that 'successorssets' returns the latest successors
We do not return the first successors we found, we returns the latest (non
obsolete  (mostly)) one following the obsolete link transitively. We update the
documentation to make this clean.
2015-09-15 13:12:03 -07:00
Pierre-Yves David
f317af09f6 obsolete: drop an empty line at the end of a docstring
This empty line is useless, let's drop it.
2015-09-15 13:10:25 -07:00
timeless@mozdev.org
ea67eda4f0 obsolete: improve English of successorssets 2015-09-08 20:44:18 -04:00
Siddharth Agarwal
a5b449ed2e obsolete: replace references to 'sopener' with 'svfs' 2015-06-25 22:19:49 -07:00
Jordi Gutiérrez Hermoso
a6105df67a phases: add hg help phases hint to failures to edit public commits
There were a couple of locations that were missing this hint after an
edition of some kind failed due to the public phase.
2015-06-01 14:16:52 -04:00
Jordi Gutiérrez Hermoso
3ed01018a3 phases: rewrite "immutable changeset" to "public changeset"
The phrase "cannot edit immutable changeset" is kind of tautological.
Of course unchangeable things can't be changed. We instead mention
"public" and provide a hint so that we can point to the actual
problem. Even in cases where some operation other than edition cannot
be performed, "public" gives the root cause that results in the
"immutable" effect.

There is a precedent for saying "public" instead of "immutable", for
example, in `hg commit --amend`.
2015-06-01 18:05:38 +00:00
Pierre-Yves David
c34d269931 util: drop the 'unpacker' helper
It is not helping anything anymore.
2015-05-18 23:43:36 -05:00
Augie Fackler
a5b17bd9d1 cleanup: use __builtins__.any instead of util.any
any() is available in all Python versions we support now.
2015-05-16 14:30:07 -04:00
Pierre-Yves David
96cf5ab0aa obsolete: sort obsmarkers during exchange
Because bundle2 allows a more precise exchange of obsmarkers during pull, it
sends them in a different order (previously unstable because of sets.)  As
a result, they are added to the repository in a different order. To stabilize
the order and ensure tests are unchanged when moving from bundle1 to bundle2 we
sort markers when exchanging them.

In the long run, the obsstore will probably not use a linear storage.
2015-05-10 06:48:08 -07:00
Laurent Charignon
22af9eef3f obsolete: speed up unstable computation
Speed up the computation of the unstable revset by using the not public()
revset. In another series of patches, we optimize the not public() revset and
together it leads to a 50-100x speedup on the computation of unstable() for
our big repos.
2015-04-28 16:51:23 -07:00
Laurent Charignon
9044778c8c obsolete: speed up computation of bumped revset
Speed up the computation of the bumped revset by using the not public() revset.
In another patch series, we optimized the not public() revset. Together,
this cuts the cost of the computation of bumped() from 17% of the total time of
smartlog on our big repo to under 0.1% of the total time.
2015-04-24 14:46:30 -07:00
Pierre-Yves David
bbf64d6a4d obsolete: avoid infinite loop from obs-cycle in divergence (issue4126)
As for other currently in place cycle detection, arbitrarily cut the first
obsolescence link that create a cycle avoiding the infinite loop. This will have
to be made more deterministic in the future but we do not really care right now.
2015-03-19 13:00:44 -07:00
Matt Harbison
73a96f7b7b obsolete: replace 'ctx._repo' with 'ctx.repo()' 2015-03-12 23:05:25 -04:00
Matt Harbison
9e0bfd2ea2 obsolete: drop the explicit seek to EOF after append mode open()
posixfile now handles this.
2015-01-31 12:54:35 -05:00
Martin von Zweigbergk
5f8a09ad0c obsolete: populate successors, precursors, children lazily
The precursors and children dictionaries are not used by many
commands. By making them lazily populated,
'hg log -r @~10::@ >/dev/null' is sped up from 0.564s to 0.440s on my
hg.hg repo with 73k markers.

Also make successors lazily populated, mostly for consistency with the
others.
2015-02-04 22:25:35 -08:00
Martin von Zweigbergk
bf0b56486b obsolete: pass only new markers to _checkinvalidmarkers()
We will soon delay populating precursors until we have to. To prepare
for that, make _checkinvalidmarkers() scan for a nullid precursor in
the list of new markers instead of the (currently) cheaper 'if nullid
in precursors' check.
2015-02-04 22:40:48 -08:00
Martin von Zweigbergk
9680bb7217 obsolete: extract helpers from _load()
In preparation for making the successors, precursors, and children
dictionaries lazily populated, break up _load() into one function for
adding markers to each dictionary.
2015-01-20 22:01:37 -08:00
Martin von Zweigbergk
2601c25066 _fm1readmarkers: generate list in C
This moves perfloadmarkers from
! result: 63866
! wall 0.239217 comb 0.250000 user 0.240000 sys 0.010000 (best of 42)

to

! result: 63866
! wall 0.218795 comb 0.210000 user 0.210000 sys 0.000000 (best of 46)
2015-01-27 09:22:59 -05:00
Augie Fackler
7838bfda1b obsolete: use parsers.fm1readmarker if it exists for a ~38% perf win
This moves perfloadmarkers on my linux workstation (63494 markers from
mpm, crew, and myself) performance from
! wall 0.357657 comb 0.360000 user 0.350000 sys 0.010000 (best of 28)
to
! wall 0.222345 comb 0.220000 user 0.210000 sys 0.010000 (best of 41)
which is a pretty good improvement.

On my BSD machine, which is ancient and slow, before:
! wall 3.584964 comb 3.578125 user 3.539062 sys 0.039062 (best of 3)
after:
! wall 2.267974 comb 2.265625 user 2.195312 sys 0.070312 (best of 5)


I feel like we could do better by moving the whole generator function
into C, but I didn't want to tackle that right away.
2015-01-20 13:38:07 -05:00
Augie Fackler
a4620354b4 obsolete: make optional offset parameter to fm*readmarkers required
It was always passed by the only callsite, so just make it required.
2015-01-20 09:38:22 -05:00
Pierre-Yves David
35033dc470 obsstore: make the invalid markers check wrap-able
Some evolve user ignored the invalid markers for about two years and still have
some of them in some repository. This lead to plain abort whenever mercurial try
to open such repo. We need reinstall some way to clean this up in the evolve
extension. For this purpose, we need the checker code wrap-able independently.

This is scheduled for stable as this issue is blocking some evolve user.
2015-01-30 18:49:33 +00:00
Matt Mackall
efd707b6d7 readmarkers: add a SHA256 fixme note 2015-01-11 16:46:13 -06:00
Matt Mackall
1b1c572cac readmarkers: fast-path single successors and parents
This gives about a 5% performance bump.
2015-01-11 16:37:57 -06:00
Matt Mackall
aaefce821d readmarkers: promote global constants to locals for performance 2015-01-11 15:35:09 -06:00
Matt Mackall
5a2d46743d readmarkers: drop a temporary 2015-01-11 14:52:57 -06:00
Matt Mackall
f70b8899f1 readmarkers: read node reading into node length conditional
This removes some conditional assignments
2015-01-11 14:51:49 -06:00
Matt Mackall
fd24385ccc readmarkers: drop a temporary
Two other temporaries are renamed to fit line-length.
2015-01-11 14:46:55 -06:00
Matt Mackall
54920da7a8 readmarkers: hoist subtraction out of loop comparison 2015-01-11 14:44:57 -06:00
Matt Mackall
ccb9e25cca readmarkers: streamline offset tracking
This minimizes the number of assignments and operations needed to use offsets.
2015-01-11 14:43:31 -06:00
Matt Mackall
4cb9887cb8 readmarkers: use unpacker for fixed header 2015-01-11 14:37:50 -06:00
Matt Mackall
66bb59fd8e readmarkers: drop metadata temporary 2015-01-11 14:35:03 -06:00
Matt Mackall
eeecc7d717 readmarkers: drop date temporary 2015-01-11 14:33:49 -06:00