/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

Use XDG cache directory if the python xdg module is available.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
    )
33
33
 
34
34
 
 
35
def get_cache_dir():
 
36
    try:
 
37
        from xdg.BaseDirectory import xdg_cache_home
 
38
    except ImportError:
 
39
        pass
 
40
    else:
 
41
        return os.path.join(xdg_cache_home, "bazaar", "git")
 
42
    from bzrlib.config import config_dir
 
43
    return os.path.join(config_dir(), "git")
 
44
 
 
45
 
35
46
def check_pysqlite_version(sqlite3):
36
47
    """Check that sqlite library is compatible.
37
48
 
170
181
                return cls(os.path.join(transport.local_abspath("."), "git.db"))
171
182
        except bzrlib.errors.NotLocalUrl:
172
183
            pass
173
 
        from bzrlib.config import config_dir
174
 
        return cls(os.path.join(config_dir(), "remote-git.db"))
 
184
        return cls(os.path.join(get_cache_dir(), "remote.db"))
175
185
 
176
186
    def lookup_commit(self, revid):
177
187
        row = self.db.execute("select sha1 from commits where revid = ?", (revid,)).fetchone()
299
309
                return cls(os.path.join(transport.local_abspath("."), "git.tdb"))
300
310
        except bzrlib.errors.NotLocalUrl:
301
311
            pass
302
 
        from bzrlib.config import config_dir
303
 
        return cls(os.path.join(config_dir(), "remote-git.tdb"))
 
312
        return cls(os.path.join(get_cache_dir(), "remote.tdb"))
304
313
 
305
314
    def lookup_commit(self, revid):
306
315
        return sha_to_hex(self.db["commit\0" + revid][:20])