/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

Tags: bzr-git-0.1.0
Add tests for GitShaMap.

Show diffs side-by-side

added added

removed removed

Lines of Context:
83
83
        return self.dict[sha]
84
84
 
85
85
    def revids(self):
86
 
        ret = []
87
86
        for key, (type, type_data) in self.dict.iteritems():
88
87
            if type == "commit":
89
 
                ret.append(type_data[0])
90
 
        return ret
 
88
                yield type_data[0]
91
89
 
92
90
 
93
91
class SqliteGitShaMap(GitShaMap):
94
92
 
95
 
    def __init__(self, transport):
 
93
    def __init__(self, transport=None):
96
94
        self.transport = transport
97
 
        self.db = sqlite3.connect(
98
 
            os.path.join(self.transport.local_abspath("."), "git.db"))
 
95
        if transport is None:
 
96
            self.db = sqlite3.connect(":memory:")
 
97
        else:
 
98
            self.db = sqlite3.connect(
 
99
                os.path.join(self.transport.local_abspath("."), "git.db"))
99
100
        self.db.executescript("""
100
101
        create table if not exists commits(sha1 text, revid text, tree_sha text);
101
102
        create index if not exists commit_sha1 on commits(sha1);