~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge.py

  • Committer: aaron.bentley at utoronto
  • Date: 2005-08-05 02:53:57 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: aaron.bentley@utoronto.ca-20050805025357-9d90b2e4c066eb4b
Switched from text-id to hashcache for merge optimization

Show diffs side-by-side

added added

removed removed

Lines of Context:
145
145
        os.mkdir(os.path.join(self.tempdir, "texts"))
146
146
        self.cached = {}
147
147
 
 
148
    def __contains__(self, file_id):
 
149
        return id in self.tree
 
150
 
 
151
    def get_file_sha1(self, id):
 
152
        return self.tree.get_file_sha1(id)
 
153
 
148
154
    def readonly_path(self, id):
149
155
        if id not in self.tree:
150
156
            return None
232
238
             source_file.interesting = source_file.id in interesting_ids
233
239
 
234
240
 
235
 
def set_optimized(tree_a, tree_b, inventory_a, inventory_b):
236
 
    """Mark files that have changed texts as interesting
237
 
    """
238
 
    for file_id in tree_a.tree.inventory:
239
 
        if file_id not in tree_b.tree.inventory:
240
 
            continue
241
 
        entry_a = tree_a.tree.inventory[file_id]
242
 
        entry_b = tree_b.tree.inventory[file_id]
243
 
        if (entry_a.kind, entry_b.kind) != ("file", "file"):
244
 
            continue
245
 
        if None in (entry_a.text_id, entry_b.text_id):
246
 
            continue
247
 
        if entry_a.text_id != entry_b.text_id:
248
 
            continue
249
 
        inventory_a[abspath(tree_a.tree, file_id)].interesting = False
250
 
        inventory_b[abspath(tree_b.tree, file_id)].interesting = False
251
 
 
252
 
 
253
241
def generate_cset_optimized(tree_a, tree_b, inventory_a, inventory_b,
254
242
                            interesting_ids=None):
255
 
    """Generate a changeset, with preprocessing to select interesting files.
256
 
    using the text_id to mark really-changed files.
257
 
    This permits blazing comparisons when text_ids are present.  It also
258
 
    disables metadata comparison for files with identical texts.
 
243
    """Generate a changeset.  If interesting_ids is supplied, only changes
 
244
    to those files will be shown.  Metadata changes are stripped.
259
245
    """ 
260
 
    if interesting_ids is None:
261
 
        set_optimized(tree_a, tree_b, inventory_a, inventory_b)
262
 
    else:
 
246
    if interesting_ids is not None:
263
247
        set_interesting(inventory_a, inventory_b, interesting_ids)
264
248
    cset =  generate_changeset(tree_a, tree_b, inventory_a, inventory_b)
265
249
    for entry in cset.entries.itervalues():