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")
63
60
from pysqlite2 import dbapi2 as sqlite3
64
61
check_pysqlite_version(sqlite3)
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 '
68
65
raise bzrlib.errors.BzrError("missing sqlite library")
320
317
def commit(self):
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.
326
self.db["git\0" + hex_to_sha(sha)] = "\0".join((type, type_data[0], type_data[1]))
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]))
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
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))]
338
return sha_to_hex(sha)
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
345
data = self.db["git\0" + hex_to_sha(sha)].split("\0")
351
sha = hex_to_sha(sha)
352
data = self.db["git\0" + sha].split("\0")
346
353
return (data[0], (data[1], data[2]))
348
355
def revids(self):