Commit Graph

247 Commits

Author SHA1 Message Date
Henrik Stuart
c1e6537e5f strip: make repair.strip transactional to avoid repository corruption
Uses a transaction instance from the local repository to journal the
truncation of revlog files, such that if a strip only partially completes,
hg recover will be able to finish the truncate of all the files.

The potential unbundling of changes that have been backed up to be restored
later will, in case of an error, have to be unbundled manually. The
difference is that it will be possible to recover the repository state so
the unbundle can actually succeed.
2009-04-16 15:34:03 +02:00
Benoit Boissinot
309c0e0a31 merge with -stable 2009-04-06 20:11:00 +02:00
Benoit Boissinot
e5ea532970 raise RevlogError when parser can't parse the revlog index
Initial patch and test thanks to Nicolas Dumazet.
2009-04-06 19:48:11 +02:00
Nicolas Dumazet
3ced073c3b revlog: faster hash computation when one of the parent node is null
Because we often compute sha1(nullid), it's interesting to copy a precomputed
hash of nullid instead of computing everytime the same hash. Similarly, when
one of the parents is null, we can avoid a < comparison (sort).

Overall, this change adds a string equality comparison on each hash() call,
but when p2 is null, we drop one string < comparison, and copy a hash instead
of computing it. Since it is common to have revisions with only one parent,
this change makes hash() 25% faster when cloning a big repository.
2009-03-23 15:32:29 +01:00
Peter Arrenbrecht
a2d3e23eef cleanup: drop variables for unused return values
They are unnecessary. I did leave them in localrepo.py where there is
something like:

  _junk = foo()
  _junk = None

to free memory early. I don't know if just `foo()` will free the return
value as early.
2009-03-23 13:13:02 +01:00
Peter Arrenbrecht
bc21361ed2 cleanup: drop unused imports 2009-03-23 13:12:07 +01:00
Matt Mackall
d15d559b7c errors: move revlog errors
- create error.py for exception classes to reduce demandloading
- move revlog exceptions to it
- change users to import error and drop revlog import if possible
2009-01-11 22:48:28 -06:00
Matt Mackall
4bb1cd5f2b lookup: speed up partial lookup 2008-11-12 19:11:34 -06:00
Matt Mackall
4205fad04a revlog: speed up parents() 2008-11-12 15:58:46 -06:00
Matt Mackall
0770924171 revlog: remove delta function 2008-11-12 15:32:16 -06:00
Matt Mackall
b2807810c6 linkrev: take a revision number rather than a hash 2008-11-12 15:19:14 -06:00
Benoit Boissinot
4f2e35bc33 fix pull racing with push/commit (issue1320)
changegroup() has a problem when nodes which does not descend from a node
in <bases> are added to remote after the discovery phase.
If that happens, changegroup() won't send the correct set of nodes, ie.
some nodes will be missing.
To correct it we have to find the set of nodes that both remote and self
have (called <common>), and send all the nodes not in <common>.

This fix has some overhead, in the worst case it will re-send a whole branch.

A proper fix to avoid this overhead might be to change the protocol so that
the <common> nodes are sent (instead of the <bases> of the missing nodes).
2008-10-21 17:00:35 +02:00
Bernhard Leiner
b7e7ab32c3 use the new parseindex implementation C in parsers 2008-10-17 00:24:22 +02:00
Matt Mackall
a1af556eb5 revlog: fix heads performance regression 2008-10-12 15:21:08 -05:00
Sune Foldager
9b5eac039b provide nicer feedback when an unknown node id is passed to a command
Previously, an unknown node id would lead to the following error:
abort: 00changelog.i@343445453433: no node!

All other unknown revision would instead display as:
abort: unknown revision '343445453'!

The former error message has been suppressed in favor of the latter.
2008-10-04 10:14:39 +02:00
Martin Geisler
559197e59b Fixed docstring typos 2008-08-12 13:45:48 +02:00
Adrian Buehlmann
c330a45cd1 revlog: add files method 2008-08-13 20:18:41 -05:00
Stefano Tortarolo
5388b1792f Add ancestors and descendants to revlog
This patch adds two methods to revlog:
- ancestors: given a list of revisions returns their ancestors
- descendants: given a list of revisions return their descendants
2008-07-19 18:19:50 +02:00
Matt Mackall
bc715be859 add __len__ and __iter__ methods to repo and revlog 2008-06-26 14:35:50 -05:00
Alexander Solovyov
6a1b628db8 LookupError should have same __str__ as RevlogError 2008-06-18 16:47:47 +03:00
Alexander Solovyov
1088d84e91 make revlog.LookupError inherit from KeyError
This will improve integration with external applications which depend on
KeyError, which is usually raised by __getitem__ calls.
2008-06-18 12:48:04 +02:00
Peter Arrenbrecht
892bff8c6e drop superfluous param from revlog.addgroup() 2008-06-05 16:25:11 +02:00
Dirkjan Ochtman
34d6bea8db python 2.6 compatibility: compatibility wrappers for hash functions 2008-04-04 22:36:40 +02:00
Alexis S. L. Carvalho
e8bdcfb352 revlog.py: remove extra close()
atomictempfile.rename() already calls close().
2008-03-14 20:01:50 -03:00
Benoit Boissinot
8aa28e9a96 revlog: make sure the files are closed after an exception happens
This prevents a corruption when the writes happen after the truncate
initiated by the transaction rollback.
2008-03-14 22:12:50 +01:00
Matt Mackall
865487e7f2 revlog: report node and file when lookup fails 2008-03-11 17:42:29 -05:00
Joel Rosdahl
4f8012378a Remove unused imports 2008-03-06 22:23:41 +01:00
Joel Rosdahl
5dae3059a0 Expand import * to allow Pyflakes to find problems 2008-03-06 22:23:26 +01:00
Alexis S. L. Carvalho
bda2fe75b5 revlog.revision: avoid opening the datafile without need.
If there's no inline data, revlog.revision opens the data file every
time it's called.  This is useful if we're going to call chunk many
times, but, if we're going to call it only once, it's better to let
chunk open the file - if we're lucky, all the data we're going to need
is already cached and we won't need to even look at the file.
2008-02-19 19:20:10 -03:00
Alexis S. L. Carvalho
ba985d288a simplify revlog.strip interface and callers; add docstring
Also, strip files only after the changelog and the manifest.
2008-01-19 18:01:16 -02:00
Alexis S. L. Carvalho
8b35462ec9 strip: calculate list of extra nodes to save and pass it to changegroupsubset
When we remove revision N from the repository, all revisions >= N are
affected: either it's a descendant from N and will also be removed, or
it's not a descendant of N and will be renumbered.

