Commit Graph

226 Commits

Author SHA1 Message Date
Pierre-Yves David
675e8b857f obsutil: move 'getmarkers' to the new modules
We have a new 'obsutil' module now. We move the high level utility there to
bring 'obsolete.py' back to a more reasonable size.
2017-06-27 02:06:15 +02:00
Pierre-Yves David
cf50b9bfaf obsutil: move the 'marker' class to the new modules
We have a new 'obsutil' module now. We move high level utility there to bring
'obsolete.py' back to a more reasonable size.
2017-06-27 01:51:40 +02:00
Pierre-Yves David
1360d2c71c obsolete: delete three unused utility functions
None of this function has been used in the past 5 years, so I think it is safe
to just kill them. All code accessing rich markers is using 'getmarkers(...)'
instead (or raw markers).
2017-06-27 01:48:41 +02:00
Pierre-Yves David
ab57951fd7 obsutil: move 'foreground' to the new modules
We have a new 'obsutil' module now. We move the high level utility there to
bring 'obsolete.py' back to a more reasonable size.
2017-06-27 01:40:34 +02:00
Pierre-Yves David
719387c7c7 obsutil: move 'allsuccessors' to the new modules
We have a new 'obsutil' module now. We move the high level utility there to bring
'obsolete.py' back to a more reasonable size.
2017-06-27 01:36:20 +02:00
Pierre-Yves David
2f0989dab7 obsutil: move 'allprecursors' to the new modules
We have a new 'obsutil' module now. We move the high level utility there to
bring 'obsolete.py' back to a more reasonable size.
2017-06-27 01:31:18 +02:00
Pierre-Yves David
8b519349e8 obsutil: move 'exclusivemarkers' to the new modules
We have a new 'obsutil' module now. We move the high level utility there to
bring 'obsolete.py' back to a more reasonable size.
2017-06-27 01:11:56 +02:00
Pierre-Yves David
04205af86b obsutil: move 'successorssets' to the new modules
We have a new 'obsutil' module now. We move this high level utility there to bring
'obsolete.py' back to a more reasonable size.
2017-06-27 01:03:01 +02:00
Pierre-Yves David
3e0bfc6abf obsolete: skip 'changectx' usage in unstable computation
We simplify the unstable computation code, skipping the expensive creation of
changectx object. We focus on efficient set operation and revnumber centric
functions.

In my mercurial development repository, this provides a 3x speedup to the
function:

  before: 5.319 ms
  after:  1.844 ms

repo details:

  total changesets:       40886
  obsolete changesets:     7756
  mutable (not obsolete):   293
  unstable:                  30
2017-06-19 01:08:11 +02:00
Pierre-Yves David
be7de168fe obsolete: provide a small function to retrieve all mutable revisions
More obsolescence related algorithm focus on the mutable revision. We provide a
tiny utility function to make it easy to access this set.
2017-06-18 22:38:11 +02:00
Pierre-Yves David
f9505c66f4 obsolete: use ProgrammingError over assert for volatile set registration
We have ProgrammingError now.
2017-05-01 05:57:36 +02:00
Martin von Zweigbergk
46713842b3 pushkey: use False/True for return values from push functions
It was particularly unclear in phases.pushphase() whether the 0/1
returned were the 0/1 for public/draft phase or for False/True
2017-06-12 16:35:57 -07:00
Jun Wu
db8bfa3842 obsstore: do not load all markers to detect duplication
This will make duplication detection something like O(newmarkers) instead of
O(obsstore).
2017-06-02 20:49:42 -07:00
Gregory Szorc
943d55015e obsolete: move obsstore creation logic from localrepo
This code has more to do with obsolete.py than localrepo.py. Let's
move it there.
2017-06-08 21:54:30 -07:00
Jun Wu
7dac9c0bba obsstore: move header encoding to a separate function
This patch moves encodeheader from encodemarkers. So markers and header
could be encoded separately.
2017-06-04 00:38:11 -07:00
Jun Wu
ed047705d9 obsstore: move _version to a propertycache
This makes sure _version is correct even if "_all" is not called.
2017-06-04 08:49:15 -07:00
Jun Wu
3835d8bd52 obsstore: separate marker parsing from obsstore reading
This allows us to get raw obsstore content without parsing any markers.
Reading obsstore is much cheaper than parsing markers.
2017-06-02 20:38:01 -07:00
Jun Wu
4c6d8665c7 obsstore: move marker version reading to a separate function
This allows us to read marker version without reading markers.
2017-06-02 19:34:56 -07:00
Jun Wu
d9a63e5be4 obsstore: minor optimization for the obsolete revset
Use local variables in a loop.
2017-06-02 19:32:27 -07:00
Pierre-Yves David
e928751835 exclusive-markers: update the dedicated test with list of exclusive markers
We now display data about the "exclusive markers" in the test dedicated to
relevant and exclusive markers computation and usage. Each output have been
carefully validated
2017-06-01 08:44:01 +02:00
Pierre-Yves David
66c1fb799c obsolete: add a function to compute "exclusive-markers" for a set of nodes
This set will be used to select the obsmarkers to be stripped alongside the
stripped changesets. See the function docstring for details.

