~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/foreign.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-08-17 18:13:57 UTC
  • mfrom: (5268.7.29 transport-segments)
  • Revision ID: pqm@pqm.ubuntu.com-20110817181357-y5q5eth1hk8bl3om
(jelmer) Allow specifying the colocated branch to use in the branch URL,
 and retrieving the branch name using ControlDir._get_selected_branch.
 (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008-2012 Canonical Ltd
 
1
# Copyright (C) 2008-2011 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
 
17
 
17
18
"""Foreign branch utilities."""
18
19
 
19
 
from __future__ import absolute_import
20
 
 
21
20
 
22
21
from bzrlib.branch import (
23
22
    Branch,
32
31
    registry,
33
32
    transform,
34
33
    )
35
 
from bzrlib.i18n import gettext
36
34
""")
37
35
 
38
36
class VcsMapping(object):
265
263
    branch unless the --no-rebase option is used, in which case 
266
264
    the two branches will be out of sync after the push. 
267
265
    """
 
266
    hidden = True
268
267
    takes_args = ['location?']
269
268
    takes_options = [
270
269
        'remember',
283
282
    def run(self, location=None, remember=False, directory=None,
284
283
            no_rebase=False, strict=None):
285
284
        from bzrlib import urlutils
286
 
        from bzrlib.controldir import ControlDir
 
285
        from bzrlib.bzrdir import BzrDir
287
286
        from bzrlib.errors import BzrCommandError, NoWorkingTree
288
287
        from bzrlib.workingtree import WorkingTree
289
288
 
303
302
        stored_loc = source_branch.get_push_location()
304
303
        if location is None:
305
304
            if stored_loc is None:
306
 
                raise BzrCommandError(gettext("No push location known or specified."))
 
305
                raise BzrCommandError("No push location known or specified.")
307
306
            else:
308
307
                display_url = urlutils.unescape_for_display(stored_loc,
309
308
                        self.outf.encoding)
310
 
                self.outf.write(
311
 
                       gettext("Using saved location: %s\n") % display_url)
 
309
                self.outf.write("Using saved location: %s\n" % display_url)
312
310
                location = stored_loc
313
311
 
314
 
        controldir = ControlDir.open(location)
315
 
        target_branch = controldir.open_branch()
 
312
        bzrdir = BzrDir.open(location)
 
313
        target_branch = bzrdir.open_branch()
316
314
        target_branch.lock_write()
317
315
        try:
318
316
            try:
319
317
                push_result = source_branch.push(target_branch, lossy=True)
320
318
            except errors.LossyPushToSameVCS:
321
 
                raise BzrCommandError(gettext("{0!r} and {1!r} are in the same VCS, lossy "
322
 
                    "push not necessary. Please use regular push.").format(
323
 
                    source_branch, target_branch))
 
319
                raise BzrCommandError("%r and %r are in the same VCS, lossy "
 
320
                    "push not necessary. Please use regular push." %
 
321
                    (source_branch, target_branch))
324
322
            # We successfully created the target, remember it
325
323
            if source_branch.get_push_location() is None or remember:
326
 
                # FIXME: Should be done only if we succeed ? -- vila 2012-01-18
327
324
                source_branch.set_push_location(target_branch.base)
328
325
            if not no_rebase:
329
326
                old_last_revid = source_branch.last_revision()