Commit Graph

118 Commits

Author SHA1 Message Date
Pierre-Yves David
556c3d9a5e obsolete: use the version argument in encodemarkers
Recent scientific studies show that assigning a variable have no effect on
a unrelated constant. We therefore use the variable where we intended to in the
first place.
2014-09-16 15:56:38 -07:00
Pierre-Yves David
7fe702d01c obsolete: gather all contents related to format version 0 in a single place
All contents includes documentation, constants, and functions, so we
gather all of those things into a single location. The diff is confusing
because it cannot understand what code is semantically moved around in this
grand migration.
2014-09-12 14:41:43 +02:00
Pierre-Yves David
5c32e2e043 obsolete: ensure that getrevs always return a set
When a set of revisions was empty, we were using an empty tuple. We now return an
empty frozenset to ensure the object could be used in an operation that requires a
set.
2014-09-23 12:21:38 -07:00
Pierre-Yves David
1873ea14ec obsolete: properly drop 'date' from metadata
Mistakes were made while resolving rebase conflicts in 92753bcc8aa2. This led to
'date' being preserved in metadata when reading markers from a binary stream.

As a result, some known markers were seen as "new" when pulling. I noticed it
because a no-op pulls from main added about 600 duplicated markers to my
obsstore (for each pull).

I do not believe we need to perform any specific action to actively
de-duplicates existing obsstore. After this fix, duplicated markers will no be
propagated and the few affected repositories can probably deal with duplication (or
people can repull the obsstore from a clone).

As a side effect, we decode metadata only once, reducing the impact of the hack
in fm0 to store extra important data (parents and date).
2014-09-10 14:42:52 +01:00
Pierre-Yves David
9c8ad08d12 obsolete: add a commonversion function
This function returns the highest common version between the locally known
formats and a list of remotely known formats. This is going to be useful to
know what format should be used for exchange.
2014-08-26 11:36:23 +02:00
Pierre-Yves David
fc6088afa7 obsmarker: record the number of new markers in the transaction
This lets hooks be notified about new markers in the repository.
2014-08-25 18:26:56 +02:00
Pierre-Yves David
d8f05095f7 obsolete: make encodemarkers a public function
We'll need access to it for bundle2.
2014-08-25 16:24:40 +02:00
Pierre-Yves David
460e985627 obsolete: move _encodemarkers next to _readmarkers 2014-08-25 16:21:33 +02:00
Pierre-Yves David
73e94f0411 obsstore: store and preserve ondisk version 2014-08-25 16:18:44 +02:00
Pierre-Yves David
150d8e5d5f obsolete: have _readmarkers return the format version
readmarkers is not returning the version of the format it read from. This will
let callers know about the format and allow them to preserve it.
2014-08-25 16:51:51 +02:00
Pierre-Yves David
2be245bb0d obsolete: support for any known obsstore format when reading or writing
We can now read and write any known format. The list of known formats
currently has one element (0). The obsstore itself is not aware of
multiple formats yet and always uses format 0.
2014-08-25 16:16:01 +02:00
Pierre-Yves David
e891429fca obsolete: move _fm0encodeonemarker next to _fm0readmarkers 2014-08-25 16:09:18 +02:00
Pierre-Yves David
59d5970fe3 obsolete: rename _encodeonemarker to _fm0encodeonemarkers
This function encodes markers in version 0 of the format.
2014-08-25 16:43:23 +02:00
Pierre-Yves David
30503ced28 obsolete: extract the part of _readmarkers specific to format version 0
If we are to introduce new formats we need to be able call different
functions for different formats. Creating a function for format
version 0 is the first step.
2014-08-25 14:58:11 +02:00
Pierre-Yves David
104efe6c90 obsolete: rename all _fm to _fm0
This change is because these formats are used for version 0 of the
obsstore format. This is going to be useful in the future when we
introduce new versions of the format.
2014-08-25 14:56:15 +02:00
Pierre-Yves David
7cf82e8c6d obsolete: rename _fnodesize to _fmfnodesize
All variables involved in the obsstore format are prefixed with `_fm`.
`_fnodesize` was the exception. It is now back in line.