More advanced testing is introduced in the next changesets to keep this one
simpler. That extra testing provides more example.
2017-05-20 15:02:30 +02:00
Pierre-Yves David
0b43826a5f obsolete: raise richer exception on unknown version
We raise a more precise subclass of Abort with details about the faulty
version.  This will be used to detect this case  and display some information
in debugbundle.
2017-05-25 16:50:23 +02:00
Pierre-Yves David
1a819b73cb obsolete: fix relevant-obsmarkers computation on pruned changeset
The markers pruning a node was not directly considered relevant for the pruned
node, only to its parents.

This went unnoticed during obsmarkers exchange because all
ancestors of the pruned node would be included in the computation.
This still affects obsmarkers exchange a bit since "inline" prune markers would
be ignored (see second test case). This went unnoticed, because in such case,
we always push another obsolescence markers for that node.

We add explicit tests covering this case.

(The set of relevant changeset is use in the obsmarkers discovery protocol used
in the evolve experimental extension, the impact will be handled on the
extension side).
2017-05-25 19:37:29 +02:00
Boris Feld
527b4d3011 devel: use default-date config field when creating obsmarkers
Also use the default-date when creating obsmarkers. Currently they are created
with the current date and without any option to force their value.

To test the feature, we remove some of the many 'glob' used to match obsmarker
date in the tests.
2017-05-19 12:08:47 +02:00
Augie Fackler
0e18802e22 merge with stable 2017-05-21 02:45:32 -04:00
Pierre-Yves David
8f0cd8c82a obsolete: invalidate "volatile" set cache after merging marker
Adding markers to the repository might affect the set of obsolete changesets. So we
most remove the "volatile" set who rely in that data. We add two missing
invalidations after merging markers. This was caught by code change in the evolve
extensions tests.

This issues highlight that the current way to do things is a bit fragile,
however we keep things simple for stable.
2017-05-17 15:39:37 +02:00
Yuya Nishihara
4563e16232 parsers: switch to policy importer
# no-check-commit
2016-08-13 12:23:56 +09:00
Pierre-Yves David
1d69629fff obsmarker: add an experimental flag controlling "operation" recording
It seems better to introduce the experiment behind a flag for now as there are
multiple concerns around the feature:

 * Storing operation increase the size of obsolescence markers significantly
   (+10-20%).

 * It performs poorly when exchanging markers (cannot combine command names,
   command name might be unknown remotely, etc)
2017-05-20 03:10:23 +02:00
Pierre-Yves David
457dd23894 obsolete: move the 'isenabled' function at the top of the file
That is a simple and important function so having it at the top next to the
related constant seems better.
2017-05-19 13:12:42 +02:00
Durham Goode
77dcefda06 obsolete: add operation metadata to rebase/amend/histedit obsmarkers
By recording what operation created the obsmarker, we can show very intuitive
messages to the user in various UIs. For instance, log output could have
messages like "Amended as XXX" to show why a commit is old and has an 'x' on it.

     @  ac28e3  durham
    /   First commit
   |
   | o  d4afe7 durham
   | |  Second commit
   | |
   | x  8e9a5d (Amended as ac28e3)  durham
   |/   First commit
   |
2017-05-09 16:29:31 -07:00
Gregory Szorc
d8b8a2301d obsolete: use 2 argument form of enumerate()
The 2 argument form of enumerate was added in Python 2.6. This
change effectively reverts 00a7214a4f0d.
2017-05-13 11:42:42 -07:00
Yuya Nishihara
ab046506ef base85: proxy through util module
I'm going to replace hgimporter with a simpler import function, so we can
access to pure/cext modules by name:

  # util.py
  base85 = policy.importmod('base85')  # select pure.base85 or cext.base85

  # cffi/base85.py
  from ..pure.base85 import *  # may re-export pure.base85 functions

This means we'll have to use policy.importmod() function in place of the
standard import statement, but we wouldn't want to write it every place where
C extension modules are used. So this patch makes util host base85 functions.
2017-04-26 21:56:47 +09:00
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