/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
198 by mbp at sourcefrog
- experimental compressed Revfile support
1
#! /usr/bin/env python
2
200 by mbp at sourcefrog
revfile: fix up __getitem__ to allow simple iteration
3
# (C) 2005 Canonical Ltd
198 by mbp at sourcefrog
- experimental compressed Revfile support
4
200 by mbp at sourcefrog
revfile: fix up __getitem__ to allow simple iteration
5
# based on an idea by Matt Mackall
198 by mbp at sourcefrog
- experimental compressed Revfile support
6
# modified to squish into bzr by Martin Pool
7
8
# This program is free software; you can redistribute it and/or modify
9
# it under the terms of the GNU General Public License as published by
10
# the Free Software Foundation; either version 2 of the License, or
11
# (at your option) any later version.
12
13
# This program is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
# GNU General Public License for more details.
17
18
# You should have received a copy of the GNU General Public License
19
# along with this program; if not, write to the Free Software
20
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21
22
23
"""Packed file revision storage.
24
25
A Revfile holds the text history of a particular source file, such
26
as Makefile.  It can represent a tree of text versions for that
27
file, allowing for microbranches within a single repository.
28
29
This is stored on disk as two files: an index file, and a data file.
30
The index file is short and always read completely into memory; the
31
data file is much longer and only the relevant bits of it,
32
identified by the index file, need to be read.
33
34
Each text version is identified by the SHA-1 of the full text of
35
that version.  It also has a sequence number within the file.
36
37
The index file has a short header and then a sequence of fixed-length
38
records:
39
40
* byte[20]    SHA-1 of text (as binary, not hex)
41
* uint32      sequence number this is based on, or -1 for full text
42
* uint32      flags: 1=zlib compressed
43
* uint32      offset in text file of start
44
* uint32      length of compressed delta in text file
45
* uint32[3]   reserved
46
47
total 48 bytes.
48
199 by mbp at sourcefrog
- use -1 for no_base in revfile
49
The header is also 48 bytes for tidyness and easy calculation.
198 by mbp at sourcefrog
- experimental compressed Revfile support
50
51
Both the index and the text are only ever appended to; a consequence
52
is that sequence numbers are stable references.  But not every
53
repository in the world will assign the same sequence numbers,
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
 
66
201 by mbp at sourcefrog
Revfile: - get full text from a record- fix creation of files if they don't exist- protect against half-assed storage
67
# TODO: Something like pread() would make this slightly simpler and
68
# perhaps more efficient.
69
219 by mbp at sourcefrog
todo
70
# TODO: Could also try to mmap things...  Might be faster for the
71
# index in particular?
72
73
# TODO: Some kind of faster lookup of SHAs?  The bad thing is that probably means
74
# rewriting existing records, which is not so nice.
201 by mbp at sourcefrog
Revfile: - get full text from a record- fix creation of files if they don't exist- protect against half-assed storage
75
198 by mbp at sourcefrog
- experimental compressed Revfile support
76
77
import sys, zlib, struct, mdiff, stat, os, sha
204 by mbp at sourcefrog
Revfile:- new find-sha command and implementation- new _check_index helper
78
from binascii import hexlify, unhexlify
198 by mbp at sourcefrog
- experimental compressed Revfile support
79
80
factor = 10
81
82
_RECORDSIZE = 48
83
84
_HEADER = "bzr revfile v1\n"
85
_HEADER = _HEADER + ('\xff' * (_RECORDSIZE - len(_HEADER)))
204 by mbp at sourcefrog
Revfile:- new find-sha command and implementation- new _check_index helper
86
_NO_RECORD = 0xFFFFFFFFL
198 by mbp at sourcefrog
- experimental compressed Revfile support
87
201 by mbp at sourcefrog
Revfile: - get full text from a record- fix creation of files if they don't exist- protect against half-assed storage
88
# fields in the index record
89
I_SHA = 0
90
I_BASE = 1
91
I_FLAGS = 2
92
I_OFFSET = 3
93
I_LEN = 4
94
207 by mbp at sourcefrog
Revfile: compress data going into datafile if that would be worthwhile
95
FL_GZIP = 1
96
205 by mbp at sourcefrog
Revfile:- store and retrieve deltas!mdiff:- work on bytes not lines
97
198 by mbp at sourcefrog
- experimental compressed Revfile support
98
class RevfileError(Exception):
99
    pass
100
201 by mbp at sourcefrog
Revfile: - get full text from a record- fix creation of files if they don't exist- protect against half-assed storage
101
102
198 by mbp at sourcefrog
- experimental compressed Revfile support
103
class Revfile:
104
    def __init__(self, basename):
202 by mbp at sourcefrog
Revfile:
105
        # TODO: Option to open readonly
106
107
        # TODO: Lock file  while open
108
109
        # TODO: advise of random access
110
198 by mbp at sourcefrog
- experimental compressed Revfile support
111
        self.basename = basename
201 by mbp at sourcefrog
Revfile: - get full text from a record- fix creation of files if they don't exist- protect against half-assed storage
112
        
113
        idxname = basename + '.irev'
114
        dataname = basename + '.drev'
115
116
        idx_exists = os.path.exists(idxname)
117
        data_exists = os.path.exists(dataname)
118
119
        if idx_exists != data_exists:
120
            raise RevfileError("half-assed revfile")
121
        
122
        if not idx_exists:
123
            self.idxfile = open(idxname, 'w+b')
124
            self.datafile = open(dataname, 'w+b')
125
            
198 by mbp at sourcefrog
- experimental compressed Revfile support
126
            print 'init empty file'
127
            self.idxfile.write(_HEADER)
128
            self.idxfile.flush()
129
        else:
201 by mbp at sourcefrog
Revfile: - get full text from a record- fix creation of files if they don't exist- protect against half-assed storage
130
            self.idxfile = open(idxname, 'r+b')
202 by mbp at sourcefrog
Revfile:
131
            self.datafile = open(dataname, 'r+b')
201 by mbp at sourcefrog
Revfile: - get full text from a record- fix creation of files if they don't exist- protect against half-assed storage
132
            
198 by mbp at sourcefrog
- experimental compressed Revfile support
133
            h = self.idxfile.read(_RECORDSIZE)
134
            if h != _HEADER:
135
                raise RevfileError("bad header %r in index of %r"
136
                                   % (h, self.basename))
201 by mbp at sourcefrog
Revfile: - get full text from a record- fix creation of files if they don't exist- protect against half-assed storage
137
138
205 by mbp at sourcefrog
Revfile:- store and retrieve deltas!mdiff:- work on bytes not lines
139
    def _check_index(self, idx):
140
        if idx < 0 or idx > len(self):
141
            raise RevfileError("invalid index %r" % idx)
142
143
144
    def find_sha(self, s):
145
        assert isinstance(s, str)
146
        assert len(s) == 20
147
        
148
        for idx, idxrec in enumerate(self):
149
            if idxrec[I_SHA] == s:
150
                return idx
151
        else:
217 by mbp at sourcefrog
Revfile: make compression optional, in case people are storing files they know won't compress
152
            return _NO_RECORD
153
154
155
156
    def _add_compressed(self, text_sha, data, base, compress):
157
        # well, maybe compress
158
        flags = 0
159
        if compress:
160
            data_len = len(data)
161
            if data_len > 50:
162
                # don't do compression if it's too small; it's unlikely to win
163
                # enough to be worthwhile
164
                compr_data = zlib.compress(data)
165
                compr_len = len(compr_data)
166
                if compr_len < data_len:
167
                    data = compr_data
168
                    flags = FL_GZIP
169
                    ##print '- compressed %d -> %d, %.1f%%' \
170
                    ##      % (data_len, compr_len, float(compr_len)/float(data_len) * 100.0)
171
        return self._add_raw(text_sha, data, base, flags)
172
        
173
174
175
    def _add_raw(self, text_sha, data, base, flags):
207 by mbp at sourcefrog
Revfile: compress data going into datafile if that would be worthwhile
176
        """Add pre-processed data, can be either full text or delta.