This is meaningful as we'll need to distinguish between multiple versions of the
obsstore format.
2014-08-25 14:52:51 +02:00
Pierre-Yves David
1ea986ffcd obsstore: have the mergemarkers method return the number of new markers
The mergemarkers function now returns the number of unknown markers in
the stream that have been added to the obsstore. This is similar to what
`obsstore.add` already does.

The method gains a docstring in the process.
2014-08-21 17:42:50 -07:00
Gregory Szorc
3cffe8cb84 obsolete: avoid slow, generic date parsing
Simple profiling of `hg log -r .` revealed ~18,000 calls to
mercurial.i18n.gettext() on the author's repository. The
culprit was 3 _() calls in util.parsedate() multiplied by
~6000 obsmarkers originating from the parsing of obsmarkers.

Changing the obsmarker code to parse the stored format of
dates instead of going through a generic path eliminates these
gettext() lookups and makes `hg log -r .` execute ~10% faster
on the author's repo. The performance gain is proportional to
the number of obsmarkers.

The author attempted to patch util.parsedate() to avoid the
gettext() lookups. However, that code is whacky and the author
is jet lagged, so the approach was not attempted.
2014-08-29 18:00:44 +02:00
Pierre-Yves David
dfccc53b1c debugobsolete: add a --rev argument
This argument can be used to list markers relevant to a set of revisions. We
add a test for this option and the relevant computation in the same move.
2014-08-19 23:22:44 -07:00
Pierre-Yves David
e3efc0de1b obsolete: rename allmarkers to getmarkers
This function is going to gain a "nodes" argument to filter the markers to the
ones relevant to <nodes> only.
2014-08-20 18:11:23 -07:00
Pierre-Yves David
9b224dd694 obsstore: add relevantmarkers method
We add a ``relevantmarkers`` method to fetch all markers that seem relevant to a
set of nodes. See function documentation about how this set is computed. This
will let us exchange only the markers that seem "relevant" to the set of
changesets related to a push or a pull.

The approach used to define "relevant" has been successfully tested in evolve
for 6 months.
2014-08-19 17:03:10 -07:00
Pierre-Yves David
4bdfd3c696 obsstore: keep track of children information
We use the new `parents` field to build a dictionary of markers that touch
children of a node. This will be used to link prune markers to a set of
exchanged nodes.
2014-08-19 16:53:53 -07:00
Pierre-Yves David
72d4cdd2bd obsstore: drop outdated comment
This comment was associated with a now-defunct line.
2014-08-19 16:46:17 -07:00
Augie Fackler
1705b23c44 obsolete: avoid 2-argument form of enumerate, which was new in Python 2.6 2014-08-20 14:33:59 -04:00
Pierre-Yves David
d03cabd953 obsmarkers: add a parentnodes method to retrieve parent information 2014-08-18 17:14:27 -07:00
Pierre-Yves David
fd1f0f7321 obsstore: also store the 'parents' field on disk
We now store the `parents` field on disk. We use the same strategy as for
`date`: We stick it into the metadata. This is slow and dirty, but this is also
the only way we currently have.

At some point we'll have a new obsstore format to store this properly.
2014-08-18 16:28:44 -07:00
Pierre-Yves David
41733331bc obsstore: drop 'date' from the metadata dictionary
We are extracting the `date` information from the metadata at read time.
However, we failed to remove it from the metadata returned in the markers. This
is now fixed.
2014-08-18 17:06:08 -07:00
Pierre-Yves David
c584b9c277 createmarkers: automatically record the parent of pruned changesets
We need this information to build the set of relevant markers during
exchanges. This can only be done at the `createmarkers` level since
the `obsstore.create` function does not have a repo and therefore has
no access to the parent information.
2014-08-18 16:17:16 -07:00
Pierre-Yves David
767b2c8f0d obsstore: add a parents argument to obsstore.create
We need a way to pass the information to the function. Some guru told me that
what's arguments are made for.
2014-08-18 16:12:29 -07:00
Pierre-Yves David
95fa5b1577 obsstore: add a parents field
This field is intended to store the parent of the precursor. This is useful to
attach pruned changesets to a set of exchanged changesets. We currently just
add the fields with a None value. None stands for "no data recorded".
2014-08-18 16:08:44 -07:00
Pierre-Yves David
21ceed5f91 obsstore: add some documentation about the marker fields
As the number of fields grow, it makes sense to start documenting their contents.
2014-08-19 14:42:08 -07:00
Pierre-Yves David
3b78721608 obsmarker: add date as an explicit field
The markers are now 5-item tuples (concluded by the date). The obsstore.fields
contents have been updated accordingly.

