tree-less merges
Michael Hudson
michael.hudson at canonical.com
Tue Nov 27 14:10:22 GMT 2007
Aaron Bentley wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Michael Hudson wrote:
>> If you could look it over and tell me whether it appears sane, I can probably make
>> good progress from here by myself.
>
> How's it coming?
>
> I had an additional thought, which is that while TransformPreview must
> not implement apply, TreeTransformBase could implement get_preview_tree,
> so that both TreeTransform and TransformPreview would use that
> implementation.
So I did these things and some further hacking (mostly slicing up bits
of merge.py into smaller methods, attached as a bundle against your
branch) that lets me write get_diff_as_merged like this:
def get_diff_as_merged(target_branch, merge_source_branch, to_file):
"""Compute the diff that would result from merging one branch into another.
"""
tree = target_branch.basis_tree()
tree.branch = target_branch
merger = Merger.from_revision_ids(
DummyProgress(), tree,
merge_source_branch.last_revision(),
None, merge_source_branch, merge_source_branch)
merger.merge_type = Merge3Merger
merger.ignore_zero = True
m3m = merger.make_merger()
pt = m3m.make_preview_transform()
show_diff_trees(
tree, pt.get_preview_tree(), to_file)
and it works for the simple cases, which is pretty nice. It's not
tested at all, bad me, but I'd appreciate another sanity check if you
have time :)
Cheers,
mwh
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: tree-less-merge-diffs.bundle
Url: https://lists.ubuntu.com/archives/bazaar/attachments/20071127/646b4302/attachment-0001.diff
More information about the bazaar
mailing list