177
178
        This does the compression if that makes sense."""
203 by mbp at sourcefrog
revfile:
179
        idx = len(self)
198 by mbp at sourcefrog
- experimental compressed Revfile support
180
        self.datafile.seek(0, 2)        # to end
181
        self.idxfile.seek(0, 2)
202 by mbp at sourcefrog
Revfile:
182
        assert self.idxfile.tell() == _RECORDSIZE * (idx + 1)
198 by mbp at sourcefrog
- experimental compressed Revfile support
183
        data_offset = self.datafile.tell()
184
205 by mbp at sourcefrog
Revfile:- store and retrieve deltas!mdiff:- work on bytes not lines
185
        assert isinstance(data, str) # not unicode or anything wierd
198 by mbp at sourcefrog
- experimental compressed Revfile support
186
205 by mbp at sourcefrog
Revfile:- store and retrieve deltas!mdiff:- work on bytes not lines
187
        self.datafile.write(data)
198 by mbp at sourcefrog
- experimental compressed Revfile support
188
        self.datafile.flush()
189
205 by mbp at sourcefrog
Revfile:- store and retrieve deltas!mdiff:- work on bytes not lines
190
        assert isinstance(text_sha, str)
191
        entry = text_sha
192
        entry += struct.pack(">IIII12x", base, flags, data_offset, len(data))
198 by mbp at sourcefrog
- experimental compressed Revfile support
193
        assert len(entry) == _RECORDSIZE
194
195
        self.idxfile.write(entry)
196
        self.idxfile.flush()
197
198
        return idx
204 by mbp at sourcefrog
Revfile:- new find-sha command and implementation- new _check_index helper
199
        
205 by mbp at sourcefrog
Revfile:- store and retrieve deltas!mdiff:- work on bytes not lines
200
201
206 by mbp at sourcefrog
new Revfile.add() dwim
202
    def _add_full_text(self, text, text_sha):
205 by mbp at sourcefrog
Revfile:- store and retrieve deltas!mdiff:- work on bytes not lines
203
        """Add a full text to the file.
