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
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
from bzrlib.osutils import pathjoin, basename, abspath
22
from bzrlib.osutils import pathjoin, basename, abspath, getcwd
23
from bzrlib.urlutils import local_path_to_url
23
def cbranch(from_location, to_location, revision=None):
25
def cbranch(from_location, to_location=None, revision=None, lightweight=False):
26
from_location = from_location.rstrip('/')
27
if to_location is None:
28
to_location = pathjoin(getcwd(), basename(from_location))
24
29
config = LocationConfig(abspath(to_location))
25
30
b_root = config.get_user_option("cbranch_root")
27
32
raise BzrCommandError("Can't find cbranch_root in branches.conf")
28
33
b_loc = pathjoin(b_root, basename(to_location))
29
34
cmd_branch().run(from_location, b_loc, revision=revision)
30
cmd_checkout().run(b_loc, to_location, lightweight=True)
35
cmd_checkout().run(b_loc, to_location, lightweight=lightweight)
36
b = Branch.open(to_location)