/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/interrepo.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
"""InterRepository operations."""
18
18
 
19
 
from __future__ import absolute_import
20
 
 
21
19
from io import BytesIO
22
20
import itertools
23
21
 
52
50
from ..revision import (
53
51
    NULL_REVISION,
54
52
    )
55
 
from ..sixish import (
56
 
    viewitems,
57
 
    viewvalues,
58
 
    )
59
53
from .. import (
60
54
    config,
61
55
    trace,
90
84
    )
91
85
from .remote import (
92
86
    RemoteGitRepository,
 
87
    RemoteGitError,
93
88
    )
94
89
from .unpeel_map import (
95
90
    UnpeelMap,
229
224
                        new_stop_revids.append(revid)
230
225
                stop_revids = set()
231
226
                parent_map = graph.get_parent_map(new_stop_revids)
232
 
                for parent_revids in viewvalues(parent_map):
 
227
                for parent_revids in parent_map.values():
233
228
                    stop_revids.update(parent_revids)
234
229
                pb.update("determining revisions to fetch", len(missing))
235
230
        return graph.iter_topo_order(missing)
248
243
                # broken symref?
249
244
                continue
250
245
            revid = None
251
 
            if not v.startswith(SYMREF):
 
246
            if v and not v.startswith(SYMREF):
252
247
                try:
253
248
                    for (kind, type_data) in self.source_store.lookup_git_sha(
254
249
                            v):
272
267
                 for (git_sha, bzr_revid) in new_refs.values()
273
268
                 if git_sha is None or not git_sha.startswith(SYMREF)],
274
269
                lossy=lossy)
275
 
            for name, (gitid, revid) in viewitems(new_refs):
 
270
            for name, (gitid, revid) in new_refs.items():
276
271
                if gitid is None:
277
272
                    try:
278
273
                        gitid = revidmap[revid][0]
314
309
                        try:
315
310
                            self.mapping.revision_id_bzr_to_foreign(old_revid)
316
311
                        except InvalidRevisionId:
317
 
                            refname = self.mapping.revid_as_refname(old_revid)
318
 
                            self.target_refs[refname] = git_sha
 
312
                            pass
319
313
                    revidmap[old_revid] = (git_sha, new_revid)
320
314
                self.target_store.add_objects(object_generator)
321
315
                return revidmap
362
356
        def git_update_refs(old_refs):
363
357
            ret = {}
364
358
            self.old_refs = {
365
 
                k: (v, None) for (k, v) in viewitems(old_refs)}
 
359
                k: (v, None) for (k, v) in old_refs.items()}
366
360
            new_refs = update_refs(self.old_refs)
367
 
            for name, (gitid, revid) in viewitems(new_refs):
 
361
            for name, (gitid, revid) in new_refs.items():
368
362
                if gitid is None:
369
363
                    git_sha = self.source_store._lookup_revision_sha1(revid)
