/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-08-10 15:00:17 UTC
  • mfrom: (7490.40.99 work)
  • mto: This revision was merged to the branch mainline in revision 7521.
  • Revision ID: jelmer@jelmer.uk-20200810150017-vs7xnrd1vat4iktg
Merge lp:brz/3.1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
from stat import S_ISREG
23
23
import time
24
24
 
25
 
from .. import errors, multiparent, osutils, trace, ui, urlutils
 
25
from .. import conflicts, errors, multiparent, osutils, trace, ui, urlutils
26
26
from ..i18n import gettext
27
27
from ..mutabletree import MutableTree
28
28
from ..transform import (
38
38
    ReusingTransform,
39
39
    MalformedTransform,
40
40
    )
 
41
from ..bzr.inventorytree import InventoryTreeChange
41
42
 
42
43
from ..bzr import inventory
43
44
from ..bzr.transform import TransformPreview as GitTransformPreview
280
281
            if value == trans_id:
281
282
                return key
282
283
 
283
 
    def find_conflicts(self):
 
284
    def find_raw_conflicts(self):
284
285
        """Find any violations of inventory or filesystem invariants"""
285
286
        if self._done is True:
286
287
            raise ReusingTransform()
289
290
        # all children of non-existent parents are known, by definition.
290
291
        self._add_tree_children()
291
292
        by_parent = self.by_parent()
292
 
        conflicts.extend(self._unversioned_parents(by_parent))
293
293
        conflicts.extend(self._parent_loops())
294
294
        conflicts.extend(self._duplicate_entries(by_parent))
295
295
        conflicts.extend(self._parent_type_conflicts(by_parent))
299
299
        return conflicts
300
300
 
301
301
    def _check_malformed(self):
302
 
        conflicts = self.find_conflicts()
 
302
        conflicts = self.find_raw_conflicts()
303
303
        if len(conflicts) != 0:
304
304
            raise MalformedTransform(conflicts=conflicts)
305
305
 
385
385
                    break
386
386
        return conflicts
387
387
 
388
 
    def _unversioned_parents(self, by_parent):
389
 
        """If parent directories are versioned, children must be versioned."""
390
 
        conflicts = []
391
 
        for parent_id, children in by_parent.items():
392
 
            if parent_id == ROOT_PARENT:
393
 
                continue
394
 
            if self.final_is_versioned(parent_id):
395
 
                continue
396
 
            for child_id in children:
397
 
                if self.final_is_versioned(child_id):
398
 
                    conflicts.append(('unversioned parent', parent_id))
399
 
                    break
400
 
        return conflicts
401
 
 
402
388
    def _improper_versioning(self):
403
389
        """Cannot version a file with no contents, or a bad type.
404
390
 
687
673
        """Produce output in the same format as Tree.iter_changes.
688
674
 
689
675
        Will produce nonsensical results if invoked while inventory/filesystem
690
 
        conflicts (as reported by TreeTransform.find_conflicts()) are present.
 
676
        conflicts (as reported by TreeTransform.find_raw_conflicts()) are present.
691
677
 
692
678
        This reads the Transform, but only reproduces changes involving a
693
679
        file_id.  Files that are not versioned in either of the FROM or TO
739
725
                    and from_executable == to_executable):
740
726
                continue
741
727
            results.append(
742
 
                TreeChange(
 
728
                InventoryTreeChange(
743
729
                    file_id, (from_path, to_path), modified,
744
730
                    (from_versioned, to_versioned),
745
731
                    (from_parent, to_parent),
994
980
        """
995
981
        raise NotImplementedError(self.apply)
996
982
 
 
983
    def cook_conflicts(self, raw_conflicts):
 
984
        """Generate a list of cooked conflicts, sorted by file path"""
 
985
        if not raw_conflicts:
 
986
            return
 
987
        fp = FinalPaths(self)
 
988
        from .workingtree import TextConflict
 
989
        for c in raw_conflicts:
 
990
            if c[0] == 'text conflict':
 
991
                yield TextConflict(fp.get_path(c[1]))
 
992
            elif c[0] == 'duplicate':
 
993
                yield TextConflict(fp.get_path(c[2]))
 
994
            elif c[0] == 'contents conflict':
 
995
                yield TextConflict(fp.get_path(c[1][0]))
 
996
            elif c[0] == 'missing parent':
 
997
                # TODO(jelmer): This should not make it to here
 
998
                yield TextConflict(fp.get_path(c[2]))
 
999
            else:
 
1000
                raise AssertionError('unknown conflict %s' % c[0])
 
1001
 
997
1002
 
998
1003
class DiskTreeTransform(TreeTransformBase):
999
1004
    """Tree transform storing its contents on disk."""