204
205
        This is not compressed against any reference version.
206
207
        Returns the index for that text."""
217 by mbp at sourcefrog
Revfile: make compression optional, in case people are storing files they know won't compress
208
        return self._add_compressed(text_sha, text, _NO_RECORD, compress)
209
210
211
    def _add_delta(self, text, text_sha, base, compress):
204 by mbp at sourcefrog
Revfile:- new find-sha command and implementation- new _check_index helper
212
        """Add a text stored relative to a previous text."""
213
        self._check_index(base)
205 by mbp at sourcefrog
Revfile:- store and retrieve deltas!mdiff:- work on bytes not lines
214
        base_text = self.get(base)
215
        data = mdiff.bdiff(base_text, text)
213 by mbp at sourcefrog
Revfile: don't store deltas if they'd be larger than just storing the whole text
216
        
217
        # If the delta is larger than the text, we might as well just
218
        # store the text.  (OK, the delta might be more compressible,
219
        # but the overhead of applying it probably still makes it
214 by mbp at sourcefrog
doc
220
        # bad, and I don't want to compress both of them to find out.)
213 by mbp at sourcefrog
Revfile: don't store deltas if they'd be larger than just storing the whole text
221
        if len(data) >= len(text):
217 by mbp at sourcefrog
Revfile: make compression optional, in case people are storing files they know won't compress
222
            return self._add_full_text(text, text_sha, compress)
213 by mbp at sourcefrog
Revfile: don't store deltas if they'd be larger than just storing the whole text
223
        else:
217 by mbp at sourcefrog
Revfile: make compression optional, in case people are storing files they know won't compress
224
            return self._add_compressed(text_sha, data, base, compress)
225
226
227
    def add(self, text, base=_NO_RECORD, compress=True):
215 by mbp at sourcefrog
Doc
228
        """Add a new text to the revfile.
229
230
        If the text is already present them its existing id is
231
        returned and the file is not changed.
232
217 by mbp at sourcefrog
Revfile: make compression optional, in case people are storing files they know won't compress
233
        If compress is true then gzip compression will be used if it
234
        reduces the size.
235
215 by mbp at sourcefrog
Doc
236
        If a base index is specified, that text *may* be used for
237
        delta compression of the new text.  Delta compression will
238
        only be used if it would be a size win and if the existing
239
        base is not at too long of a delta chain already.
