~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/push.py

  • Committer: Andrew Bennetts
  • Date: 2009-07-27 08:02:52 UTC
  • mto: This revision was merged to the branch mainline in revision 4573.
  • Revision ID: andrew.bennetts@canonical.com-20090727080252-1r4s9oqwlkzgywx7
Fix trivial bug in _vfs_set_tags_bytes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008, 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2008 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
17
17
"""UI helper for the push command."""
18
18
 
19
19
from bzrlib import (
 
20
    builtins,
 
21
    branch,
20
22
    bzrdir,
21
23
    errors,
22
24
    revision as _mod_revision,
57
59
 
58
60
def _show_push_branch(br_from, revision_id, location, to_file, verbose=False,
59
61
    overwrite=False, remember=False, stacked_on=None, create_prefix=False,
60
 
    use_existing_dir=False, no_tree=False):
 
62
    use_existing_dir=False):
61
63
    """Push a branch to a location.
62
64
 
63
65
    :param br_from: the source branch
87
89
        try:
88
90
            br_to = br_from.create_clone_on_transport(to_transport,
89
91
                revision_id=revision_id, stacked_on=stacked_on,
90
 
                create_prefix=create_prefix, use_existing_dir=use_existing_dir,
91
 
                no_tree=no_tree)
92
 
        except errors.FileExists, err:
93
 
            if err.path.endswith('/.bzr'):
94
 
                raise errors.BzrCommandError(
95
 
                    "Target directory %s already contains a .bzr directory, "
96
 
                    "but it is not valid." % (location,))
 
92
                create_prefix=create_prefix, use_existing_dir=use_existing_dir)
 
93
        except errors.FileExists:
97
94
            if not use_existing_dir:
98
95
                raise errors.BzrCommandError("Target directory %s"
99
 
                     " already exists, but does not have a .bzr"
 
96
                     " already exists, but does not have a valid .bzr"
100
97
                     " directory. Supply --use-existing-dir to push"
101
98
                     " there anyway." % location)
102
 
            # This shouldn't occur, but if it does the FileExists error will be
103
 
            # more informative than an UnboundLocalError for br_to.
104
 
            raise
105
99
        except errors.NoSuchFile:
106
100
            if not create_prefix:
107
101
                raise errors.BzrCommandError("Parent directory of %s"
109
103
                    "\nYou may supply --create-prefix to create all"
110
104
                    " leading parent directories."
111
105
                    % location)
112
 
            # This shouldn't occur (because create_prefix is true, so
113
 
            # create_clone_on_transport should be catching NoSuchFile and
114
 
            # creating the missing directories) but if it does the original
115
 
            # NoSuchFile error will be more informative than an
116
 
            # UnboundLocalError for br_to.
117
 
            raise
118
106
        except errors.TooManyRedirections:
119
107
            raise errors.BzrCommandError("Too many redirections trying "
120
108
                                         "to make %s." % location)
129
117
        push_result.target_branch = br_to
130
118
        push_result.old_revid = _mod_revision.NULL_REVISION
131
119
        push_result.old_revno = 0
132
 
        # Remembers if asked explicitly or no previous location is set
133
 
        if (remember
134
 
            or (remember is None and br_from.get_push_location() is None)):
 
120
        if br_from.get_push_location() is None or remember:
135
121
            br_from.set_push_location(br_to.base)
136
122
    else:
137
123
        if stacked_on is not None:
144
130
            raise errors.BzrCommandError('These branches have diverged.'
145
131
                                    '  See "bzr help diverged-branches"'
146
132
                                    ' for more information.')
147
 
        except errors.NoRoundtrippingSupport, e:
148
 
            raise errors.BzrCommandError("It is not possible to losslessly "
149
 
                "push to %s. You may want to use dpush instead." % 
150
 
                    e.target_branch.mapping.vcs.abbreviation)
151
133
        except errors.NoRepositoryPresent:
152
134
            # we have a bzrdir but no branch or repository
153
135
            # XXX: Figure out what to do other than complain.