~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to cbranch.py

  • Committer: Aaron Bentley
  • Date: 2007-06-12 15:52:05 UTC
  • mfrom: (535.1.1 bzrtools)
  • Revision ID: abentley@panoramicfeedback.com-20070612155205-ssbl678bfz266ptb
Merge fix for symlinks in directories

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
#    along with this program; if not, write to the Free Software
16
16
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
17
 
 
18
from bzrlib.branch import Branch
18
19
from bzrlib.builtins import cmd_branch, cmd_checkout
19
20
from bzrlib.config import LocationConfig
20
21
from bzrlib.errors import BzrCommandError
21
22
from bzrlib.osutils import pathjoin, basename, abspath, getcwd
 
23
from bzrlib.urlutils import local_path_to_url
22
24
 
23
 
def cbranch(from_location, to_location=None, revision=None, lightweight=False):
 
25
def cbranch(from_location, to_location=None, revision=None,
 
26
            lightweight=False):
24
27
    from_location = from_location.rstrip('/')
25
28
    if to_location is None:
26
29
        to_location = pathjoin(getcwd(), basename(from_location))
27
30
    config = LocationConfig(abspath(to_location))
28
 
    b_root = config.get_user_option("cbranch_root")
29
 
    if b_root is None:
30
 
        raise BzrCommandError("Can't find cbranch_root in branches.conf")
31
 
    b_loc = pathjoin(b_root, basename(to_location))
 
31
    b_loc = config.get_user_option("cbranch_target")
 
32
    if b_loc is None:
 
33
        b_root = config.get_user_option("cbranch_root")
 
34
        if b_root is None:
 
35
            raise BzrCommandError("Can't find cbranch_target in"
 
36
                                  " locations.conf")
 
37
        b_loc = pathjoin(b_root, basename(to_location))
32
38
    cmd_branch().run(from_location, b_loc, revision=revision)
33
39
    cmd_checkout().run(b_loc, to_location, lightweight=lightweight)
 
40
    b = Branch.open(to_location)