240
        """
206 by mbp at sourcefrog
new Revfile.add() dwim
241
        text_sha = sha.new(text).digest()
204 by mbp at sourcefrog
Revfile:- new find-sha command and implementation- new _check_index helper
242
206 by mbp at sourcefrog
new Revfile.add() dwim
243
        idx = self.find_sha(text_sha)
244
        if idx != _NO_RECORD:
215 by mbp at sourcefrog
Doc
245
            # TODO: Optional paranoid mode where we read out that record and make sure
246
            # it's the same, in case someone ever breaks SHA-1.
206 by mbp at sourcefrog
new Revfile.add() dwim
247
            return idx                  # already present
204 by mbp at sourcefrog
Revfile:- new find-sha command and implementation- new _check_index helper
248
        
206 by mbp at sourcefrog
new Revfile.add() dwim
249
        if base == _NO_RECORD:
217 by mbp at sourcefrog
Revfile: make compression optional, in case people are storing files they know won't compress
250
            return self._add_full_text(text, text_sha, compress)
206 by mbp at sourcefrog
new Revfile.add() dwim
251
        else:
217 by mbp at sourcefrog
Revfile: make compression optional, in case people are storing files they know won't compress
252
            return self._add_delta(text, text_sha, base, compress)
206 by mbp at sourcefrog
new Revfile.add() dwim
253
254
255
205 by mbp at sourcefrog
Revfile:- store and retrieve deltas!mdiff:- work on bytes not lines
256
    def get(self, idx):
201 by mbp at sourcefrog
Revfile: - get full text from a record- fix creation of files if they don't exist- protect against half-assed storage
257
        idxrec = self[idx]
205 by mbp at sourcefrog
Revfile:- store and retrieve deltas!mdiff:- work on bytes not lines
258
        base = idxrec[I_BASE]
259
        if base == _NO_RECORD:
260
            text = self._get_full_text(idx, idxrec)
261
        else:
262
            text = self._get_patched(idx, idxrec)
263
264
        if sha.new(text).digest() != idxrec[I_SHA]:
265
            raise RevfileError("corrupt SHA-1 digest on record %d"
266
                               % idx)
267
268
        return text
269
270
271
272
    def _get_raw(self, idx, idxrec):
209 by mbp at sourcefrog
Revfile: handle decompression
273
        flags = idxrec[I_FLAGS]
274
        if flags & ~FL_GZIP:
275
            raise RevfileError("unsupported index flags %#x on index %d"
276
                               % (flags, idx))
277
        
201 by mbp at sourcefrog
Revfile: - get full text from a record- fix creation of files if they don't exist- protect against half-assed storage
278
        l = idxrec[I_LEN]
279
        if l == 0:
280
            return ''
281
282
        self.datafile.seek(idxrec[I_OFFSET])
283
205 by mbp at sourcefrog
Revfile:- store and retrieve deltas!mdiff:- work on bytes not lines
284
        data = self.datafile.read(l)
285
        if len(data) != l:
201 by mbp at sourcefrog
Revfile: - get full text from a record- fix creation of files if they don't exist- protect against half-assed storage
286
            raise RevfileError("short read %d of %d "
287
                               "getting text for record %d in %r"
205 by mbp at sourcefrog
Revfile:- store and retrieve deltas!mdiff:- work on bytes not lines
288
                               % (len(data), l, idx, self.basename))
204 by mbp at sourcefrog
Revfile:- new find-sha command and implementation- new _check_index helper
289
209 by mbp at sourcefrog
Revfile: handle decompression
290
        if flags & FL_GZIP:
291
            data = zlib.decompress(data)
292
205 by mbp at sourcefrog
Revfile:- store and retrieve deltas!mdiff:- work on bytes not lines
293
        return data
201 by mbp at sourcefrog
Revfile: - get full text from a record- fix creation of files if they don't exist- protect against half-assed storage
294
        
205 by mbp at sourcefrog
Revfile:- store and retrieve deltas!mdiff:- work on bytes not lines
295
296
    def _get_full_text(self, idx, idxrec):
297
        assert idxrec[I_BASE] == _NO_RECORD
298
299
        text = self._get_raw(idx, idxrec)
300
301
        return text
302
303
304
    def _get_patched(self, idx, idxrec):
305
        base = idxrec[I_BASE]
306
        assert base >= 0
307
        assert base < idx    # no loops!
308
309
        base_text = self.get(base)
310
        patch = self._get_raw(idx, idxrec)
311
312
        text = mdiff.bpatch(base_text, patch)
313
314
        return text
315
201 by mbp at sourcefrog
Revfile: - get full text from a record- fix creation of files if they don't exist- protect against half-assed storage
316
317
198 by mbp at sourcefrog
- experimental compressed Revfile support
318
    def __len__(self):
203 by mbp at sourcefrog
revfile:
319
        """Return number of revisions."""
320
        l = os.fstat(self.idxfile.fileno())[stat.ST_SIZE]
321
        if l % _RECORDSIZE:
322
            raise RevfileError("bad length %d on index of %r" % (l, self.basename))
323
        if l < _RECORDSIZE:
324
            raise RevfileError("no header present in index of %r" % (self.basename))
325
        return int(l / _RECORDSIZE) - 1
198 by mbp at sourcefrog
- experimental compressed Revfile support
326
200 by mbp at sourcefrog
revfile: fix up __getitem__ to allow simple iteration
327
198 by mbp at sourcefrog
- experimental compressed Revfile support
328
    def __getitem__(self, idx):
201 by mbp at sourcefrog
Revfile: - get full text from a record- fix creation of files if they don't exist- protect against half-assed storage
329
        """Index by sequence id returns the index field"""
204 by mbp at sourcefrog
Revfile:- new find-sha command and implementation- new _check_index helper
330
        ## TODO: Can avoid seek if we just moved there...
201 by mbp at sourcefrog
Revfile: - get full text from a record- fix creation of files if they don't exist- protect against half-assed storage
331
        self._seek_index(idx)
332
        return self._read_next_index()
333
334
335
    def _seek_index(self, idx):
205 by mbp at sourcefrog
Revfile:- store and retrieve deltas!mdiff:- work on bytes not lines
336
        if idx < 0:
337
            raise RevfileError("invalid index %r" % idx)
198 by mbp at sourcefrog
- experimental compressed Revfile support
338
        self.idxfile.seek((idx + 1) * _RECORDSIZE)
201 by mbp at sourcefrog
Revfile: - get full text from a record- fix creation of files if they don't exist- protect against half-assed storage
339
        
340
341
    def _read_next_index(self):
198 by mbp at sourcefrog
- experimental compressed Revfile support
342
        rec = self.idxfile.read(_RECORDSIZE)
200 by mbp at sourcefrog
revfile: fix up __getitem__ to allow simple iteration
343
        if not rec:
201 by mbp at sourcefrog
Revfile: - get full text from a record- fix creation of files if they don't exist- protect against half-assed storage
344
            raise IndexError("end of index file")
200 by mbp at sourcefrog
revfile: fix up __getitem__ to allow simple iteration
345
        elif len(rec) != _RECORDSIZE:
198 by mbp at sourcefrog
- experimental compressed Revfile support
346
            raise RevfileError("short read of %d bytes getting index %d from %r"
347
                               % (len(rec), idx, self.basename))
201 by mbp at sourcefrog
Revfile: - get full text from a record- fix creation of files if they don't exist- protect against half-assed storage
348
        
199 by mbp at sourcefrog
- use -1 for no_base in revfile
349
        return struct.unpack(">20sIIII12x", rec)
198 by mbp at sourcefrog
- experimental compressed Revfile support
350
351
        
199 by mbp at sourcefrog
- use -1 for no_base in revfile
352
    def dump(self, f=sys.stdout):
353
        f.write('%-8s %-40s %-8s %-8s %-8s %-8s\n' 
354
                % tuple('idx sha1 base flags offset len'.split()))
355
        f.write('-------- ---------------------------------------- ')
356
        f.write('-------- -------- -------- --------\n')
357
200 by mbp at sourcefrog
revfile: fix up __getitem__ to allow simple iteration
358
        for i, rec in enumerate(self):
199 by mbp at sourcefrog
- use -1 for no_base in revfile
359
            f.write("#%-7d %40s " % (i, hexlify(rec[0])))
204 by mbp at sourcefrog
Revfile:- new find-sha command and implementation- new _check_index helper
360
            if rec[1] == _NO_RECORD:
199 by mbp at sourcefrog
- use -1 for no_base in revfile
361
                f.write("(none)   ")
362
            else:
363
                f.write("#%-7d " % rec[1])
364
                
365
            f.write("%8x %8d %8d\n" % (rec[2], rec[3], rec[4]))
198 by mbp at sourcefrog
- experimental compressed Revfile support
366
        
367
368
369
def main(argv):
370
    r = Revfile("testrev")
203 by mbp at sourcefrog
revfile:
371
372
    try:
373
        cmd = argv[1]
374
    except IndexError:
198 by mbp at sourcefrog
- experimental compressed Revfile support
375
        sys.stderr.write("usage: revfile dump\n"
201 by mbp at sourcefrog
Revfile: - get full text from a record- fix creation of files if they don't exist- protect against half-assed storage
376
                         "       revfile add\n"
205 by mbp at sourcefrog
Revfile:- store and retrieve deltas!mdiff:- work on bytes not lines
377
                         "       revfile add-delta BASE\n"
204 by mbp at sourcefrog
Revfile:- new find-sha command and implementation- new _check_index helper
378
                         "       revfile get IDX\n"
379
                         "       revfile find-sha HEX\n")
203 by mbp at sourcefrog
revfile:
380
        return 1
218 by mbp at sourcefrog
todo
381
382
383
    # TODO: Something to show compression ratio, e.g. total size of
384
    # all files vs size of index and data files.
198 by mbp at sourcefrog
- experimental compressed Revfile support
385
        
203 by mbp at sourcefrog
revfile:
386
387
    if cmd == 'add':
206 by mbp at sourcefrog
new Revfile.add() dwim
388
        new_idx = r.add(sys.stdin.read())
216 by mbp at sourcefrog
revfile add and add-delta commands print just the index for use by scripts
389
        print new_idx
205 by mbp at sourcefrog
Revfile:- store and retrieve deltas!mdiff:- work on bytes not lines
390
    elif cmd == 'add-delta':
207 by mbp at sourcefrog
Revfile: compress data going into datafile if that would be worthwhile
391
        new_idx = r.add(sys.stdin.read(), int(argv[2]))
216 by mbp at sourcefrog
revfile add and add-delta commands print just the index for use by scripts
392
        print new_idx
203 by mbp at sourcefrog
revfile:
393
    elif cmd == 'dump':
198 by mbp at sourcefrog
- experimental compressed Revfile support
394
        r.dump()
203 by mbp at sourcefrog
revfile:
395
    elif cmd == 'get':
202 by mbp at sourcefrog
Revfile:
396
        try:
203 by mbp at sourcefrog
revfile:
397
            idx = int(argv[2])
202 by mbp at sourcefrog
Revfile:
398
        except IndexError:
203 by mbp at sourcefrog
revfile:
399
            sys.stderr.write("usage: revfile get IDX\n")
400
            return 1
401
402
        if idx < 0 or idx >= len(r):
403
            sys.stderr.write("invalid index %r\n" % idx)
404
            return 1
405
205 by mbp at sourcefrog
Revfile:- store and retrieve deltas!mdiff:- work on bytes not lines
406
        sys.stdout.write(r.get(idx))
204 by mbp at sourcefrog
Revfile:- new find-sha command and implementation- new _check_index helper
407
    elif cmd == 'find-sha':
408
        try:
409
            s = unhexlify(argv[2])
410
        except IndexError:
411
            sys.stderr.write("usage: revfile find-sha HEX\n")
412
            return 1
413
414
        idx = r.find_sha(s)
415
        if idx == _NO_RECORD:
416
            sys.stderr.write("no such record\n")
417
            return 1
418
        else:
419
            print idx
420
            
198 by mbp at sourcefrog
- experimental compressed Revfile support
421
    else:
203 by mbp at sourcefrog
revfile:
422
        sys.stderr.write("unknown command %r\n" % cmd)
423
        return 1
198 by mbp at sourcefrog
- experimental compressed Revfile support
424
    
425
426
if __name__ == '__main__':
427
    import sys
203 by mbp at sourcefrog
revfile:
428
    sys.exit(main(sys.argv) or 0)