~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to cbranch.py

  • Committer: Aaron Bentley
  • Date: 2006-06-18 01:24:25 UTC
  • mfrom: (0.3.3 shelf-dev)
  • Revision ID: aaron.bentley@utoronto.ca-20060618012425-61c3d9d62a2cc971
Merged the latest Shelf changes, patches.py no longer needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2006 Aaron Bentley
 
2
# <aaron.bentley@utoronto.ca>
 
3
#
 
4
#    This program is free software; you can redistribute it and/or modify
 
5
#    it under the terms of the GNU General Public License as published by
 
6
#    the Free Software Foundation; either version 2 of the License, or
 
7
#    (at your option) any later version.
 
8
#
 
9
#    This program is distributed in the hope that it will be useful,
 
10
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
#    GNU General Public License for more details.
 
13
#
 
14
#    You should have received a copy of the GNU General Public License
 
15
#    along with this program; if not, write to the Free Software
 
16
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
17
 
 
18
from bzrlib.builtins import cmd_branch, cmd_checkout
 
19
from bzrlib.config import LocationConfig
 
20
from bzrlib.errors import BzrCommandError
 
21
from bzrlib.osutils import pathjoin, basename, abspath, getcwd
 
22
 
 
23
def cbranch(from_location, to_location=None, revision=None, lightweight=False):
 
24
    from_location = from_location.rstrip('/')
 
25
    if to_location is None:
 
26
        to_location = pathjoin(getcwd(), basename(from_location))
 
27
    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))
 
32
    cmd_branch().run(from_location, b_loc, revision=revision)
 
33
    cmd_checkout().run(b_loc, to_location, lightweight=lightweight)