/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/controldir.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:
129
129
        """
130
130
        return list(self.get_branches().values())
131
131
 
132
 
    def branch_names(self):
133
 
        """List all branch names in this control directory.
134
 
 
135
 
        :return: List of branch names
136
 
        """
137
 
        try:
138
 
            self.get_branch_reference()
139
 
        except (errors.NotBranchError, errors.NoRepositoryPresent):
140
 
            return []
141
 
        else:
142
 
            return [""]
143
 
 
144
132
    def get_branches(self):
145
133
        """Get all branches in this control directory, as a dictionary.
146
134
 
412
400
        raise NotImplementedError(self.sprout)
413
401
 
414
402
    def push_branch(self, source, revision_id=None, overwrite=False,
415
 
                    remember=False, create_prefix=False, lossy=False,
416
 
                    tag_selector=None):
 
403
                    remember=False, create_prefix=False, lossy=False):
417
404
        """Push the source branch into this ControlDir."""
418
405
        br_to = None
419
406
        # If we can open a branch, use its direct repository, otherwise see
437
424
                # revision
438
425
                revision_id = source.last_revision()
439
426
            repository_to.fetch(source.repository, revision_id=revision_id)
440
 
            br_to = source.sprout(
441
 
                self, revision_id=revision_id, lossy=lossy,
442
 
                tag_selector=tag_selector)
 
427
            br_to = source.sprout(self, revision_id=revision_id, lossy=lossy)
443
428
            if source.get_push_location() is None or remember:
444
429
                # FIXME: Should be done only if we succeed ? -- vila 2012-01-18
445
430
                source.set_push_location(br_to.base)
458
443
            try:
459
444
                tree_to = self.open_workingtree()
460
445
            except errors.NotLocalUrl:
461
 
                push_result.branch_push_result = source.push(
462
 
                    br_to, overwrite, stop_revision=revision_id, lossy=lossy,
463
 
                    tag_selector=tag_selector)
 
446
                push_result.branch_push_result = source.push(br_to,
 
447
                                                             overwrite, stop_revision=revision_id, lossy=lossy)
464
448
                push_result.workingtree_updated = False
465
449
            except errors.NoWorkingTree:
466
 
                push_result.branch_push_result = source.push(
467
 
                    br_to, overwrite, stop_revision=revision_id, lossy=lossy,
468
 
                    tag_selector=tag_selector)
 
450
                push_result.branch_push_result = source.push(br_to,
 
451
                                                             overwrite, stop_revision=revision_id, lossy=lossy)
469
452
                push_result.workingtree_updated = None  # Not applicable
470
453
            else:
471
454
                with tree_to.lock_write():
472
455
                    push_result.branch_push_result = source.push(
473
456
                        tree_to.branch, overwrite, stop_revision=revision_id,
474
 
                        lossy=lossy, tag_selector=tag_selector)
 
457
                        lossy=lossy)
475
458
                    tree_to.update()
476
459
                push_result.workingtree_updated = True
477
460
            push_result.old_revno = push_result.branch_push_result.old_revno
510
493
        raise NotImplementedError(self.check_conversion_target)
511
494
 
512
495
    def clone(self, url, revision_id=None, force_new_repo=False,
513
 
              preserve_stacking=False, tag_selector=None):
 
496
              preserve_stacking=False):
514
497
        """Clone this controldir and its contents to url verbatim.
515
498
 
516
499
        :param url: The url create the clone at.  If url's last component does
526
509
        return self.clone_on_transport(_mod_transport.get_transport(url),
527
510
                                       revision_id=revision_id,
528
511
                                       force_new_repo=force_new_repo,
529
 
                                       preserve_stacking=preserve_stacking,
530
 
                                       tag_selector=tag_selector)
 
512
                                       preserve_stacking=preserve_stacking)
531
513
 
532
514
    def clone_on_transport(self, transport, revision_id=None,
533
515
                           force_new_repo=False, preserve_stacking=False, stacked_on=None,
534
 
                           create_prefix=False, use_existing_dir=True, no_tree=False,
535
 
                           tag_selector=None):
 
516
                           create_prefix=False, use_existing_dir=True, no_tree=False):
536
517
        """Clone this controldir and its contents to transport verbatim.