There is no change to the on-disk format yet, so the date has to be extracted
every time we read binary markers and re-injected each team we write them. This
introduces a slowdown that will be solved when a new version of the format is
added. Such a slowdown was already introduced by the evolve extension anyway.
2014-08-19 10:01:06 -07:00
Pierre-Yves David
971ae35ea3 obsstore: add fields attribute to track each field in a marker
We are going to increase the amount of data explicitly stored in obsolescence
markers. This mean we are going to have a longer tuple and some values will be
shuffled around. So we add a ``fields`` attribute to the obsstore class to
keep track of what entry is what. This will be useful for extensions and for
documentation purpose.
2014-08-12 01:49:38 -07:00
Pierre-Yves David
f43f2ce984 obsolete: add a date argument to the createmarkers function
The function is now just passing the value to create markers.
2014-08-14 12:59:48 -07:00
Pierre-Yves David
a9a2652690 obsstore: add an explicit date argument to obsstore.create
The date will become an official field in the markers (and ultimately
in the on-disk format). We start by making it an official argument for
the function.
2014-08-13 22:44:47 -07:00
Pierre-Yves David
3b69b7e067 obsolete: explicitly pass metadata argument using keyword argument
We are about to add more arguments to this function (date, parents, etc).
Passing metadata as a keyword argument gives us more flexibility when adding
them.
2014-08-14 01:53:07 -07:00
Pierre-Yves David
b1789db911 obsmarker: add a flags method
We introduce a proper method to access the flag information.
2014-08-15 09:41:30 -07:00
Matt Mackall
92e0debc2b merge with stable 2014-08-15 11:48:05 -05:00
Mads Kiilerich
5d377a8588 cleanup: avoid local vars shadowing imports
This will mute some pyflakes "import ... shadowed by loop variable" warnings.
2014-08-15 16:20:47 +02:00
Pierre-Yves David
8bf8eb1b78 obsstore.create: add a simple safeguard against cyclic markers
We detect when there is a cycle in the marker itself (precursors being listed
as successors).
2014-08-14 14:59:42 -07:00
Martin Geisler
df032a1bc2 obsolete: fix one-element tuple in module docstring 2014-04-19 20:12:53 +02:00
Martin Geisler
010f4026c6 obsolete: let N denote number of obsoleted changestes in a marker
The number of obsoleted changesets is referred to as N later in the
docstring.
2014-04-19 19:53:46 +02:00
Martin Geisler
3b1788aa56 obsolete: fix language and grammar in module docstring 2014-04-19 19:52:09 +02:00
FUJIWARA Katsunori
87f58fc092 obsolete: add '%' specifier to the format string to avoid TypeError at runtime
Mapping operation on the format string not including any '%'
specifiers causes TypeError at runtime.
2014-04-16 03:05:00 +09:00
Mads Kiilerich
0e8795ccd6 spelling: fixes from spell checker 2014-04-13 19:01:00 +02:00
Pierre-Yves David
a61297246c obsolete: extract encoding of marker for pushkey from the list key function
We now have a function taking a list and marker and returning an encoded
version. This will allow obsolescence marker exchange experimentation to easily
pushkey-encode markers to be pushed after selection.
2014-02-27 20:01:28 -08:00
Pierre-Yves David
d8fd55e6c1 obsstore: add a __len__ method
We can already use "for mark in store:" it make sense to allow
"len(store)" too.
2014-02-25 10:32:54 -08:00
Pierre-Yves David
8ed33f95d4 obsstore: create method return True if a marker is actually added
The obsstore method now have a return value. This informs caller about the
actual creation of a new markers. No new markers are created if it would have
been a duplicate.
2014-02-25 10:21:54 -08:00
Mads Kiilerich
92dc407d90 comments: fix minor spelling issues found with spell checker 2014-02-20 02:39:01 +01: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