~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/switch.py

  • Committer: Vincent Ladeuil
  • Date: 2008-12-04 17:12:46 UTC
  • mto: (3902.1.1 bzr.integration)
  • mto: This revision was merged to the branch mainline in revision 3903.
  • Revision ID: v.ladeuil+lp@free.fr-20081204171246-p28b3u0e2alz53iv
Fix bug #270863 by preserving 'bzr+http[s]' decorator.

* bzrlib/transport/remote.py:
(RemoteHTTPTransport._redirected_to): Specific implementation to
handle the redirections.

* bzrlib/transport/http/_urllib.py:
(HttpTransport_urllib.__init__): Fix parameter order.

* bzrlib/transport/http/_pycurl.py:
(PyCurlTransport.__init__): Fix parameter order.

* bzrlib/transport/http/__init__.py:
(HttpTransportBase.external_url): Semi drive-by fix, external_url
shouldn't expose the implementation qualifier (it's private to bzr
not externally usable).

* bzrlib/transport/decorator.py:
(TransportDecorator._redirected_to): Cleanup.

* bzrlib/tests/test_smart_transport.py:
(RemoteHTTPTransportTestCase): Add specific tests for
_redirected_to.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
# Original author: David Allouche
18
18
 
22
22
from bzrlib.trace import note
23
23
 
24
24
 
25
 
def switch(control_dir, to_branch, force=False, quiet=False):
 
25
def switch(control_dir, to_branch, force=False):
26
26
    """Switch the branch associated with a checkout.
27
27
 
28
28
    :param control_dir: BzrDir of the checkout to change
36
36
        source_repository = to_branch.repository
37
37
    _set_branch_location(control_dir, to_branch, force)
38
38
    tree = control_dir.open_workingtree()
39
 
    _update(tree, source_repository, quiet)
 
39
    _update(tree, source_repository)
40
40
 
41
41
 
42
42
def _check_pending_merges(control, force=False):
79
79
            # synchronise the local branch with the new remote branch
80
80
            # and bind to it
81
81
            possible_transports = []
82
 
            try:
83
 
                if not force and _any_local_commits(b, possible_transports):
84
 
                    raise errors.BzrCommandError(
85
 
                        'Cannot switch as local commits found in the checkout. '
86
 
                        'Commit these to the bound branch or use --force to '
87
 
                        'throw them away.')
88
 
            except errors.BoundBranchConnectionFailure, e:
 
82
            if not force and _any_local_commits(b, possible_transports):
89
83
                raise errors.BzrCommandError(
90
 
                        'Unable to connect to current master branch %(target)s: '
91
 
                        '%(error)s To switch anyway, use --force.' %
92
 
                        e.__dict__)
 
84
                    'Cannot switch as local commits found in the checkout. '
 
85
                    'Commit these to the bound branch or use --force to '
 
86
                    'throw them away.')
93
87
            b.set_bound_location(None)
94
88
            b.pull(to_branch, overwrite=True,
95
89
                possible_transports=possible_transports)
118
112
    return False
119
113
 
120
114
 
121
 
def _update(tree, source_repository, quiet=False):
 
115
def _update(tree, source_repository):
122
116
    """Update a working tree to the latest revision of its branch.
123
117
 
124
118
    :param tree: the working tree
128
122
    try:
129
123
        to_branch = tree.branch
130
124
        if tree.last_revision() == to_branch.last_revision():
131
 
            if not quiet:
132
 
                note("Tree is up to date at revision %d.", to_branch.revno())
 
125
            note("Tree is up to date at revision %d.", to_branch.revno())
133
126
            return
134
127
        base_tree = source_repository.revision_tree(tree.last_revision())
135
128
        merge.Merge3Merger(tree, tree, base_tree, to_branch.basis_tree())
136
129
        tree.set_last_revision(to_branch.last_revision())
137
 
        if not quiet:
138
 
            note('Updated to revision %d.' % to_branch.revno())
 
130
        note('Updated to revision %d.' % to_branch.revno())
139
131
    finally:
140
132
        tree.unlock()