/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

Partially fix pull.

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
        create index if not exists commit_sha1 on commits(sha1);
58
58
        create table if not exists blobs(sha1 text, fileid text, revid text);
59
59
        create index if not exists blobs_sha1 on blobs(sha1);
60
 
        create table if not exists trees(sha1 text, path text, revid text);
 
60
        create table if not exists trees(sha1 text, fileid text, revid text);
61
61
        create index if not exists trees_sha1 on trees(sha1);
62
62
""")
63
63
 
64
64
    def _parent_lookup(self, revid):
65
65
        return self.db.execute("select sha1 from commits where revid = ?", (revid,)).fetchone()[0].encode("utf-8")
66
66
 
67
 
    def commit(self):
68
 
        self.db.commit()
69
 
 
70
67
    def add_entry(self, sha, type, type_data):
71
68
        """Add a new entry to the database.
72
69
        """
77
74
        elif type == "blob":
78
75
            self.db.execute("replace into blobs (sha1, fileid, revid) values (?, ?, ?)", (sha, type_data[0], type_data[1]))
79
76
        elif type == "tree":
80
 
            self.db.execute("replace into trees (sha1, path, revid) values (?, ?, ?)", (sha, type_data[0], type_data[1]))
 
77
            self.db.execute("replace into trees (sha1, fileid, revid) values (?, ?, ?)", (sha, type_data[0], type_data[1]))
81
78
        else:
82
79
            raise AssertionError("Unknown type %s" % type)
83
80
 
94
91
        row = self.db.execute("select fileid, revid from blobs where sha1 = ?", (sha,)).fetchone()
95
92
        if row is not None:
96
93
            return ("blob", row)
97
 
        row = self.db.execute("select path, revid from trees where sha1 = ?", (sha,)).fetchone()
 
94
        row = self.db.execute("select fileid, revid from trees where sha1 = ?", (sha,)).fetchone()
98
95
        if row is not None:
99
96
            return ("tree", row)
100
97
        raise KeyError(sha)