~ubuntu-branches/debian/jessie/bzr-git/jessie

« back to all changes in this revision

Viewing changes to tree.py

  • Committer: Bazaar Package Importer
  • Author(s): Jelmer Vernooij
  • Date: 2010-07-31 00:18:45 UTC
  • mfrom: (1.1.11 upstream) (8.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20100731001845-su2xo23q9xdqdcyu
* New upstream release.
* Bump standards version to 3.9.1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
 
35
35
 
36
36
class GitRevisionTree(revisiontree.RevisionTree):
 
37
    """Revision tree implementation based on Git objects."""
37
38
 
38
39
    def __init__(self, repository, revision_id):
39
40
        self._revision_id = revision_id
51
52
            store, revision_id)
52
53
 
53
54
    def get_revision_id(self):
 
55
        """See RevisionTree.get_revision_id."""
54
56
        return self._revision_id
55
57
 
56
58
    def get_file_text(self, file_id, path=None):
 
59
        """See RevisionTree.get_file_text."""
57
60
        if path is not None:
58
61
            entry = self._inventory._get_ie(path)
59
62
        else:
67
70
        (old_fileid_map, new_fileid_map), specific_file=None,
68
71
        require_versioned=False):
69
72
    """Create a TreeDelta from two git trees.
70
 
    
71
 
    source and target are iterators over tuples with: 
 
73
 
 
74
    source and target are iterators over tuples with:
72
75
        (filename, sha, mode)
73
76
    """
74
77
    ret = delta.TreeDelta()
94
97
    return ret
95
98
 
96
99
 
97
 
def changes_from_git_changes(changes, mapping, specific_file=None, 
 
100
def changes_from_git_changes(changes, mapping, specific_file=None,
98
101
                                require_versioned=False):
99
102
    """Create a iter_changes-like generator from a git stream.
100
 
    
101
 
    source and target are iterators over tuples with: 
 
103
 
 
104
    source and target are iterators over tuples with:
102
105
        (filename, sha, mode)
103
106
    """
104
107
    for (oldpath, newpath), (oldmode, newmode), (oldsha, newsha) in changes:
135
138
                newname = newpath
136
139
            else:
137
140
                newparent = mapping.generate_file_id(newparentpath)
138
 
        yield fileid, (oldpath, newpath), (oldsha != newsha), (oldpath is not None, newpath is not None), (oldparent, newparent), (oldname, newname), (oldkind, newkind), (oldexe, newexe)
 
141
        yield (fileid, (oldpath, newpath), (oldsha != newsha),
 
142
             (oldpath is not None, newpath is not None),
 
143
             (oldparent, newparent), (oldname, newname),
 
144
             (oldkind, newkind), (oldexe, newexe))
139
145
 
140
146
 
141
147
class InterGitRevisionTrees(tree.InterTree):
147
153
 
148
154
    @classmethod
149
155
    def is_compatible(cls, source, target):
150
 
        return (isinstance(source, GitRevisionTree) and 
 
156
        return (isinstance(source, GitRevisionTree) and
151
157
                isinstance(target, GitRevisionTree))
152
158
 
153
159
    def compare(self, want_unchanged=False, specific_files=None,
163
169
        target_fileid_map = self.target.mapping.get_fileid_map(
164
170
            self.target._repository._git.object_store.__getitem__,
165
171
            self.target.tree)
166
 
        return tree_delta_from_git_changes(changes, self.target.mapping, 
 
172
        return tree_delta_from_git_changes(changes, self.target.mapping,
167
173
            (source_fileid_map, target_fileid_map),
168
174
            specific_file=specific_files)
169
175
 
170
176
    def iter_changes(self, include_unchanged=False, specific_files=None,
171
 
        pb=None, extra_trees=[], require_versioned=True, want_unversioned=False):
 
177
        pb=None, extra_trees=[], require_versioned=True,
 
178
        want_unversioned=False):
172
179
        if self.source._repository._git.object_store != self.target._repository._git.object_store:
173
180
            raise AssertionError
174
181
        changes = self.source._repository._git.object_store.tree_changes(
175
 
            self.source.tree, self.target.tree, 
 
182
            self.source.tree, self.target.tree,
176
183
            want_unchanged=include_unchanged)
177
 
        return changes_from_git_changes(changes, self.target.mapping, 
 
184
        return changes_from_git_changes(changes, self.target.mapping,
178
185
            specific_file=specific_files)
179
186
 
180
187