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

  • Committer: Aaron Bentley
  • Date: 2007-04-02 17:18:11 UTC
  • mfrom: (2392 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2393.
  • Revision ID: abentley@panoramicfeedback.com-20070402171811-bz7y2b2h1m1k4n7x
Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
58
58
                                      deprecated_method,
59
59
                                      DEPRECATED_PARAMETER,
60
60
                                      deprecated_passed,
61
 
                                      zero_eight, zero_nine,
 
61
                                      zero_eight, zero_nine, zero_sixteen,
62
62
                                      )
63
63
from bzrlib.trace import mutter, note
64
64
 
297
297
            raise InvalidRevisionNumber(revno)
298
298
        return self.repository.get_revision_delta(rh[revno-1])
299
299
 
 
300
    @deprecated_method(zero_sixteen)
300
301
    def get_root_id(self):
301
 
        """Return the id of this branches root"""
 
302
        """Return the id of this branches root
 
303
 
 
304
        Deprecated: branches don't have root ids-- trees do.
 
305
        Use basis_tree().get_root_id() instead.
 
306
        """
302
307
        raise NotImplementedError(self.get_root_id)
303
308
 
304
309
    def print_file(self, file, revision_id):
591
596
            raise InvalidRevisionNumber(revno)
592
597
 
593
598
    @needs_read_lock
594
 
    def clone(self, *args, **kwargs):
 
599
    def clone(self, to_bzrdir, revision_id=None):
595
600
        """Clone this branch into to_bzrdir preserving all semantic values.
596
601
        
597
602
        revision_id: if not None, the revision history in the new branch will
598
603
                     be truncated to end with revision_id.
599
604
        """
600
 
        # for API compatibility, until 0.8 releases we provide the old api:
601
 
        # def clone(self, to_location, revision=None, basis_branch=None, to_branch_format=None):
602
 
        # after 0.8 releases, the *args and **kwargs should be changed:
603
 
        # def clone(self, to_bzrdir, revision_id=None):
604
 
        if (kwargs.get('to_location', None) or
605
 
            kwargs.get('revision', None) or
606
 
            kwargs.get('basis_branch', None) or
607
 
            (len(args) and isinstance(args[0], basestring))):
608
 
            # backwards compatibility api:
609
 
            warn("Branch.clone() has been deprecated for BzrDir.clone() from"
610
 
                 " bzrlib 0.8.", DeprecationWarning, stacklevel=3)
611
 
            # get basis_branch
612
 
            if len(args) > 2:
613
 
                basis_branch = args[2]
614
 
            else:
615
 
                basis_branch = kwargs.get('basis_branch', None)
616
 
            if basis_branch:
617
 
                basis = basis_branch.bzrdir
618
 
            else:
619
 
                basis = None
620
 
            # get revision
621
 
            if len(args) > 1:
622
 
                revision_id = args[1]
623
 
            else:
624
 
                revision_id = kwargs.get('revision', None)
625
 
            # get location
626
 
            if len(args):
627
 
                url = args[0]
628
 
            else:
629
 
                # no default to raise if not provided.
630
 
                url = kwargs.get('to_location')
631
 
            return self.bzrdir.clone(url,
632
 
                                     revision_id=revision_id,
633
 
                                     basis=basis).open_branch()
634
 
        # new cleaner api.
635
 
        # generate args by hand 
636
 
        if len(args) > 1:
637
 
            revision_id = args[1]
638
 
        else:
639
 
            revision_id = kwargs.get('revision_id', None)
640
 
        if len(args):
641
 
            to_bzrdir = args[0]
642
 
        else:
643
 
            # no default to raise if not provided.
644
 
            to_bzrdir = kwargs.get('to_bzrdir')
645
605
        result = self._format.initialize(to_bzrdir)
646
606
        self.copy_content_into(result, revision_id=revision_id)
647
607
        return  result
1231
1191
    it's writable, and can be accessed via the normal filesystem API.
