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

  • Committer: Jelmer Vernooij
  • Date: 2019-03-04 05:10:44 UTC
  • mfrom: (7293 work)
  • mto: This revision was merged to the branch mainline in revision 7294.
  • Revision ID: jelmer@jelmer.uk-20190304051044-vph4s8p9qvpy2qe9
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
142
142
            if target_repo._git.refs.get(ref_name) == unpeeled:
143
143
                pass
144
144
            elif overwrite or ref_name not in target_repo._git.refs:
145
 
                target_repo._git.refs[ref_name] = unpeeled or peeled
146
145
                try:
147
146
                    updates[tag_name] = (
148
 
                        self.repository.lookup_foreign_revision_id(peeled))
 
147
                        target_repo.lookup_foreign_revision_id(peeled))
149
148
                except KeyError:
150
149
                    trace.warning('%s does not point to a valid object',
151
150
                                  tag_name)
152
151
                    continue
 
152
                target_repo._git.refs[ref_name] = unpeeled or peeled
153
153
            else:
154
154
                try:
155
155
                    source_revid = self.repository.lookup_foreign_revision_id(
625
625
                self._tag_refs = list(self._iter_tag_refs())
626
626
            return self._tag_refs
627
627
 
 
628
    def import_last_revision_info_and_tags(self, source, revno, revid,
 
629
                                           lossy=False):
 
630
        """Set the last revision info, importing from another repo if necessary.
 
631
 
 
632
        This is used by the bound branch code to upload a revision to
 
633
        the master branch first before updating the tip of the local branch.
 
634
        Revisions referenced by source's tags are also transferred.
 
635
 
 
636
        :param source: Source branch to optionally fetch from
 
637
        :param revno: Revision number of the new tip
 
638
        :param revid: Revision id of the new tip
 
639
        :param lossy: Whether to discard metadata that can not be
 
640
            natively represented
 
641
        :return: Tuple with the new revision number and revision id
 
642
            (should only be different from the arguments when lossy=True)
 
643
        """
 
644
        push_result = source.push(
 
645
            self, stop_revision=revid, lossy=lossy, _stop_revno=revno)
 
646
        return (push_result.new_revno, push_result.new_revid)
 
647
 
 
648
    def reconcile(self, thorough=True):
 
649
        """Make sure the data stored in this branch is consistent."""
 
650
        from ..reconcile import ReconcileResult
 
651
        # Nothing to do here
 
652
        return ReconcileResult()
 
653
 
628
654
 
629
655
class LocalGitBranch(GitBranch):
630
656
    """A local Git branch."""
1221
1247
        return (not isinstance(source, GitBranch) and
1222
1248
                isinstance(target, GitBranch))
1223
1249
 
1224
 
    def _get_new_refs(self, stop_revision=None, fetch_tags=None):
 
1250
    def _get_new_refs(self, stop_revision=None, fetch_tags=None,
 
1251
                      stop_revno=None):
1225
1252
        if not self.source.is_locked():
1226
1253
            raise errors.ObjectNotLocked(self.source)
1227
1254
        if stop_revision is None:
1228
1255
            (stop_revno, stop_revision) = self.source.last_revision_info()
1229
 
        else:
 
1256
        elif stop_revno is None:
1230
1257
            stop_revno = self.source.revision_id_to_revno(stop_revision)
1231
1258
        if not isinstance(stop_revision, bytes):
1232
1259
            raise TypeError(stop_revision)
1318
1345
            raise errors.NoRoundtrippingSupport(self.source, self.target)
1319
1346
 
1320
1347
    def pull(self, overwrite=False, stop_revision=None, local=False,
1321
 
             possible_transports=None, run_hooks=True):
 
1348
             possible_transports=None, run_hooks=True, _stop_revno=None):
1322
1349
        result = GitBranchPullResult()
1323
1350
        result.source_branch = self.source
1324
1351
        result.target_branch = self.target
1325
1352
        with self.source.lock_read(), self.target.lock_write():
1326
1353
            new_refs, main_ref, stop_revinfo = self._get_new_refs(
1327
 
                stop_revision)
 
1354
                stop_revision, stop_revno=_stop_revno)
1328
1355
 
1329
1356
            def update_refs(old_refs):
1330
1357
                return self._update_refs(result, old_refs, new_refs, overwrite)
1347
1374
        return result
1348
1375
 
1349
1376
    def push(self, overwrite=False, stop_revision=None, lossy=False,
1350
 
             _override_hook_source_branch=None):
 
1377
             _override_hook_source_branch=None, _stop_revno=None):
1351
1378
        result = GitBranchPushResult()
1352
1379
        result.source_branch = self.source
1353
1380
        result.target_branch = self.target
1355
1382
        result.master_branch = result.target_branch
1356
1383
        with self.source.lock_read(), self.target.lock_write():
1357
1384
            new_refs, main_ref, stop_revinfo = self._get_new_refs(
1358
 
                stop_revision)
 
1385
                stop_revision, stop_revno=_stop_revno)
1359
1386
 
1360
1387
            def update_refs(old_refs):
1361
1388
                return self._update_refs(result, old_refs, new_refs, overwrite)