~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: John Arbash Meinel
  • Date: 2005-11-12 19:55:34 UTC
  • mto: (1587.1.6 bound-branches)
  • mto: This revision was merged to the branch mainline in revision 1590.
  • Revision ID: john@arbash-meinel.com-20051112195534-3e33d6225502834b
(broken) working on implementing bound branches.

Show diffs side-by-side

added added

removed removed

Lines of Context:
484
484
    branch before copying anything from the remote branch.
485
485
    """
486
486
    takes_args = ['from_location', 'to_location?']
487
 
    takes_options = ['revision', 'basis']
 
487
    takes_options = ['revision', 'basis', 'bound', 'unbound']
488
488
    aliases = ['get', 'clone']
489
489
 
490
 
    def run(self, from_location, to_location=None, revision=None, basis=None):
 
490
    def run(self, from_location, to_location=None, revision=None, basis=None,
 
491
            bound=False, unbound=False):
491
492
        from bzrlib.clone import copy_branch
492
493
        import errno
493
494
        from shutil import rmtree
496
497
        elif len(revision) > 1:
497
498
            raise BzrCommandError(
498
499
                'bzr branch --revision takes exactly 1 revision value')
 
500
        if bound and unbound:
 
501
            raise BzrCommandError('Cannot supply both bound and unbound at the same time')
499
502
        try:
500
503
            br_from = Branch.open(from_location)
501
504
        except OSError, e:
538
541
                raise BzrCommandError(msg)
539
542
            except bzrlib.errors.UnlistableBranch:
540
543
                rmtree(to_location)
541
 
                msg = "The branch %s cannot be used as a --basis"
 
544
                msg = "The branch %s cannot be used as a --basis" % (basis,)
542
545
                raise BzrCommandError(msg)
 
546
            branch = Branch.open(to_location)
543
547
            if name:
544
 
                branch = Branch.open(to_location)
545
548
                name = StringIO(name)
546
549
                branch.put_controlfile('branch-name', name)
 
550
            if bound:
 
551
                branch.bind(br_from.base)
547
552
        finally:
548
553
            br_from.unlock()
549
554
 
1732
1737
            else:
1733
1738
                raise BzrCommandError('Please supply either one revision, or a range.')
1734
1739
 
 
1740
class cmd_bind(Command):
 
1741
    """Bind the current branch to its parent.
 
1742
 
 
1743
    After binding, commits must succeed on the parent branch
 
1744
    before they can be done on the local one.
 
1745
    """
 
1746
 
 
1747
    takes_args = ['location?']
 
1748
    takes_options = []
 
1749
 
 
1750
    def run(self, location=None):
 
1751
        b = Branch.open_containing('.')
 
1752
        if location is None:
 
1753
            location = b.get_parent()
 
1754
        if location is None:
 
1755
            raise BzrCommandError('Branch has no parent,'
 
1756
                                  ' you must supply a bind location.')
 
1757
        b_other = Branch.open(location)
 
1758
        b.bind(b_other)
 
1759
 
 
1760
class cmd_unbind(Command):
 
1761
    """Bind the current branch to its parent.
 
1762
 
 
1763
    After unbinding, the local branch is considered independent.
 
1764
    """
 
1765
 
 
1766
    takes_args = []
 
1767
    takes_options = []
 
1768
 
 
1769
    def run(self):
 
1770
        b = Branch.open_containing('.')
 
1771
        b.unbind()
1735
1772
 
1736
1773
# these get imported and then picked up by the scan for cmd_*
1737
1774
# TODO: Some more consistent way to split command definitions across files;