~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bzrdir.py

  • Committer: John Arbash Meinel
  • Date: 2007-06-28 23:18:09 UTC
  • mfrom: (2562 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2566.
  • Revision ID: john@arbash-meinel.com-20070628231809-pqbt7puoqj8bl07b
[merge] bzr.dev 2562

Show diffs side-by-side

added added

removed removed

Lines of Context:
155
155
        :param force_new_repo: Do not use a shared repository for the target 
156
156
                               even if one is available.
157
157
        """
158
 
        self._make_tail(url)
159
 
        result = self._format.initialize(url)
 
158
        return self.clone_on_transport(get_transport(url),
 
159
                                       revision_id=revision_id,
 
160
                                       force_new_repo=force_new_repo)
 
161
 
 
162
    def clone_on_transport(self, transport, revision_id=None,
 
163
                           force_new_repo=False):
 
164
        """Clone this bzrdir and its contents to transport verbatim.
 
165
 
 
166
        If the target directory does not exist, it will be created.
 
167
 
 
168
        if revision_id is not None, then the clone operation may tune
 
169
            itself to download less data.
 
170
        :param force_new_repo: Do not use a shared repository for the target 
 
171
                               even if one is available.
 
172
        """
 
173
        transport.ensure_base()
 
174
        result = self._format.initialize_on_transport(transport)
160
175
        try:
161
176
            local_repo = self.find_repository()
162
177
        except errors.NoRepositoryPresent:
195
210
    # TODO: This should be given a Transport, and should chdir up; otherwise
196
211
    # this will open a new connection.
197
212
    def _make_tail(self, url):
198
 
        head, tail = urlutils.split(url)
199
 
        if tail and tail != '.':
200
 
            t = get_transport(head)
201
 
            try:
202
 
                t.mkdir(tail)
203
 
            except errors.FileExists:
204
 
                pass
 
213
        t = get_transport(url)
 
214
        t.ensure_base()
205
215
 
206
216
    # TODO: Should take a Transport
207
217
    @classmethod
217
227
        if cls is not BzrDir:
218
228
            raise AssertionError("BzrDir.create always creates the default"
219
229
                " format, not one of %r" % cls)
220
 
        head, tail = urlutils.split(base)
221
 
        if tail and tail != '.':
222
 
            t = get_transport(head)
223
 
            try:
224
 
                t.mkdir(tail)
225
 
            except errors.FileExists:
226
 
                pass
 
230
        t = get_transport(base)
 
231
        t.ensure_base()
227
232
        if format is None:
228
233
            format = BzrDirFormat.get_default_format()
229
234
        return format.initialize(safe_unicode(base))
756
761
        if revision_id is not None, then the clone operation may tune
757
762
            itself to download less data.
758
763
        """
759
 
        self._make_tail(url)
 
764
        target_transport = get_transport(url)
 
765
        target_transport.ensure_base()
760
766
        cloning_format = self.cloning_metadir()
761
 
        result = cloning_format.initialize(url)
 
767
        result = cloning_format.initialize_on_transport(target_transport)
762
768
        try:
763
769
            source_branch = self.open_branch()
764
770
            source_repository = source_branch.repository