/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 breezy/git/cache.py

  • Committer: Gustav Hartvigsson
  • Date: 2021-01-09 21:36:27 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20210109213627-h1xwcutzy9m7a99b
Added 'Case Preserving Working Tree Use Cases' from Canonical Wiki

* Addod a page from the Canonical Bazaar wiki
  with information on the scmeatics of case
  perserving filesystems an a case insensitive
  filesystem works.
  
  * Needs re-work, but this will do as it is the
    same inforamoton as what was on the linked
    page in the currint documentation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Map from Git sha's to Bazaar objects."""
18
18
 
19
 
from __future__ import absolute_import
20
 
 
21
19
from dulwich.objects import (
22
20
    sha_to_hex,
23
21
    hex_to_sha,
30
28
    )
31
29
 
32
30
from .. import (
 
31
    bedding,
33
32
    errors as bzr_errors,
34
33
    osutils,
35
34
    registry,
40
39
    index as _mod_index,
41
40
    versionedfile,
42
41
    )
43
 
from ..sixish import (
44
 
    viewitems,
45
 
    viewkeys,
46
 
    viewvalues,
47
 
    )
48
42
from ..transport import (
49
 
    get_transport,
 
43
    get_transport_from_path,
50
44
    )
51
45
 
52
46
 
53
47
def get_cache_dir():
54
 
    try:
55
 
        from xdg.BaseDirectory import xdg_cache_home
56
 
    except ImportError:
57
 
        from ..config import config_dir
58
 
        ret = os.path.join(config_dir(), "git")
59
 
    else:
60
 
        ret = os.path.join(xdg_cache_home, "breezy", "git")
61
 
    if not os.path.isdir(ret):
62
 
        os.makedirs(ret)
63
 
    return ret
 
48
    path = os.path.join(bedding.cache_dir(), "git")
 
49
    if not os.path.isdir(path):
 
50
        os.mkdir(path)
 
51
    return path
64
52
 
65
53
 
66
54
def get_remote_cache_transport(repository):
74
62
        path = os.path.join(get_cache_dir(), uuid)
75
63
        if not os.path.isdir(path):
76
64
            os.mkdir(path)
77
 
    return get_transport(path)
 
65
    return get_transport_from_path(path)
78
66
 
79
67
 
80
68
def check_pysqlite_version(sqlite3):
341
329
    def lookup_git_sha(self, sha):
342
330
        if not isinstance(sha, bytes):
343
331
            raise TypeError(sha)
344
 
        for entry in viewvalues(self._by_sha[sha]):
 
332
        for entry in self._by_sha[sha].values():
345
333
            yield entry
346
334
 
347
335
    def lookup_tree_id(self, fileid, revision):
351
339
        return self._by_revid[revid]
352
340
 
353
341
    def revids(self):
354
 
        for key, entries in viewitems(self._by_sha):
355
 
            for (type, type_data) in viewvalues(entries):
 
342
        for key, entries in self._by_sha.items():
 
343
            for (type, type_data) in entries.values():
356
344
                if type == "commit":
357
345
                    yield type_data[0]
358
346
 
359
347
    def sha1s(self):
360
 
        return viewkeys(self._by_sha)
 
348
        return self._by_sha.keys()
361
349
 
362
350
 
363
351
class SqliteCacheUpdater(CacheUpdater):
613
601
 
614
602
    def open(self, transport):
615
603
        try:
616
 
            basepath = transport.local_abspath(".").encode(osutils._fs_enc)
 
604
            basepath = transport.local_abspath(".")
617
605
        except bzr_errors.NotLocalUrl:
618
606
            basepath = get_cache_dir()
619
 
        if not isinstance(basepath, str):
620
 
            raise TypeError(basepath)
621
607
        try:
622
608
            return TdbBzrGitCache(os.path.join(basepath, "idmap.tdb"))
623
609
        except ImportError:
718
704
        return ret
719
705
 
720
706
    def _keys(self):
721
 
        try:
722
 
            return self.db.keys()
723
 
        except AttributeError:  # python < 3
724
 
            return self.db.iterkeys()
 
707
        return self.db.keys()
725
708
 
726
709
    def revids(self):
727
710
        """List the revision ids known."""
850
833
            except bzr_errors.FileExists:
851
834
                pass
852
835
            return cls(transport.clone('git'))
853
 
        from ..transport import get_transport
854
 
        return cls(get_transport(get_cache_dir()))
 
836
        return cls(get_transport_from_path(get_cache_dir()))
855
837
 
856
838
    def __repr__(self):
857
839
        if self._transport is not None: