~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Aaron Bentley
  • Date: 2005-09-25 05:01:17 UTC
  • mto: (1185.14.1) (1393.1.21)
  • mto: This revision was merged to the branch mainline in revision 1391.
  • Revision ID: aaron.bentley@utoronto.ca-20050925050117-dc4b46505adfc0d7
Added --basis option to bzr branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
374
374
    parameter, as in "branch foo/bar -r 5".
375
375
    """
376
376
    takes_args = ['from_location', 'to_location?']
377
 
    takes_options = ['revision']
 
377
    takes_options = ['revision', 'basis']
378
378
    aliases = ['get', 'clone']
379
379
 
380
 
    def run(self, from_location, to_location=None, revision=None):
 
380
    def run(self, from_location, to_location=None, revision=None, basis=None):
381
381
        from bzrlib.branch import copy_branch
382
382
        import tempfile
383
383
        import errno
398
398
                else:
399
399
                    raise
400
400
            br_from.setup_caching(cache_root)
 
401
            if basis is not None:
 
402
                basis_branch = Branch.open_containing(basis)
 
403
            else:
 
404
                basis_branch = None
401
405
            if len(revision) == 1 and revision[0] is not None:
402
406
                revno = revision[0].in_history(br_from)[0]
403
407
            else:
416
420
                else:
417
421
                    raise
418
422
            try:
419
 
                copy_branch(br_from, to_location, revno)
 
423
                copy_branch(br_from, to_location, revno, basis_branch)
420
424
            except bzrlib.errors.NoSuchRevision:
421
425
                rmtree(to_location)
422
426
                msg = "The branch %s has no revision %d." % (from_location, revision[0])
423
427
                raise BzrCommandError(msg)
 
428
            except bzrlib.errors.UnlistableBranch:
 
429
                msg = "The branch %s cannot be used as a --basis"
424
430
        finally:
425
431
            rmtree(cache_root)
426
432