/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/transform.py

  • Committer: Jelmer Vernooij
  • Date: 2020-11-18 02:15:43 UTC
  • mfrom: (7490.40.117 work)
  • mto: This revision was merged to the branch mainline in revision 7526.
  • Revision ID: jelmer@jelmer.uk-20201118021543-0flrmtqv7ibat6yv
Merge lp:brz/3.1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
300
300
 
301
301
    def _parent_loops(self):
302
302
        """No entry should be its own ancestor"""
303
 
        conflicts = []
304
303
        for trans_id in self._new_parent:
305
304
            seen = set()
306
305
            parent_id = trans_id
311
310
                except KeyError:
312
311
                    break
313
312
                if parent_id == trans_id:
314
 
                    conflicts.append(('parent loop', trans_id))
 
313
                    yield ('parent loop', trans_id)
315
314
                if parent_id in seen:
316
315
                    break
317
 
        return conflicts
318
316
 
319
317
    def _improper_versioning(self):
320
318
        """Cannot version a file with no contents, or a bad type.
321
319
 
322
320
        However, existing entries with no contents are okay.
323
321
        """
324
 
        conflicts = []
325
322
        for trans_id in self._versioned:
326
323
            kind = self.final_kind(trans_id)
327
324
            if kind == 'symlink' and not self._tree.supports_symlinks():
328
325
                # Ignore symlinks as they are not supported on this platform
329
326
                continue
330
327
            if kind is None:
331
 
                conflicts.append(('versioning no contents', trans_id))
 
328
                yield ('versioning no contents', trans_id)
332
329
                continue
333
330
            if not self._tree.versionable_kind(kind):
334
 
                conflicts.append(('versioning bad kind', trans_id, kind))
335
 
        return conflicts
 
331
                yield ('versioning bad kind', trans_id, kind)
336
332
 
337
333
    def _executability_conflicts(self):
338
334
        """Check for bad executability changes.
342
338
        2. only files can be executable.  (The execute bit on a directory
343
339
           does not indicate searchability)
344
340
        """
345
 
        conflicts = []
346
341
        for trans_id in self._new_executability:
347
342
            if not self.final_is_versioned(trans_id):
348
 
                conflicts.append(('unversioned executability', trans_id))
 
343
                yield ('unversioned executability', trans_id)
349
344
            else:
350
345
                if self.final_kind(trans_id) != "file":
351
 
                    conflicts.append(('non-file executability', trans_id))
352
 
        return conflicts
 
346
                    yield ('non-file executability', trans_id)
353
347
 
354
348
    def _overwrite_conflicts(self):
355
349
        """Check for overwrites (not permitted on Win32)"""
356
 
        conflicts = []
357
350
        for trans_id in self._new_contents:
358
351
            if self.tree_kind(trans_id) is None:
359
352
                continue
360
353
            if trans_id not in self._removed_contents:
361
 
                conflicts.append(('overwrite', trans_id,
362
 
                                  self.final_name(trans_id)))
363
 
        return conflicts
 
354
                yield ('overwrite', trans_id, self.final_name(trans_id))
364
355
 
365
356
    def _duplicate_entries(self, by_parent):
366
357
        """No directory may have two entries with the same name."""
367
 
        conflicts = []
368
358
        if (self._new_name, self._new_parent) == ({}, {}):
369
 
            return conflicts
370
359
        for children in by_parent.values():
371
360
            name_ids = []
372
361
            for child_tid in children:
384
373
                if kind is None and not self.final_is_versioned(trans_id):
385
374
                    continue
386
375
                if name == last_name:
387
 
                    conflicts.append(('duplicate', last_trans_id, trans_id,
388
 
                                      name))
 
376
                    yield ('duplicate', last_trans_id, trans_id, name)
389
377
                last_name = name
390
378
                last_trans_id = trans_id
391
 
        return conflicts
392
379
 
393
380
    def _parent_type_conflicts(self, by_parent):
394
381
        """Children must have a directory parent"""
395
 
        conflicts = []
396
382
        for parent_id, children in by_parent.items():
397
383
            if parent_id == ROOT_PARENT:
398
384
                continue
408
394
            kind = self.final_kind(parent_id)
409
395
            if kind is None:
410
396
                # The directory will be deleted
411
 
                conflicts.append(('missing parent', parent_id))
 
397
                yield ('missing parent', parent_id)
412
398
            elif kind != "directory":
413
399
                # Meh, we need a *directory* to put something in it
414
 
                conflicts.append(('non-directory parent', parent_id))
415
 
        return conflicts
 
400
                yield ('non-directory parent', parent_id)
416
401
 
417
402
    def _set_executability(self, path, trans_id):
418
403
        """Set the executability of versioned files """
745
730
        """Cancel the creation of new file contents."""
746
731
        raise NotImplementedError(self.cancel_creation)
747
732
 
748
 
    def apply(self, no_conflicts=False, precomputed_delta=None, _mover=None):
 
733
    def apply(self, no_conflicts=False, _mover=None):
749
734
        """Apply all changes to the inventory and filesystem.
750
735
 
751
736
        If filesystem or inventory conflicts are present, MalformedTransform
755
740
 
756
741
        :param no_conflicts: if True, the caller guarantees there are no
757
742
            conflicts, so no check is made.
758
 
        :param precomputed_delta: An inventory delta to use instead of
759
 
            calculating one.
760
743
        :param _mover: Supply an alternate FileMover, for testing
761
744
        """
762
745
        raise NotImplementedError(self.apply)