370
364
                    gitid = unpeel_map.re_unpeel_tag(
377
371
            return ret
378
372
        self._warn_slow()
379
373
        with self.source_store.lock_read():
380
 
            new_refs = self.target.send_pack(
 
374
            result = self.target.send_pack(
381
375
                git_update_refs, self.source_store.generate_lossy_pack_data)
 
376
            if result is not None and not isinstance(result, dict):
 
377
                for ref, error in result.ref_status.items():
 
378
                    if error:
 
379
                        raise RemoteGitError(
 
380
                            'unable to update ref %r: %s' % (ref, error))
 
381
                new_refs = result.refs
 
382
            else:  # dulwich < 0.20.3
 
383
                new_refs = result
382
384
        # FIXME: revidmap?
383
385
        return revidmap, self.old_refs, new_refs
384
386
 
415
417
 
416
418
        def determine_wants(refs):
417
419
            unpeel_lookup = {}
418
 
            for k, v in viewitems(refs):
 
420
            for k, v in refs.items():
419
421
                if k.endswith(ANNOTATED_TAG_SUFFIX):
420
422
                    unpeel_lookup[v] = refs[k[:-len(ANNOTATED_TAG_SUFFIX)]]
421
423
            potential = set([unpeel_lookup.get(w, w) for w in wants])
422
424
            if include_tags:
423
 
                for k, sha in viewitems(refs):
 
425
                for k, sha in refs.items():
424
426
                    if k.endswith(ANNOTATED_TAG_SUFFIX):
425
427
                        continue
426
428
                    try:
463
465
            if if_present_ids is not None:
464
466
                todo.update(if_present_ids)
465
467
        result_set = todo.difference(self.target.all_revision_ids())
466
 
        result_parents = set(itertools.chain.from_iterable(viewvalues(
467
 
            self.source.get_graph().get_parent_map(result_set))))
 
468
        result_parents = set(itertools.chain.from_iterable(
 
469
            self.source.get_graph().get_parent_map(result_set).values()))
468
470
        included_keys = result_set.intersection(result_parents)
469
471
        start_keys = result_set.difference(included_keys)
470
472
        exclude_keys = result_parents.difference(result_set)
489
491
 
490
492
    def determine_wants_all(self, refs):
491
493
        potential = set()
492
 
        for k, v in viewitems(refs):
 
494
        for k, v in refs.items():
493
495
            # For non-git target repositories, only worry about peeled
494
496
            if v == ZERO_SHA:
495
497
                continue
563
565
        all_revs = self.target.all_revision_ids()
564
566
        parent_map = self.target.get_parent_map(all_revs)
565
567
        all_parents = set()
566
 
        for values in viewvalues(parent_map):
 
568
        for values in parent_map.values():
567
569
            all_parents.update(values)
568
570
        return set(all_revs) - all_parents
569
571
 
647
649
 
648
650
        def determine_wants(heads):
649
651
            old_refs = dict([(k, (v, None))
650
 
                             for (k, v) in viewitems(heads.as_dict())])
 
652
                             for (k, v) in heads.as_dict().items()])
651
653
            new_refs = update_refs(old_refs)
652
654
            ref_changes.update(new_refs)
653
 
            return [sha1 for (sha1, bzr_revid) in viewvalues(new_refs)]
 
655
            return [sha1 for (sha1, bzr_revid) in new_refs.values()]
654
656
        self.fetch_objects(determine_wants, lossy=lossy)
655
 
        for k, (git_sha, bzr_revid) in viewitems(ref_changes):
 
657
        for k, (git_sha, bzr_revid) in ref_changes.items():
656
658
            self.target._git.refs[k] = git_sha
657
659
        new_refs = self.target.controldir.get_refs_container()
658
660
        return None, old_refs, new_refs
706
708
    def get_determine_wants_branches(self, branches, include_tags=False):
707
709
        def determine_wants(refs):
708
710
            ret = []
709
 
            for name, value in viewitems(refs):
 
711
            for name, value in refs.items():
710
712
                if value == ZERO_SHA:
711
713
                    continue
712
714
 
786
788
        """Be compatible with GitRepository."""
787
789
        return (isinstance(source, RemoteGitRepository) and
788
790
                isinstance(target, LocalGitRepository))
 
791
 
 
792
 
 
793
 
 
794
class InterLocalGitRemoteGitRepository(InterToGitRepository):
 
795
 
 
796
    def fetch_refs(self, update_refs, lossy=False, overwrite=False):
 
797
        """Import the gist of the ancestry of a particular revision."""
 
798
        if lossy:
 
799
            raise LossyPushToSameVCS(self.source, self.target)
 
800
 
 
801
        def git_update_refs(old_refs):
 
802
            ret = {}
 
803
            self.old_refs = {
 
804
                k: (v, None) for (k, v) in viewitems(old_refs)}
 
805
            new_refs = update_refs(self.old_refs)
 
806
            for name, (gitid, revid) in viewitems(new_refs):
 
807
                if gitid is None:
 
808
                    gitid = self.source_store._lookup_revision_sha1(revid)
 
809
                if not overwrite:
 
810
                    if remote_divergence(
 
811
                            old_refs.get(name), gitid, self.source_store):
 
812
                        raise DivergedBranches(self.source, self.target)
 
813
                ret[name] = gitid
 
814
            return ret
 
815
        new_refs = self.target.send_pack(
 
816
            git_update_refs,
 
817
            self.source._git.generate_pack_data)
 
818
        return None, self.old_refs, new_refs
 
819
 
 
820
    @staticmethod
 
821
    def is_compatible(source, target):
 
822
        return (isinstance(source, LocalGitRepository) and
 
823
                isinstance(target, RemoteGitRepository))