/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

Merge refactor of conflict code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
821
821
    def cook_conflicts(self, raw_conflicts):
822
822
        """Generate a list of cooked conflicts, sorted by file path"""
823
823
        if not raw_conflicts:
824
 
            return []
825
 
        # TODO(jelmer): Support cooking git conflicts
826
 
        raise ValueError(raw_conflicts)
 
824
            return
 
825
        fp = FinalPaths(self)
 
826
        from .workingtree import TextConflict
 
827
        for c in raw_conflicts:
 
828
            if c[0] == 'text conflict':
 
829
                yield TextConflict(fp.get_path(c[1]))
 
830
            elif c[0] == 'duplicate':
 
831
                yield TextConflict(fp.get_path(c[2]))
 
832
            elif c[0] == 'contents conflict':
 
833
                yield TextConflict(fp.get_path(c[1][0]))
 
834
            else:
 
835
                raise AssertionError('unknown conflict %s' % c[0])
827
836
 
828
837
 
829
838
class DiskTreeTransform(TreeTransformBase):
1064
1073
        if trans_id in self._new_contents:
1065
1074
            path = self._limbo_name(trans_id)
1066
1075
            st = os.lstat(path)
1067
 
            kind = mode_kind(st.t_mode)
 
1076
            kind = mode_kind(st.st_mode)
 
1077
            if kind == 'directory':
 
1078
                return None, None
1068
1079
            executable = mode_is_executable(st.st_mode)
1069
1080
            mode = object_mode(kind, executable)
1070
 
            blob = blob_from_path_and_mode(path, mode)
 
1081
            blob = blob_from_path_and_stat(encode_git_path(path), st)
1071
1082
        elif trans_id in self._removed_contents:
1072
1083
            return None, None
1073
1084
        else:
1079
1090
                contents = self._tree.get_symlink_target(orig_path)
1080
1091
            elif kind == 'file':
1081
1092
                contents = self._tree.get_file_text(orig_path)
 
1093
            elif kind == 'directory':
 
1094
                return None, None
1082
1095
            else:
1083
 
                raise AssertionError
 
1096
                raise AssertionError(kind)
1084
1097
            blob = Blob.from_string(contents)
1085
1098
        return blob, mode
1086
1099
 
1743
1756
            children.sort(key=paths.get)
1744
1757
            todo.extend(reversed(children))
1745
1758
            for trans_id in children:
1746
 
                yield (trans_id, paths.get(trans_id))
 
1759
                yield trans_id, paths[trans_id][0]
1747
1760
 
1748
1761
    def revision_tree(self, revision_id):
1749
1762
        return self._transform._tree.revision_tree(revision_id)
1756
1769
        extra = set()
1757
1770
        os = []
1758
1771
        for trans_id, path in self._list_files_by_dir():
1759
 
            if self._transform.final_is_versioned(trans_id):
 
1772
            if not self._transform.final_is_versioned(trans_id):
1760
1773
                if not want_unversioned:
1761
1774
                    continue
1762
1775
                extra.add(path)
1763
1776
            o, mode = self._transform.final_git_entry(trans_id)
1764
 
            self.store.add_object(o)
1765
 
            os.append((encode_git_path(path), o.id, mode))
 
1777
            if o is not None:
 
1778
                self.store.add_object(o)
 
1779
                os.append((encode_git_path(path), o.id, mode))
1766
1780
        return commit_tree(self.store, os), extra