0.38.1
by Andrew Bennetts
Simple plugin for merging GNU ChangeLog files. |
1 |
# Copyright (C) 2010 Canonical Ltd
|
2 |
#
|
|
3 |
# This program is free software; you can redistribute it and/or modify
|
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
7 |
#
|
|
8 |
# This program is distributed in the hope that it will be useful,
|
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
12 |
#
|
|
13 |
# You should have received a copy of the GNU General Public License
|
|
14 |
# along with this program; if not, write to the Free Software
|
|
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
16 |
||
6379.6.1
by Jelmer Vernooij
Import absolute_import in a few places. |
17 |
from __future__ import absolute_import |
18 |
||
0.38.1
by Andrew Bennetts
Simple plugin for merging GNU ChangeLog files. |
19 |
__doc__ = """Merge hook for GNU-format ChangeLog files |
20 |
||
6250.1.1
by Jelmer Vernooij
Fix typo in changelog_merge help. |
21 |
To enable this plugin, add a section to your locations.conf
|
0.38.1
by Andrew Bennetts
Simple plugin for merging GNU ChangeLog files. |
22 |
like::
|
23 |
||
24 |
[/home/user/proj]
|
|
25 |
changelog_merge_files = ChangeLog
|
|
26 |
||
0.38.3
by Andrew Bennetts
Match file names, not paths, and tweak docs. |
27 |
Or add an entry to your branch.conf like::
|
28 |
||
29 |
changelog_merge_files = ChangeLog
|
|
30 |
||
31 |
The changelog_merge_files config option takes a list of file names (not paths),
|
|
32 |
separated by commas. (This is unlike the news_merge plugin, which matches
|
|
33 |
paths.) e.g. the above config examples would match both
|
|
34 |
``src/foolib/ChangeLog`` and ``docs/ChangeLog``.
|
|
0.38.1
by Andrew Bennetts
Simple plugin for merging GNU ChangeLog files. |
35 |
|
0.39.4
by Andrew Bennetts
Update help text. |
36 |
The algorithm used to merge the changes can be summarised as:
|
37 |
||
38 |
* new entries added to the top of OTHER are emitted first
|
|
39 |
* all other additions, deletions and edits from THIS and OTHER are preserved
|
|
40 |
* edits (e.g. to fix typos) at the top of OTHER are hard to distinguish from
|
|
41 |
adding and deleting independent entries; the algorithm tries to guess which
|
|
42 |
based on how similar the old and new entries are.
|
|
43 |
||
44 |
Caveats
|
|
45 |
-------
|
|
46 |
||
47 |
Most changes can be merged, but conflicts are possible if the plugin finds
|
|
48 |
edits at the top of OTHER to entries that have been deleted (or also edited) by
|
|
49 |
THIS. In that case the plugin gives up and bzr's default merge logic will be
|
|
50 |
used.
|
|
51 |
||
52 |
No effort is made to deduplicate entries added by both sides.
|
|
53 |
||
54 |
The results depend on the choice of the 'base' version, so it might give
|
|
55 |
strange results if there is a criss-cross merge.
|
|
0.38.1
by Andrew Bennetts
Simple plugin for merging GNU ChangeLog files. |
56 |
"""
|
57 |
||
5724.2.1
by Andrew Bennetts
Merge bzr-changelog-merge plugin. |
58 |
# Since we are a built-in plugin we share the bzrlib version
|
59 |
from bzrlib import version_info |
|
5622.3.14
by Jelmer Vernooij
use lazy hook installation in bundled plugins. |
60 |
from bzrlib.hooks import install_lazy_named_hook |
0.38.1
by Andrew Bennetts
Simple plugin for merging GNU ChangeLog files. |
61 |
|
62 |
# Put most of the code in a separate module that we lazy-import to keep the
|
|
63 |
# overhead of this plugin as minimal as possible.
|
|
64 |
def changelog_merge_hook(merger): |
|
65 |
"""Merger.merge_file_content hook for GNU-format ChangeLog files."""
|
|
5622.3.16
by Jelmer Vernooij
Fix typo. |
66 |
from bzrlib.plugins.changelog_merge.changelog_merge import ChangeLogMerger |
5622.3.14
by Jelmer Vernooij
use lazy hook installation in bundled plugins. |
67 |
return ChangeLogMerger(merger) |
68 |
||
69 |
install_lazy_named_hook("bzrlib.merge", "Merger.hooks", "merge_file_content", |
|
70 |
changelog_merge_hook, 'GNU ChangeLog file merge') |
|
0.38.1
by Andrew Bennetts
Simple plugin for merging GNU ChangeLog files. |
71 |
|
72 |
def load_tests(basic_tests, module, loader): |
|
73 |
testmod_names = [ |
|
74 |
'tests', |
|
75 |
]
|
|
76 |
basic_tests.addTest(loader.loadTestsFromModuleNames( |
|
77 |
["%s.%s" % (__name__, tmn) for tmn in testmod_names])) |
|
78 |
return basic_tests |