78
78
fp = fingerprint_file(f)
81
if ie.text_size is not None:
81
if ie.text_size != None:
82
82
if ie.text_size != fp['size']:
83
83
bailout("mismatched size for file %r in %r" % (ie.file_id, self._store),
84
84
["inventory expects %d bytes" % ie.text_size,
92
92
"store is probably damaged/corrupt"])
95
def export(self, dest):
95
def print_file(self, fileid):
96
"""Print file with id `fileid` to stdout."""
98
pumpfile(self.get_file(fileid), sys.stdout)
101
def export(self, dest):
96
102
"""Export this tree to a new directory.
98
104
`dest` should not exist, and will be created holding the
99
105
contents of this tree.
101
:todo: To handle subdirectories we need to create the
107
TODO: To handle subdirectories we need to create the
102
108
directories first.
104
110
:note: If the export fails, the destination directory will be
115
121
elif kind == 'file':
116
122
pumpfile(self.get_file(ie.file_id), file(fullpath, 'wb'))
118
bailout("don't know how to export {%s} of kind %r", fid, kind)
124
bailout("don't know how to export {%s} of kind %r" % (fid, kind))
119
125
mutter(" export {%s} kind %s to %s" % (ie.file_id, kind, fullpath))
151
157
return file(self.abspath(filename), 'rb')
153
159
def _get_store_filename(self, file_id):
160
## XXX: badly named; this isn't in the store at all
154
161
return self.abspath(self.id2path(file_id))
156
163
def has_id(self, file_id):
231
238
for ff in descend(fp, f_ie.file_id, fap):
234
for f in descend('', None, self.basedir):
241
for f in descend('', inv.root.file_id, self.basedir):
299
306
def is_ignored(self, filename):
300
"""Check whether the filename matches an ignore pattern.
307
r"""Check whether the filename matches an ignore pattern.
302
Patterns containing '/' need to match the whole path; others
303
match against only the last component.
309
Patterns containing '/' or '\' need to match the whole path;
310
others match against only the last component.
305
312
If the file is ignored, returns the pattern which caused it to
306
313
be ignored, otherwise None. So this can simply be used as a
307
314
boolean if desired."""
309
## TODO: Use '**' to match directories, and other extended globbing stuff from cvs/rsync.
316
# TODO: Use '**' to match directories, and other extended
317
# globbing stuff from cvs/rsync.
319
# XXX: fnmatch is actually not quite what we want: it's only
320
# approximately the same as real Unix fnmatch, and doesn't
321
# treat dotfiles correctly and allows * to match /.
322
# Eventually it should be replaced with something more
311
325
for pat in self.get_ignore_list():
313
# as a special case, you can put ./ at the start of a pattern;
314
# this is good to match in the top-level only;
326
if '/' in pat or '\\' in pat:
328
# as a special case, you can put ./ at the start of a
329
# pattern; this is good to match in the top-level
332
if (pat[:2] == './') or (pat[:2] == '.\\'):
333
350
File text can be retrieved from the text store.
335
:todo: Some kind of `__repr__` method, but a good one
352
TODO: Some kind of `__repr__` method, but a good one
336
353
probably means knowing the branch and revision number,
337
354
or at least passing a description to the constructor.