/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/repository.py

  • Committer: Jelmer Vernooij
  • Date: 2019-06-03 23:48:08 UTC
  • mfrom: (7316 work)
  • mto: This revision was merged to the branch mainline in revision 7328.
  • Revision ID: jelmer@jelmer.uk-20190603234808-15yk5c7054tj8e2b
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
348
348
            o = self._git.object_store[sha]
349
349
            if not isinstance(o, Commit):
350
350
                continue
351
 
            revid = mapping.revision_id_foreign_to_bzr(o.id)
352
 
            yield o.id, revid
 
351
            revid = mapping.revision_id_foreign_to_bzr(o)
 
352
            roundtrip_revid = mapping.get_revision_id(o)
 
353
            yield o.id, revid, (roundtrip_revid if revid != roundtrip_revid else None)
353
354
 
354
355
    def all_revision_ids(self):
355
356
        ret = set()
356
 
        for git_sha, revid in self._iter_revision_ids():
357
 
            ret.add(revid)
 
357
        for git_sha, revid, roundtrip_revid in self._iter_revision_ids():
 
358
            if roundtrip_revid:
 
359
                ret.add(roundtrip_revid)
 
360
            else:
 
361
                ret.add(revid)
358
362
        return list(ret)
359
363
 
360
364
    def _get_parents(self, revid, no_alternates=False):
504
508
            (git_sha, mapping) = mapping_registry.revision_id_bzr_to_foreign(
505
509
                bzr_revid)
506
510
        except errors.InvalidRevisionId:
507
 
            raise errors.NoSuchRevision(self, bzr_revid)
 
511
            if mapping is None:
 
512
                mapping = self.get_mapping()
 
513
            try:
 
514
                return (self._git.refs[mapping.revid_as_refname(bzr_revid)],
 
515
                        mapping)
 
516
            except KeyError:
 
517
                # Update refs from Git commit objects
 
518
                # FIXME: Hitting this a lot will be very inefficient...
 
519
                pb = ui.ui_factory.nested_progress_bar()
 
520
                try:
 
521
                    for i, (git_sha, revid, roundtrip_revid) in enumerate(
 
522
                            self._iter_revision_ids()):
 
523
                        if not roundtrip_revid:
 
524
                            continue
 
525
                        pb.update("resolving revision id", i)
 
526
                        refname = mapping.revid_as_refname(roundtrip_revid)
 
527
                        self._git.refs[refname] = git_sha
 
528
                        if roundtrip_revid == bzr_revid:
 
529
                            return git_sha, mapping
 
530
                finally:
 
531
                    pb.finished()
 
532
                raise errors.NoSuchRevision(self, bzr_revid)
508
533
        else:
509
534
            return (git_sha, mapping)
510
535
 
517
542
        except KeyError:
518
543
            raise errors.NoSuchRevision(self, revision_id)
519
544
        revision, roundtrip_revid, verifiers = mapping.import_commit(
520
 
            commit, self.lookup_foreign_revision_id, strict=False)
 
545
            commit, self.lookup_foreign_revision_id)
521
546
        if revision is None:
522
547
            raise AssertionError
523
548
        # FIXME: check verifiers ?