537
518
 
538
519
        :param transport: The transport for the location to produce the clone
580
561
            recurse = True
581
562
            try:
582
563
                controldir = klass.open_from_transport(current_transport)
583
 
            except (errors.NotBranchError, errors.PermissionDenied,
584
 
                    errors.UnknownFormatError):
 
564
            except (errors.NotBranchError, errors.PermissionDenied):
585
565
                pass
586
566
            else:
587
567
                recurse, value = evaluate(controldir)
808
788
            a_transport = new_t
809
789
 
810
790
    @classmethod
811
 
    def open_tree_or_branch(klass, location, name=None):
 
791
    def open_tree_or_branch(klass, location):
812
792
        """Return the branch and working tree at a location.
813
793
 
814
794
        If there is no tree at the location, tree will be None.
817
797
        :return: (tree, branch)
818
798
        """
819
799
        controldir = klass.open(location)
820
 
        return controldir._get_tree_branch(name=name)
 
800
        return controldir._get_tree_branch()
821
801
 
822
802
    @classmethod
823
803
    def open_containing_tree_or_branch(klass, location,
1047
1027
    _default_format = None
1048
1028
    """The default format used for new control directories."""
1049
1029
 
 
1030
    _server_probers = []
 
1031
    """The registered server format probers, e.g. RemoteBzrProber.
 
1032
 
 
1033
    This is a list of Prober-derived classes.
 
1034
    """
 
1035
 
1050
1036
    _probers = []
1051
1037
    """The registered format probers, e.g. BzrProber.
1052
1038
 
1137
1123
        """
1138
1124
        klass._probers.remove(prober)
1139
1125
 
 
1126
    @classmethod
 
1127
    def register_server_prober(klass, prober):
 
1128
        """Register a control format prober for client-server environments.
 
1129
 
 
1130
        These probers will be used before ones registered with
 
1131
        register_prober.  This gives implementations that decide to the
 
1132
        chance to grab it before anything looks at the contents of the format
 
1133
        file.
 
1134
        """
 
1135
        klass._server_probers.append(prober)
 
1136
 
1140
1137
    def __str__(self):
1141
1138
        # Trim the newline
1142
1139
        return self.get_format_description().rstrip()
1143
1140
 
1144
1141
    @classmethod
1145
1142
    def all_probers(klass):
1146
 
        return klass._probers
 
1143
        return klass._server_probers + klass._probers
1147
1144
 
1148
1145
    @classmethod
1149
1146
    def known_formats(klass):
1158
1155
    def find_format(klass, transport, probers=None):
1159
1156
        """Return the format present at transport."""
1160
1157
        if probers is None:
1161
 
            probers = sorted(
1162
 
                klass.all_probers(),
1163
 
                key=lambda prober: prober.priority(transport))
 
1158
            probers = klass.all_probers()
1164
1159
        for prober_kls in probers:
1165
1160
            prober = prober_kls()
1166
1161
            try:
1280
1275
    probers that detect .bzr/ directories and Bazaar smart servers,
1281
1276
    respectively.
1282
1277
 
1283
 
    Probers should be registered using the register_prober methods on
1284
 
    ControlDirFormat.
 
1278
    Probers should be registered using the register_server_prober or
 
1279
    register_prober methods on ControlDirFormat.
1285
1280
    """
1286
1281
 
1287
1282
    def probe_transport(self, transport):
1305
1300
        """
1306
1301
        raise NotImplementedError(klass.known_formats)
1307
1302
 
1308
 
    @classmethod
1309
 
    def priority(klass, transport):
1310
 
        """Priority of this prober.
1311
 
 
1312
 
        A lower value means the prober gets checked first.
1313
 
 
1314
 
        Other conventions:
1315
 
 
1316
 
        -10: This is a "server" prober
1317
 
        0: No priority set
1318
 
        10: This is a regular file-based prober
1319
 
        100: This is a prober for an unsupported format
1320
 
        """
1321
 
        return 0
1322
 
 
1323
1303
 
1324
1304
class ControlDirFormatInfo(object):
1325
1305