Commit Graph

107 Commits

Author SHA1 Message Date
Yuya Nishihara
7941359b9d changelog: inline revlog.__contains__ in case it is used in hot loop
Currently __contains__ is called only by "rev()" revset, but "x in cl" is a
function that is likely to be used in hot loop. revlog.__contains__ is simple
enough to duplicate to changelog, so just inline it.
2015-04-04 22:30:59 +09:00
Yuya Nishihara
237120f282 revlog: add __contains__ for fast membership test
Because revlog implements __iter__, "rev in revlog" works but does silly O(n)
lookup unexpectedly. So it seems good to add fast version of __contains__.

This allows "rev in repo.changelog" in the next patch.
2015-02-04 21:25:57 +09:00
Pierre-Yves David
500808d844 changelog: register changelog.i.a as a temporary file
The file is registered to make sure the transaction is cleaned up in all cases.
2014-11-08 17:08:09 +00:00
Pierre-Yves David
29f854f61a transaction: pass the transaction to 'finalize' callback
The callback will likely need to perform some operation related to the
transaction (eg: registering file update). So we better pass the current
transaction as the callback argument. Otherwise callback that needs it has to
rely on horrible weak reference trick.

This allow already allow us to slay a wild weak reference usage.
2014-11-08 16:31:38 +00:00
Pierre-Yves David
92bf4dcbdc transaction: pass the transaction to 'pending' callback
The callback will likely need to perform some operation related to the
transaction (eg: backing files up). So we better pass the current transaction as
the callback argument. Otherwise callback that needs it has to rely on horrible
weak reference trick.

The first foreseen user of this is changelog._writepending. We would like it to
register the temporary file it create for cleanup purpose.
2014-11-08 16:27:50 +00:00
Pierre-Yves David
8803fc197d changelog: rely on transaction for finalization
Instead of calling 'cl.finalize()' by hand (possibly at a bogus time) we
register it in the transaction during 'delayupdate' and rely on 'tr.close()' to
call it at the right time.
2014-10-18 01:09:41 -07:00
Pierre-Yves David
d6b8860637 changelog: handle writepending in the transaction
The 'delayupdate' method now takes a transaction object and registers its
'_writepending' method for execution in 'transaction.writepending()'. The hook can then
use 'transaction.writepending()' directly.

At some point this will allow the addition of other file creation
during writepending.
2014-10-17 21:55:31 -07:00
Pierre-Yves David
71f171494e changelog: rework the delayupdate mechanism
The current way we use the 'delayupdate' mechanism is wrong. We call
'delayupdate' right after the transaction retrieval, then we call 'finalize'
right before calling 'tr.close()'. The 'finalize' call will -always- result in a
flush to disk, making the data available to all readers. But the 'tr.close()' may
be a no-op if the transaction is nested. This would result in data:

1) exposed to reader too early,
2) rolled back by other part of the transaction after such exposure

So we need to end up in a situation where we call 'finalize' a single time when
the transaction actually closes. For this purpose we need to be able to call
'delayupdate' and '_writepending' multiple times and 'finalize' once. This was
not possible with the previous state of the code.

This changeset refactors the code to makes this possible. We buffer data in memory
as much as possible and fall-back to writing to a ".a" file after the first call
to '_writepending'.
2014-10-18 01:12:18 -07:00
Mads Kiilerich
9a3561b211 changelog: use headrevsfiltered
5d1adb6683fa introduced use of the new filtering headrevs C implementation. It
caught TypeError to detect when to fall back to the implementation that was
compatible with old extensions. That method was however not reliable.

Instead, use the new headrevsfiltered function when passing a filter. It will
reliably fail with AttributeError when an old extension that predates
headrevsfiltered is used.
2014-10-26 12:14:12 +01:00
Pierre-Yves David
37d7d2958f repoview: add a FilteredLookupError class
This exception is a more precise LookupError that will allow us to
issue a special message when we end up accessing a filtered revision.
2014-10-16 02:05:06 -07:00
Pierre-Yves David
ea3e835124 repoview: add a FilteredIndexError class
This exception is a more precise IndexError that will allow us to
issue a special message when we end up accessing a filtered revision.
2014-10-15 17:02:44 -07:00
Durham Goode
1b59b1e4c0 obsolete: use C code for headrevs calculation
Previously, if there were filtered revs the repository could not use the C fast
path for computing the head revs in the changelog. This slowed down many
operations in large repositories.

This adds the ability to filter revs to the C fast path. This speeds up histedit
on repositories with filtered revs by 30% (13s to 9s). This could be improved
further by sorting the filtered revs and walking the sorted list while we walk
the changelog, but even this initial version that just calls __contains__ is
still massively faster.

