Ignore merge operation for given extension
I have text files created by a 3rd party tool that I'd like to keep in bzr. When two guys work on this file, I expect bzr will auto-merge the two files and the 3rd party tool will not function anymore. I can identify these files by some extension (e.g *.3rd)
Is there some way to tell bzr to handle "*.3rd" files like it handles images? Essentially, no merging will take place. I assume the version that was checked in last will be kept.
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- Bazaar Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Andrew Bennetts
- Solved:
- 2010-03-05
- Last query:
- 2010-03-05
- Last reply:
- 2010-03-05
|
#1 |
> Is there some way to tell bzr to handle "*.3rd" files like it handles images?
To make bzr handle these files the way it would handle images or other binaries is easy to do with a simple plugin:
---- merge_3rd.py ----
"""Custom 'merge' logic for *.3rd files.
Always conflicts if both branches have changed the file.
"""
from bzrlib.merge import AbstractPerFile
def merge_3rd_
"""Hook to merge *.3rd files"""
return Merge3rdFiles(
class Merge3rdFiles(
def filename_
inventory = self.merger.
filename = inventory[
if filename.
return filename
def merge_contents(
"""Merge the contents of a single file."""
# First, check whether this custom merge logic should be used. We
# expect most files should not be merged by this handler.
if (
# OTHER is a straight winner, rely on default merge.
# THIS and OTHER aren't both files.
not params.
# The filename doesn't match *.3rd
not self.filename_
return 'not_applicable', None
return 'conflicted', params.this_lines
Merger.
'merge_
---- END ----
Put that file in ~/.bazaar/plugins or your system-wide bzrlib/plugins directory.
This requires bzr 2.1 or newer.
Martin Pool (mbp) said : | #2 |
https:/
WillemD (willem-duminy) said : | #3 |
Thanks Andrew Bennetts, that solved my question.