/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to shamap.py

Support submodules during fetch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
from bzrlib import (
28
28
    trace,
29
29
    )
30
 
from bzrlib.errors import (
31
 
    NoSuchRevision,
32
 
    )
33
30
 
34
31
 
35
32
def get_cache_dir():
52
49
    if (sqlite3.sqlite_version_info[0] < 3 or 
53
50
            (sqlite3.sqlite_version_info[0] == 3 and 
54
51
             sqlite3.sqlite_version_info[1] < 3)):
55
 
        warning('Needs at least sqlite 3.3.x')
 
52
        trace.warning('Needs at least sqlite 3.3.x')
56
53
        raise bzrlib.errors.BzrError("incompatible sqlite library")
57
54
 
58
55
try:
63
60
        from pysqlite2 import dbapi2 as sqlite3
64
61
        check_pysqlite_version(sqlite3)
65
62
except:
66
 
    warning('Needs at least Python2.5 or Python2.4 with the pysqlite2 '
 
63
    trace.warning('Needs at least Python2.5 or Python2.4 with the pysqlite2 '
67
64
            'module')
68
65
    raise bzrlib.errors.BzrError("missing sqlite library")
69
66
 
113
110
        """List the revision ids known."""
114
111
        raise NotImplementedError(self.revids)
115
112
 
116
 
    def sha1s(Self):
 
113
    def sha1s(self):
117
114
        """List the SHA1s."""
118
115
        raise NotImplementedError(self.sha1s)
119
116
 
271
268
 
272
269
 
273
270
TDB_MAP_VERSION = 2
274
 
TDB_HASH_SIZE = 10000
 
271
TDB_HASH_SIZE = 50000
275
272
 
276
273
 
277
274
class TdbGitShaMap(GitShaMap):
320
317
    def commit(self):
321
318
        pass
322
319
 
323
 
    def add_entry(self, sha, type, type_data):
 
320
    def add_entry(self, hexsha, type, type_data):
324
321
        """Add a new entry to the database.
325
322
        """
326
 
        self.db["git\0" + hex_to_sha(sha)] = "\0".join((type, type_data[0], type_data[1]))
 
323
        if hexsha is None:
 
324
            sha = ""
 
325
        else:
 
326
            sha = hex_to_sha(hexsha)
 
327
            self.db["git\0" + sha] = "\0".join((type, type_data[0], type_data[1]))
327
328
        if type == "commit":
328
 
            self.db["commit\0" + type_data[0]] = "\0".join((hex_to_sha(sha), type_data[1]))
 
329
            self.db["commit\0" + type_data[0]] = "\0".join((sha, type_data[1]))
329
330
        else:
330
 
            self.db["\0".join((type, type_data[0], type_data[1]))] = hex_to_sha(sha)
 
331
            self.db["\0".join((type, type_data[0], type_data[1]))] = sha
331
332
 
332
333
    def lookup_tree(self, fileid, revid):
333
 
        return sha_to_hex(self.db["\0".join(("tree", fileid, revid))])
 
334
        sha = self.db["\0".join(("tree", fileid, revid))]
 
335
        if sha == "":
 
336
            return None
 
337
        else:
 
338
            return sha_to_hex(sha)
334
339
 
335
340
    def lookup_blob(self, fileid, revid):
336
341
        return sha_to_hex(self.db["\0".join(("blob", fileid, revid))])
342
347
        :return: (type, type_data) with type_data:
343
348
            revision: revid, tree sha
344
349
        """
345
 
        data = self.db["git\0" + hex_to_sha(sha)].split("\0")
 
350
        if len(sha) == 40:
 
351
            sha = hex_to_sha(sha)
 
352
        data = self.db["git\0" + sha].split("\0")
346
353
        return (data[0], (data[1], data[2]))
347
354
 
348
355
    def revids(self):