The new C api is compatible for both new and old python clients, and the new
python client can call both new and old C apis.
2014-09-16 16:03:21 -07:00
Pierre-Yves David
0203860e23 changelog: ensure changelog._delaybuf is initialized
The ``localrepo.writepending`` method is using the ``changelog._delaybuff``
attribute to know if it has anything to do. However the ``changelog._delaybuff``
is never initialised at ``__init__`` time. This can lead to crash when using
bundle2 for part that never touch the changelog.

We simply initialize it to its base value. This is scheduled for stable as it
both trivial and blocking for experimenting with bundle2.
2014-05-20 13:55:08 -07:00
Brodie Rao
a446720e09 branchmap: cache open/closed branch head information
This lets us determine the open/closed state of a branch without
reading from the changelog (which can be costly over NFS and/or with
many branches).
2013-09-16 01:08:29 -07:00
FUJIWARA Katsunori
61a538d89f changelog: use "vfs.fstat()" instead of "util.fstat()"
Just invoking "os.fstat()" with "file.fileno()" doesn't require non
ANSI file API, because filename is not used for invocation of
"os.fstat()".

But "util.fstat()" should invoke "os.stat()" with "fp.name", if file
object doesn't have "fileno()" method for portability, and "fp.name"
may cause invocation of non ANSI file API.

So, this patch makes the constructor of appender class invoke
"util.fstat()" via vfs, to encapsulate filename handling.
2013-10-15 00:51:04 +09:00
FUJIWARA Katsunori
6d7cc2f5e0 changelog: use "vfs.rename()" instead of "util.rename()" 2013-10-15 00:51:04 +09:00
Augie Fackler
f03df466e2 changelog: hexlify node when throwing a LookupError on a filtered node
The non-hexlified node was leaking all the way out to the web
interface, and wasn't consistent with the behavior for nonexistent
nodes.
2013-02-09 06:07:32 -06:00
Mads Kiilerich
c506eac122 tests: fix doctest stability over Python versions
pprint ain't pretty in Python 2.4:
Changed in version 2.5: Dictionaries are sorted by key before the display is
computed; before 2.5, a dictionary was sorted only if its display required more
than one line, although that wasn’t documented.

Fixes issue introduced in 06396987f8e8.
2013-01-15 18:42:04 +01:00
Mads Kiilerich
403c97887d tests: stabilize doctest output
Avoid dependencies to dict iteration order.
2013-01-15 02:59:14 +01:00
Mads Kiilerich
d8671137d4 changelog: please check-code and remove tabs
Tabs were introduced in 972c32f23691.
2013-01-12 16:04:29 +01:00
Pierre-Yves David
a99d835522 changelog: add a branch method, bypassing changectx
The only way to access the branch of a changeset is currently to
create a changectx object and access its `branch()` method. Creating
a new Python object is costly and has a huge impact on code doing
heavy access to `branch()` (like branchmap).

This change introduces a new method on changelog that allows direct
access to the branch of a revision. See the next changeset for impact.
2013-01-10 00:41:40 +01:00
Pierre-Yves David
842d7e9f52 clfilter: use empty frozenset intead of empty tuple
This will allows set operation needed for cache collaboration.
2013-01-02 01:40:06 +01:00
Durham Goode
cce0517fb6 commit: increase perf by avoiding unnecessary filteredrevs check
When commiting to a repo with lots of history (>400000 changesets)
the filteredrevs check (added with 373606589de5) in changelog.py
takes a bit of time even if the filteredrevs set is empty. Skipping
the check in that case shaves 0.36 seconds off a 2.14 second commit.
A 17% gain.
2012-11-16 15:39:12 -08:00
Pierre-Yves David
83fc452dc5 changelog: extract description cleaning logic in a dedicated function
The amend logic have use for it.
2012-10-18 22:04:49 +02:00
Pierre-Yves David
7fb7b9e016 clfilter: introduce filteredrevs attribute on changelog
This changeset allows changelog object to be "filtered". You can assign a set of
revision numbers to the `changelog.filteredrevs` attributes. The changelog will
then pretends these revision does not exists in this repo.

A few methods need to be altered to achieve this behavior:

- tip
- __iter_
- irevs
- hasnode
- headrevs

For consistency and to help debugging, the following methods are altered too.
Tests tend to show it's not necessary to alter them but have them raise proper
exception helps to detect bad acces to filtered revisions.

- rev
- node
- linkrev
- parentrevs
- flags

The following methods would also need alteration for consistency purpose but
this is non-trivial and not done yet.

- nodemap
- strip

