/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: 2018-09-25 01:18:22 UTC
  • mto: This revision was merged to the branch mainline in revision 7183.
  • Revision ID: jelmer@jelmer.uk-20180925011822-7uyk3qhi00l6ibpb
Fix committing to a bzr branch bound to a git branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
391
391
 
392
392
        :return: Branch nick
393
393
        """
394
 
        cs = self.repository._git.get_config_stack()
395
 
        try:
396
 
            return cs.get((b"branch", self.name.encode('utf-8')), b"nick").decode("utf-8")
397
 
        except KeyError:
398
 
            pass
 
394
        if getattr(self.repository, '_git', None):
 
395
            cs = self.repository._git.get_config_stack()
 
396
            try:
 
397
                return cs.get((b"branch", self.name.encode('utf-8')), b"nick").decode("utf-8")
 
398
            except KeyError:
 
399
                pass
399
400
        return self.name or u"HEAD"
400
401
 
401
402
    def _set_nick(self, nick):
575
576
                self._tag_refs = list(self._iter_tag_refs())
576
577
            return self._tag_refs
577
578
 
 
579
    def import_last_revision_info_and_tags(self, source, revno, revid,
 
580
                                           lossy=False):
 
581
        """Set the last revision info, importing from another repo if necessary.
 
582
 
 
583
        This is used by the bound branch code to upload a revision to
 
584
        the master branch first before updating the tip of the local branch.
 
585
        Revisions referenced by source's tags are also transferred.
 
586
 
 
587
        :param source: Source branch to optionally fetch from
 
588
        :param revno: Revision number of the new tip
 
589
        :param revid: Revision id of the new tip
 
590
        :param lossy: Whether to discard metadata that can not be
 
591
            natively represented
 
592
        :return: Tuple with the new revision number and revision id
 
593
            (should only be different from the arguments when lossy=True)
 
594
        """
 
595
        source.push(self, stop_revision=revid, lossy=lossy, _stop_revno=revno)
 
596
        return (revno, revid)
 
597
 
578
598
 
579
599
class LocalGitBranch(GitBranch):
580
600
    """A local Git branch."""
1148
1168
        return (not isinstance(source, GitBranch) and
1149
1169
                isinstance(target, GitBranch))
1150
1170
 
1151
 
    def _get_new_refs(self, stop_revision=None, fetch_tags=None):
 
1171
    def _get_new_refs(self, stop_revision=None, fetch_tags=None,
 
1172
                      stop_revno=None):
1152
1173
        if not self.source.is_locked():
1153
1174
            raise errors.ObjectNotLocked(self.source)
1154
1175
        if stop_revision is None:
1155
1176
            (stop_revno, stop_revision) = self.source.last_revision_info()
1156
 
        else:
 
1177
        elif stop_revno is None:
1157
1178
            stop_revno = self.source.revision_id_to_revno(stop_revision)
1158
1179
        if not isinstance(stop_revision, bytes):
1159
1180
            raise TypeError(stop_revision)
1242
1263
            raise errors.NoRoundtrippingSupport(self.source, self.target)
1243
1264
 
1244
1265
    def pull(self, overwrite=False, stop_revision=None, local=False,
1245
 
             possible_transports=None, run_hooks=True):
 
1266
             possible_transports=None, run_hooks=True, _stop_revno=None):
1246
1267
        result = GitBranchPullResult()
1247
1268
        result.source_branch = self.source
1248
1269
        result.target_branch = self.target
1249
1270
        with self.source.lock_read(), self.target.lock_write():
1250
1271
            new_refs, main_ref, stop_revinfo = self._get_new_refs(
1251
 
                stop_revision)
 
1272
                stop_revision, stop_revno=_stop_revno)
1252
1273
            def update_refs(old_refs):
1253
1274
                return self._update_refs(result, old_refs, new_refs, overwrite)
1254
1275
            try:
1268
1289
        return result
1269
1290
 
1270
1291
    def push(self, overwrite=False, stop_revision=None, lossy=False,
1271
 
             _override_hook_source_branch=None):
 
1292
             _override_hook_source_branch=None, _stop_revno=None):
1272
1293
        result = GitBranchPushResult()
1273
1294
        result.source_branch = self.source
1274
1295
        result.target_branch = self.target
1275
1296
        result.local_branch = None
1276
1297
        result.master_branch = result.target_branch
1277
1298
        with self.source.lock_read(), self.target.lock_write():
1278
 
            new_refs, main_ref, stop_revinfo = self._get_new_refs(stop_revision)
 
1299
            new_refs, main_ref, stop_revinfo = self._get_new_refs(stop_revision, stop_revno=_stop_revno)
1279
1300
            def update_refs(old_refs):
1280
1301
                return self._update_refs(result, old_refs, new_refs, overwrite)
1281
1302
            try: