/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/git/dir.py

  • Committer: Gustav Hartvigsson
  • Date: 2021-01-09 21:36:27 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20210109213627-h1xwcutzy9m7a99b
Added 'Case Preserving Working Tree Use Cases' from Canonical Wiki

* Addod a page from the Canonical Bazaar wiki
  with information on the scmeatics of case
  perserving filesystems an a case insensitive
  filesystem works.
  
  * Needs re-work, but this will do as it is the
    same inforamoton as what was on the linked
    page in the currint documentation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
    RepositoryAcquisitionPolicy,
40
40
    )
41
41
 
 
42
from .mapping import (
 
43
    decode_git_path,
 
44
    encode_git_path,
 
45
    )
42
46
from .push import (
43
47
    GitPushResult,
44
48
    )
213
217
                        target, basis.get_reference_revision(path),
214
218
                        force_new_repo=force_new_repo, recurse=recurse,
215
219
                        stacked=stacked)
 
220
        if getattr(result_repo, '_git', None):
 
221
            # Don't leak resources:
 
222
            # TODO(jelmer): This shouldn't be git-specific, and possibly
 
223
            # just use read locks.
 
224
            result_repo._git.object_store.close()
216
225
        return result
217
226
 
218
227
    def clone_on_transport(self, transport, revision_id=None,
219
228
                           force_new_repo=False, preserve_stacking=False,
220
229
                           stacked_on=None, create_prefix=False,
221
 
                           use_existing_dir=True, no_tree=False):
 
230
                           use_existing_dir=True, no_tree=False,
 
231
                           tag_selector=None):
222
232
        """See ControlDir.clone_on_transport."""
223
233
        from ..repository import InterRepository
224
234
        from .mapping import default_mapping
 
235
        from ..transport.local import LocalTransport
225
236
        if stacked_on is not None:
226
237
            raise _mod_branch.UnstackableBranchFormat(
227
238
                self._format, self.user_url)
240
251
        interrepo = InterRepository.get(source_repo, target_repo)
241
252
        if revision_id is not None:
242
253
            determine_wants = interrepo.get_determine_wants_revids(
243
 
                [revision_id], include_tags=True)
 
254
                [revision_id], include_tags=True, tag_selector=tag_selector)
244
255
        else:
245
256
            determine_wants = interrepo.determine_wants_all
246
257
        (pack_hint, _, refs) = interrepo.fetch_objects(determine_wants,
247
258
                                                       mapping=default_mapping)
248
259
        for name, val in refs.items():
249
260
            target_git_repo.refs[name] = val
250
 
        result_dir = self.__class__(transport, target_git_repo, format)
 
261
        result_dir = LocalGitDir(transport, target_git_repo, format)
251
262
        if revision_id is not None:
252
263
            result_dir.open_branch().set_last_revision(revision_id)
253
 
        try:
254
 
            # Cheaper to check if the target is not local, than to try making
255
 
            # the tree and fail.
256
 
            result_dir.root_transport.local_abspath('.')
 
264
        if not no_tree and isinstance(result_dir.root_transport, LocalTransport):
257
265
            if result_dir.open_repository().make_working_trees():
258
 
                self.open_workingtree().clone(
259
 
                    result_dir, revision_id=revision_id)
260
 
        except (brz_errors.NoWorkingTree, brz_errors.NotLocalUrl):
261
 
            pass
 
266
                try:
 
267
                    local_wt = self.open_workingtree()
 
268
                except brz_errors.NoWorkingTree:
 
269
                    pass
 
270
                except brz_errors.NotLocalUrl:
 
271
                    result_dir.create_workingtree(revision_id=revision_id)
 
272
                else:
 
273
                    local_wt.clone(result_dir, revision_id=revision_id)
262
274
 
263
275
        return result_dir
264
276
 
293
305
        """
294
306
        return UseExistingRepository(self.find_repository())
295
307
 
 
308
    def branch_names(self):
 
309
        from .refs import ref_to_branch_name
 
310
        ret = []
 
311
        for ref in self.get_refs_container().keys():
 
312
            try:
 
313
                branch_name = ref_to_branch_name(ref)
 
314
            except UnicodeDecodeError:
 
315
                trace.warning("Ignoring branch %r with unicode error ref", ref)
 
316
                continue
 
317
            except ValueError:
 
318
                continue
 
319
            ret.append(branch_name)
 
320
        return ret
 
321
 
296
322
    def get_branches(self):
297
323
        from .refs import ref_to_branch_name
298
324
        ret = {}
312
338
 
313
339
    def push_branch(self, source, revision_id=None, overwrite=False,
314
340
                    remember=False, create_prefix=False, lossy=False,
315
 
                    name=None):
 
341
                    name=None, tag_selector=None):
316
342
        """Push the source branch into this ControlDir."""
317
343
        push_result = GitPushResult()
318
344
        push_result.workingtree_updated = None
325
351
        target = self.open_branch(name, nascent_ok=True)
326
352
        push_result.branch_push_result = source.push(
327
353
            target, overwrite=overwrite, stop_revision=revision_id,
328
 
            lossy=lossy)
 
354
            lossy=lossy, tag_selector=tag_selector)
329
355
        push_result.new_revid = push_result.branch_push_result.new_revid
330
356
        push_result.old_revid = push_result.branch_push_result.old_revid
331
357
        try:
520
546
                    target_branch._format, self._format)
521
547
            # TODO(jelmer): Do some consistency checking across branches..
522
548
            self.control_transport.put_bytes(
523
 
                'commondir', target_path.encode('utf-8'))
 
549
                'commondir', encode_git_path(target_path))
524
550
            # TODO(jelmer): Urgh, avoid mucking about with internals.
525
551
            self._git._commontransport = (
526
552
                target_branch.repository._git._commontransport.clone())
560
586
                base_url = self.user_url.rstrip('/')
561
587
            else:
562
588
                base_url = urlutils.local_path_to_url(
563
 
                    commondir.decode(osutils._fs_enc)).rstrip('/.git/') + '/'
 
589
                    decode_git_path(commondir)).rstrip('/.git/') + '/'
564
590
            return urlutils.join_segment_parameters(base_url, params)
565
591
        return None
566
592