/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/rewrite/__init__.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2020-01-12 00:21:40 UTC
  • mfrom: (7406.3.6 rebase)
  • Revision ID: breezy.the.bot@gmail.com-20200112002140-qkr2rtvq1xygp0kh
Port the rewrite plugin to breezy.

Merged from https://code.launchpad.net/~jelmer/brz/rebase/+merge/374758

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2007 by Jelmer Vernooij <jelmer@samba.org>
 
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
16
"""Rebase support.
 
17
 
 
18
The Bazaar rebase plugin adds support for rebasing branches to Bazaar.
 
19
It adds the command 'rebase' to Bazaar. When conflicts occur when replaying
 
20
patches, the user can resolve the conflict and continue the rebase using the
 
21
'rebase-continue' command or abort using the 'rebase-abort' command.
 
22
"""
 
23
 
 
24
from __future__ import absolute_import
 
25
 
 
26
from ... import errors
 
27
from ...commands import plugin_cmds
 
28
 
 
29
from ...bzr.bzrdir import BzrFormat
 
30
 
 
31
BzrFormat.register_feature(b"rebase-v1")
 
32
 
 
33
from ...i18n import load_plugin_translations
 
34
translation = load_plugin_translations("bzr-rewrite")
 
35
gettext = translation.gettext
 
36
 
 
37
for cmd in ['rebase', 'rebase_abort', 'rebase_continue', 'rebase_todo',
 
38
            'replay', 'pseudonyms', 'rebase_foreign']:
 
39
    plugin_cmds.register_lazy("cmd_%s" % cmd, [], __name__ + ".commands")
 
40
 
 
41
 
 
42
def show_rebase_summary(params):
 
43
    if getattr(params.new_tree, "_format", None) is None:
 
44
        return
 
45
    features = getattr(params.new_tree._format, "features", None)
 
46
    if features is None:
 
47
        return
 
48
    if "rebase-v1" not in features:
 
49
        return
 
50
    from .rebase import (
 
51
        RebaseState1,
 
52
        rebase_todo,
 
53
        )
 
54
    state = RebaseState1(params.new_tree)
 
55
    try:
 
56
        replace_map = state.read_plan()[1]
 
57
    except errors.NoSuchFile:
 
58
        return
 
59
    todo = list(rebase_todo(params.new_tree.branch.repository, replace_map))
 
60
    params.to_file.write('Rebase in progress. (%d revisions left)\n' % len(todo))
 
61
 
 
62
 
 
63
from ...hooks import install_lazy_named_hook
 
64
 
 
65
install_lazy_named_hook(
 
66
    'breezy.status', 'hooks', 'post_status',
 
67
    show_rebase_summary, 'rewrite status')
 
68
 
 
69
 
 
70
def load_tests(loader, basic_tests, pattern):
 
71
    testmod_names = [
 
72
        'tests',
 
73
        ]
 
74
    basic_tests.addTest(loader.loadTestsFromModuleNames(
 
75
        ["%s.%s" % (__name__, tmn) for tmn in testmod_names]))
 
76
    return basic_tests