/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/plugins/changelog_merge/changelog_merge.py

  • Committer: Jelmer Vernooij
  • Date: 2018-03-24 17:48:04 UTC
  • mfrom: (6921 work)
  • mto: This revision was merged to the branch mainline in revision 6923.
  • Revision ID: jelmer@jelmer.uk-20180324174804-xf22o05byoj12x1q
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
from ... import (
24
24
    debug,
25
25
    merge,
 
26
    osutils,
26
27
    urlutils,
27
28
    )
28
29
from ...merge3 import Merge3
63
64
 
64
65
    name_prefix = "changelog"
65
66
 
66
 
    def get_filepath(self, params, tree):
67
 
        """Calculate the path to the file in a tree.
68
 
 
69
 
        This is overridden to return just the basename, rather than full path,
70
 
        so that e.g. if the config says ``changelog_merge_files = ChangeLog``,
71
 
        then all ChangeLog files in the tree will match (not just one in the
72
 
        root of the tree).
73
 
        
74
 
        :param params: A MergeHookParams describing the file to merge
75
 
        :param tree: a Tree, e.g. self.merger.this_tree.
76
 
        """
77
 
        return urlutils.basename(tree.id2path(params.file_id))
 
67
    def file_matches(self, params):
 
68
        affected_files = self.affected_files
 
69
        if affected_files is None:
 
70
            config = self.merger.this_branch.get_config()
 
71
            # Until bzr provides a better policy for caching the config, we
 
72
            # just add the part we're interested in to the params to avoid
 
73
            # reading the config files repeatedly (breezy.conf, location.conf,
 
74
            # branch.conf).
 
75
            config_key = self.name_prefix + '_merge_files'
 
76
            affected_files = config.get_user_option_as_list(config_key)
 
77
            if affected_files is None:
 
78
                # If nothing was specified in the config, use the default.
 
79
                affected_files = self.default_files
 
80
            self.affected_files = affected_files
 
81
        if affected_files:
 
82
            filepath = osutils.basename(params.this_path)
 
83
            if filepath in affected_files:
 
84
                return True
 
85
        return False
78
86
 
79
87
    def merge_text(self, params):
80
88
        """Merge changelog changes.