~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bzrdir.py

  • Committer: Robert Collins
  • Date: 2006-02-22 23:02:29 UTC
  • mto: (1570.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 1571.
  • Revision ID: robertc@robertcollins.net-20060222230229-d5e0fb4ab1f46d9a
Add tests for sftp push, and NonLocalTets for BzrDir.create_branch_convenience, before fixing the failure of it to work on non-local urls.

Show diffs side-by-side

added added

removed removed

Lines of Context:
221
221
 
222
222
        The created Branch object is returned.
223
223
        If a working tree cannot be made due to base not being a file:// url,
224
 
        no error is raised.
 
224
        no error is raised unless force_new_tree is True, in which case no 
 
225
        data is created on disk and NotLocalUrl is raised.
225
226
 
226
227
        :param base: The URL to create the branch at.
227
228
        :param force_new_repo: If True a new repository is always created.
228
229
        :param force_new_tree: If True or False force creation of a tree or 
229
230
                               prevent such creation respectively.
230
231
        """
 
232
        if force_new_tree:
 
233
            # check for non local urls
 
234
            t = get_transport(safe_unicode(base))
 
235
            if not isinstance(t, LocalTransport):
 
236
                raise errors.NotLocalUrl(base)
231
237
        bzrdir = BzrDir.create(base)
232
238
        repo = bzrdir._find_or_create_repository(force_new_repo)
233
239
        result = bzrdir.create_branch()
234
240
        if force_new_tree or (repo.make_working_trees() and 
235
241
                              force_new_tree is None):
236
 
            bzrdir.create_workingtree()
 
242
            try:
 
243
                bzrdir.create_workingtree()
 
244
            except errors.NotLocalUrl:
 
245
                pass
237
246
        return result
238
247
        
239
248
    @staticmethod