The C version of headrevs is not run if there is any revision to filter. It'll
need a proper rewrite later to restore performance.
2012-09-20 19:02:47 +02:00
Mads Kiilerich
2f4504e446 fix trivial spelling errors 2012-08-15 22:38:42 +02:00
Pierre-Yves David
edc2b520d9 hidden: move hiddenrevs set on the repository
This set is always accessed through the repo for now. Having this set
carried by the changelog make it complicated to:

- initialize it, computing hidden set may involve revset call
- lazy compute it, (1) only the changelog can detect someone access it,
                   (2) only the repo have enought knowledge to compute it.

In later version I expect he changelog to apply filtering itself and the set to
be carried by changelog again.
2012-07-16 17:44:46 +02:00
Bryan O'Sullivan
ab8ba40835 changelog: ensure that nodecache is valid (issue3428)
This ensures that an out-of-process hook can see an incoming changegroup.
2012-05-11 01:55:33 -07:00
Matt Mackall
59bf512648 changelog: micro-optimizations to changelog.read() 2012-03-18 18:19:16 -05:00
Matt Mackall
e6d872a339 changelog: handle decoding of NULs in extra more carefully (issue3156)
Escaped NULs adjacent to [0-7] could be decoded as octal. This hits
about 0.24% of changesets with transplant, which stores binary nodes.
2011-12-16 18:23:15 -06:00
Pierre-Yves David
7049209b6a hidden: Add a hiddenrevs attributes to changelog.
This attributes hold the set of all revisions that should be ommited by command
and tools displaying changesets.

This set is given as a hit. Command and tools are responsible to check it in
order to filter they outpur.

Code adding revisions to the set are responsible to the consistency of it's
data.
2011-06-16 01:57:53 +02:00
Martin Geisler
0eaeed4412 merge with stable 2011-05-19 18:10:03 +02:00
Martin Geisler
ff9aae8a76 changelog: convert user and desc from local encoding early
Failing to do so makes it impossible to use the memctx API to create a
changeset with a commit message or username outside of the current
encoding.encoding setting.
2011-05-19 18:09:25 +02:00
Sune Foldager
c222fc4662 changelog: don't use generaldelta 2011-05-16 13:06:48 +02:00
Zachary Gramana
6cc7816532 changelog: fixes leaked file handle 2011-05-05 11:33:02 -04:00
Idan Kamara
762d333ae9 eliminate various naked except clauses 2011-04-23 00:51:25 +03:00
Matt Mackall
dd8f91e931 Merge with stable 2010-02-11 17:44:01 -06:00
Wagner Bruna
a4d5546600 branch: avoid using reserved tag names
Reported as Debian bug #552423.
2010-02-11 12:02:48 -02:00
Matt Mackall
595d66f424 Update license to GPLv2+ 2010-01-19 22:20:08 -06:00
Benoit Boissinot
ce970b2d3e changelog: do not use a mutable default value 2009-10-31 16:49:27 +01:00
Matt Mackall
d8c1b12a59 changelog: move delayopener outside of class to eliminate reference cycle 2009-07-18 12:34:38 -05:00
Matt Mackall
58b70ccd45 changelog: swap opener to switch delay modes 2009-07-18 11:26:35 -05:00
Matt Mackall
853050477c changelog: factor out _delayname 2009-07-18 11:25:55 -05:00
Matt Mackall
bda87e75ac changelog: _delaycount -> _divert 2009-07-18 11:25:54 -05:00
Benoit Boissinot
125a85ec87 use new style classes 2009-06-10 15:10:21 +02:00
Matt Mackall
23a569538b changelog: make delayopener less intrusive 2009-05-27 14:44:55 -05:00
Matt Mackall
98aa07c578 commit: move description trimming into changelog 2009-05-18 17:36:24 -05:00
Martin Geisler
b43ec973e1 changelog: turn {de,en}code_extra methods into functions
The methods were not really methods -- they didn't use 'self'. Having
them as functions in the module it useful for other modules (like the
commitsigs extension) that want to recompute the changeset hash and
thus want to encode dicts the same way as changelog does it.

Removed the underbars from their names at the same time.
2009-05-15 01:21:24 +02:00
Martin Geisler
f138e91851 merge with crew-stable 2009-05-16 11:16:23 +02:00
Martin Geisler
fc8a97dac3 changelog: refuse to add revisions with empty usernames
An empty username or a username with a "\n" will make the revision
text contain two "\n\n" sequences -> corrupt repository.

The problem is that changelog.read expects to find exactly one "\n\n"
separator and thus cannot unpack the revision.
2009-05-16 11:12:49 +02:00