1232
1192
    """
1233
1193
    
1234
 
    def __init__(self, transport=DEPRECATED_PARAMETER, init=DEPRECATED_PARAMETER,
1235
 
                 relax_version_check=DEPRECATED_PARAMETER, _format=None,
 
1194
    def __init__(self, _format=None,
1236
1195
                 _control_files=None, a_bzrdir=None, _repository=None):
1237
 
        """Create new branch object at a particular location.
1238
 
 
1239
 
        transport -- A Transport object, defining how to access files.
1240
 
        
1241
 
        init -- If True, create new control files in a previously
1242
 
             unversioned directory.  If False, the branch must already
1243
 
             be versioned.
1244
 
 
1245
 
        relax_version_check -- If true, the usual check for the branch
1246
 
            version is not applied.  This is intended only for
1247
 
            upgrade/recovery type use; it's not guaranteed that
1248
 
            all operations will work on old format branches.
1249
 
        """
 
1196
        """Create new branch object at a particular location."""
1250
1197
        Branch.__init__(self)
1251
1198
        if a_bzrdir is None:
1252
 
            self.bzrdir = bzrdir.BzrDir.open(transport.base)
 
1199
            raise ValueError('a_bzrdir must be supplied')
1253
1200
        else:
1254
1201
            self.bzrdir = a_bzrdir
1255
1202
        # self._transport used to point to the directory containing the
1261
1208
            raise ValueError('BzrBranch _control_files is None')
1262
1209
        self.control_files = _control_files
1263
1210
        self._transport = _control_files._transport
1264
 
        if deprecated_passed(init):
1265
 
            warn("BzrBranch.__init__(..., init=XXX): The init parameter is "
1266
 
                 "deprecated as of bzr 0.8. Please use Branch.create().",
1267
 
                 DeprecationWarning,
1268
 
                 stacklevel=2)
1269
 
            if init:
1270
 
                # this is slower than before deprecation, oh well never mind.
1271
 
                # -> its deprecated.
1272
 
                self._initialize(transport.base)
1273
 
        self._check_format(_format)
1274
 
        if deprecated_passed(relax_version_check):
1275
 
            warn("BzrBranch.__init__(..., relax_version_check=XXX_: The "
1276
 
                 "relax_version_check parameter is deprecated as of bzr 0.8. "
1277
 
                 "Please use BzrDir.open_downlevel, or a BzrBranchFormat's "
1278
 
                 "open() method.",
1279
 
                 DeprecationWarning,
1280
 
                 stacklevel=2)
1281
 
            if (not relax_version_check
1282
 
                and not self._format.is_supported()):
1283
 
                raise errors.UnsupportedFormatError(format=fmt)
1284
 
        if deprecated_passed(transport):
1285
 
            warn("BzrBranch.__init__(transport=XXX...): The transport "
1286
 
                 "parameter is deprecated as of bzr 0.8. "
1287
 
                 "Please use Branch.open, or bzrdir.open_branch().",
1288
 
                 DeprecationWarning,
1289
 
                 stacklevel=2)
1290
1211
        self.repository = _repository
1291
1212
 
1292
1213
    def __str__(self):
1304
1225
        """See Branch.abspath."""
1305
1226
        return self.control_files._transport.abspath(name)
1306
1227
 
1307
 
    def _check_format(self, format):
1308
 
        """Identify the branch format if needed.
1309
 
 
1310
 
        The format is stored as a reference to the format object in
1311
 
        self._format for code that needs to check it later.
1312
 
 
1313
 
        The format parameter is either None or the branch format class
1314
 
        used to open this branch.
1315
 
 
1316
 
        FIXME: DELETE THIS METHOD when pre 0.8 support is removed.
1317
 
        """
1318
 
        if format is None:
1319
 
            format = BranchFormat.find_format(self.bzrdir)
1320
 
        self._format = format
1321
 
        mutter("got branch format %s", self._format)
1322
 
 
 
1228
 
 
1229
    @deprecated_method(zero_sixteen)
1323
1230
    @needs_read_lock
1324
1231
    def get_root_id(self):
1325
1232
        """See Branch.get_root_id."""