~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/revfile.py

  • Committer: Martin Pool
  • Date: 2005-06-15 04:24:01 UTC
  • Revision ID: mbp@sourcefrog.net-20050615042401-02a29d106bece661
add-bzr-to-baz allows multiple arguments

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
is that sequence numbers are stable references.  But not every
53
53
repository in the world will assign the same sequence numbers,
54
54
therefore the SHA-1 is the only universally unique reference.
55
 
 
56
 
This is meant to scale to hold 100,000 revisions of a single file, by
57
 
which time the index file will be ~4.8MB and a bit big to read
58
 
sequentially.
59
 
 
60
 
Some of the reserved fields could be used to implement a (semi?)
61
 
balanced tree indexed by SHA1 so we can much more efficiently find the
62
 
index associated with a particular hash.  For 100,000 revs we would be
63
 
able to find it in about 17 random reads, which is not too bad.
64
 
 
65
 
This performs pretty well except when trying to calculate deltas of
66
 
really large files.  For that the main thing would be to plug in
67
 
something faster than difflib, which is after all pure Python.
68
 
Another approach is to just store the gzipped full text of big files,
69
 
though perhaps that's too perverse?
70
 
 
71
55
The iter method here will generally read through the whole index file
72
56
in one go.  With readahead in the kernel and python/libc (typically
73
57
128kB) this means that there should be no seeks and often only one
121
105
class LimitHitException(Exception):
122
106
    pass
123
107
 
124
 
class Revfile:
 
108
class Revfile(object):
125
109
    def __init__(self, basename, mode):
126
110
        # TODO: Lock file  while open
127
111