Merging Branches with Binaries

John Arbash Meinel john at arbash-meinel.com
Thu Mar 4 15:34:59 GMT 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Neil Martinsen-Burrell wrote:
> On 2010-03-04 01:52 , A. S. Budden wrote:
>> On 19 February 2010 19:12, John Arbash Meinel <john at arbash-meinel.com> wrote:
>> [snip]
>>> With bzr 2.1.0+ you can create a per-file merge plugin, that checks for
>>> any file ending in .axf and just always selects OTHER.
>> This works like a charm, thanks for the suggestion.
> 
> If the code is short enough, would you be willing to post it to the list
> (or a blog if you're into that sort of thing) so others can see how this
> might be done?
> 
> -Neil
> 
> (Aside: Bazaar's plugin architecture is so strong that I and others are
> often surprised at what is possible within that framework.  More
> examples of what is possible can help with this.  Per-file merge in
> particular is a new feature so the community is still learning about
> what works well.)
> 
> 

from bzrlib import merge

class AxfMerger(merge.AbstractPerFileMerger):

  def merge_contents(self, params):
    if params.winner != 'conflict':
      # There is already an obvious winner, just use the default
      return ('not_applicable', None)
    path = self.merger.this_tree.id2path(params.file_id)
    if path.endswith('.axf'):
      return ('success', params.other_lines)
    return ('not_applicable', None)

merge.Merger.hooks.install_named_hook('merge_file_content',
	AfxMerger, 'afx merger')

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkuP0yMACgkQJdeBCYSNAAMq3wCgyoPklJpKlYqqlHvQoc5Npcr0
EccAnAxY4IC24xFUmECPkucosTPcOA3v
=wRgm
-----END PGP SIGNATURE-----



More information about the bazaar mailing list