/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

Merge bzr-foreign.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2009 Canonical Ltd
 
1
# Copyright (C) 2009 Jelmer Vernooij <jelmer@samba.org>
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
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, fileid text, revid text);
 
60
        create table if not exists trees(sha1 text, path 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
 
67
70
    def add_entry(self, sha, type, type_data):
68
71
        """Add a new entry to the database.
69
72
        """
74
77
        elif type == "blob":
75
78
            self.db.execute("replace into blobs (sha1, fileid, revid) values (?, ?, ?)", (sha, type_data[0], type_data[1]))
76
79
        elif type == "tree":
77
 
            self.db.execute("replace into trees (sha1, fileid, revid) values (?, ?, ?)", (sha, type_data[0], type_data[1]))
 
80
            self.db.execute("replace into trees (sha1, path, revid) values (?, ?, ?)", (sha, type_data[0], type_data[1]))
78
81
        else:
79
82
            raise AssertionError("Unknown type %s" % type)
80
83
 
91
94
        row = self.db.execute("select fileid, revid from blobs where sha1 = ?", (sha,)).fetchone()
92
95
        if row is not None:
93
96
            return ("blob", row)
94
 
        row = self.db.execute("select fileid, revid from trees where sha1 = ?", (sha,)).fetchone()
 
97
        row = self.db.execute("select path, revid from trees where sha1 = ?", (sha,)).fetchone()
95
98
        if row is not None:
96
99
            return ("tree", row)
97
100
        raise KeyError(sha)