As a consequence, we have to (at least temporarily) remove all filelog
and manifest revisions that have a linkrev >= N, readding some of them
later.

Unfortunately, it's possible to have a revlog with two revisions
r1 and r2 such that r1 < r2, but linkrev(r1) > linkrev(r2).  If we try
to strip revision linkrev(r1) from the repository, we'll also lose
revision r2 when we truncate this revlog.

We already use changegroupsubset to create a temporary changegroup
containing the revisions that have to be restored, but that function is
unable to detect that we also wanted to save the r2 in the case above.

So we manually calculate these extra nodes and pass it to changegroupsubset.

This should fix issue764.
2008-01-19 18:01:16 -02:00
Matt Mackall
ebf85d18e1 util: get rid of is_win_9x wart 2007-12-18 14:01:42 -06:00
Bryan O'Sullivan
d32d6fb57f make LookupError more detailed 2007-11-28 08:36:55 -08:00
Matt Mackall
93267d50c5 revlog: make revlogv0 loading more robust against corruption 2007-11-24 12:13:32 -06:00
Benoit Boissinot
0442ace6c2 fix UnboundLocalError, refactor a bit
bin wasn't defined in all branches (bug introduced in 959d401a1954
2007-10-11 12:16:55 +02:00
Matt Mackall
81a40fb9b2 revlog: break up compression of large deltas
Python's zlib apparently makes an internal copy of strings passed to
compress(). To avoid this, compress strings 1M at a time, then join
them at the end if the result would be smaller than the original.

For initial commits of large but compressible files, this cuts peak
memory usage nearly in half.
2007-10-11 00:46:54 -05:00
Matt Mackall
0804290ab7 revlog: fix caching of buffer objects 2007-10-11 00:46:53 -05:00
Matt Mackall
9d62709a2c revlog: avoid large yields in group()
Split large yields so that the downstream consumer (chunkbuffer) will avoid
some pain when reading ahead.
2007-10-11 00:46:51 -05:00
Matt Mackall
adbffbec3c revlog: reduce memory usage in addgroup
- use a buffer to extract the delta from a chunk
- avoid concatenating to a compressed delta
- use a buffer to directly extra full text from a trivial delta
- delete chunk and delta objects after use
2007-10-11 00:46:47 -05:00
Matt Mackall
305c1ae64c changegroup: avoid large copies
- handle chunk headers separately rather than prepending them to
  (potentially large) chunks
- break large chunks into 1M pieces for compression
- don't prepend file metadata onto (potentially large) file data
2007-10-03 17:17:28 -05:00
Matt Mackall
a92b40c2ed revlog: generate trivial deltas against null revision
To avoid extra memory usage and performance issues with large files,
generate a trivial delta header for deltas against the null revision
rather than calling the usual delta generator.

We append the delta header to meta rather than prepending it to data
to avoid a large allocate and copy.
2007-10-03 17:17:27 -05:00
Alexis S. L. Carvalho
07df6adfb5 revlog: fix revlogio.packentry corner case
We want to store version information about the revlog in the first
entry of its index.  The code in packentry was using some heuristics
to detect whether this was the first entry, but these heuristics could
fail in some cases (e.g. rev 0 was empty; rev 1 descends directly from
the nullid and is stored as a delta).

We now give the revision number to packentry to avoid heuristics.
2007-09-26 01:58:45 -03:00
Matt Mackall
1e7f28023a Merge with crew 2007-09-24 12:34:26 -05:00
Patrick Mezard
327e3eb360 revlog: fix inlined revision transaction extra data (issue 749) 2007-09-23 18:24:19 +02:00
Matt Mackall
ccc415d026 revlog: more robust for damaged indexes
- fix flag reporting
- make broken length reporting smarter
2007-09-21 17:14:39 -05:00
Matt Mackall
37cc19c8c5 revlog: localize some fastpath functions 2007-07-26 12:02:58 -05:00
Matt Mackall
eeb8f14a99 revlog: minor chunk speed-up 2007-07-26 12:02:58 -05:00
Matt Mackall
d106fa8150 revlog: minor revdiff reorganization 2007-07-26 12:02:58 -05:00
Matt Mackall
9429a0a390 revlog: move flag checking out of the offset fastpath 2007-07-26 12:02:58 -05:00
Matt Mackall
767bb11dd5 revlog: avoid some unnecessary seek/tell syscalls 2007-07-23 20:44:08 -05:00