~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge.py

  • Committer: Aaron Bentley
  • Date: 2005-08-10 17:39:16 UTC
  • mto: (1092.1.41) (1185.3.4) (974.1.47)
  • mto: This revision was merged to the branch mainline in revision 1110.
  • Revision ID: abentley@panoramicfeedback.com-20050810173916-77580019d21a0e82
Removed MergeTree.inventory

Show diffs side-by-side

added added

removed removed

Lines of Context:
104
104
    return branch, MergeTree(base_tree, temp_path)
105
105
 
106
106
 
107
 
def abspath(tree, file_id):
108
 
    path = tree.inventory.id2path(file_id)
109
 
    if path == "":
110
 
        return "./."
111
 
    return "./" + path
112
 
 
113
107
def file_exists(tree, file_id):
114
108
    return tree.has_filename(tree.id2path(file_id))
115
109
    
116
 
def inventory_map(tree):
117
 
    inventory = {}
118
 
    for file_id in tree.inventory:
119
 
        path = abspath(tree, file_id)
120
 
        inventory[path] = tree.inventory[file_id]
121
 
    return inventory
122
 
 
123
110
 
124
111
class MergeTree(object):
125
112
    def __init__(self, tree, tempdir):
128
115
            self.root = tree.basedir
129
116
        else:
130
117
            self.root = None
131
 
        self.inventory = inventory_map(tree)
132
118
        self.tree = tree
133
119
        self.tempdir = tempdir
134
120
        os.mkdir(os.path.join(self.tempdir, "texts"))
135
121
        self.cached = {}
136
122
 
 
123
    def __iter__(self):
 
124
        return self.tree.__iter__()
 
125
 
137
126
    def __contains__(self, file_id):
138
127
        return file_id in self.tree
139
128
 
233
222
             source_file.interesting = source_file.id in interesting_ids
234
223
 
235
224
 
236
 
def generate_cset_optimized(tree_a, tree_b, inventory_a, inventory_b,
237
 
                            interesting_ids=None):
 
225
def generate_cset_optimized(tree_a, tree_b, interesting_ids=None):
238
226
    """Generate a changeset.  If interesting_ids is supplied, only changes
239
227
    to those files will be shown.  Metadata changes are stripped.
240
228
    """ 
241
 
    cset =  generate_changeset(tree_a, tree_b, inventory_a, inventory_b, 
242
 
                               interesting_ids)
 
229
    cset =  generate_changeset(tree_a, tree_b, interesting_ids)
243
230
    for entry in cset.entries.itervalues():
244
231
        entry.metadata_change = None
245
232
    return cset
258
245
    this_tree = get_tree((this_branch.base, None), tempdir, "this")[1]
259
246
 
260
247
    def get_inventory(tree):
261
 
        return tree.inventory
 
248
        return tree.tree.inventory
262
249
 
263
250
    inv_changes = merge_flex(this_tree, base_tree, other_tree,
264
251
                             generate_cset_optimized, get_inventory,
273
260
            if path == '.':
274
261
                path = ''
275
262
            else:
276
 
                assert path.startswith('./')
 
263
                assert path.startswith('./'), "path is %s" % path
277
264
            path = path[2:]
278
265
        adjust_ids.append((path, id))
279
266
    if len(adjust_ids) > 0: