/breezy-loom/trunk

To get this branch, use:
bzr branch https://code.breezy-vcs.org/breezy-loom/trunk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# Loom, a plugin for bzr to assist in developing focused patches.
# Copyright (C) 2006 Canonical Limited.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as published
# by the Free Software Foundation.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
# 

from __future__ import absolute_import

"""Loom is a bzr plugin which adds new commands to manage a loom of patches.

Loom adds the following new commands:
 * loomify: This converts a branch into a loom enabled branch. As a result
   of this, the branch format is converted and you need to have the loom
   plugin installed to use it after that. The current branch nickname becomes
   the base thread in the loom.

 * create-thread: This adds a new thread to the loom with the supplied name
   and positions the branch on the new thread.

 * record: Perform a commit of the loom - record the current stack of patches
   into history, allowing it to be pushed, pulled and merged.

 * revert-loom: Revert all change in the current stack of patches to the last
   recorded one.

 * show-loom: Shows the threads in the loom. It currently does not show the
   # of commits in each thread, but it is planned to do that in the future.

 * down-thread: Move the branch down a thread. After doing this commits and 
   merges in this branch will affect the newly selected thread.

 * up-thread: Move the branch up a thread. This will merge in all the changes
   from the current thread that are not yet integrated into the new thread into
   it and leave you ready to commit them.

 * combine-thread: Combine the current thread with the thread below it. If
   It is the last thread, this will currently refuse to operate, but in the
   future will just turn the loom into a normal branch again. Use this command
   to remove a thread which has been merged into upstream. 


Loom also adds new revision specifiers 'thread:' and 'below:'. You can use these
to diff against threads in the current Loom. For instance, 'bzr diff -r
thread:' will show you the different between the thread below yours, and your
thread. See ``bzr help revisionspec`` for the detailed help on these two
revision specifiers.
"""

from bzrlib.plugins.loom.version import (
    bzr_plugin_version as version_info,
    bzr_minimum_version,
    )

import bzrlib
import bzrlib.api

bzrlib.api.require_api(bzrlib, bzr_minimum_version)

import bzrlib.builtins
import bzrlib.commands

from bzrlib.plugins.loom import (
    commands,
    formats,
    )


for command in [
    'combine_thread',
    'create_thread',
    'down_thread',
    'export_loom',
    'loomify',
    'record',
    'revert_loom',
    'show_loom',
    'up_thread',
    ]:
    bzrlib.commands.plugin_cmds.register_lazy('cmd_' + command, [],
        'bzrlib.plugins.loom.commands')

# XXX: bzr fix needed: for switch, we have to register directly, not
# lazily, because register_lazy does not stack in the same way register_command
# does.
if not hasattr(bzrlib.builtins, "cmd_switch"):
    # provide a switch command (allows 
    bzrlib.commands.register_command(getattr(commands, 'cmd_switch'))
else:
    commands.cmd_switch._original_command = bzrlib.commands.register_command(
        getattr(commands, 'cmd_switch'), True)

from bzrlib.hooks import install_lazy_named_hook
def show_loom_summary(params):
    branch = getattr(params.new_tree, "branch", None)
    if branch is None:
        # Not a working tree, ignore
        return
    try:
        formats.require_loom_branch(branch)
    except formats.NotALoom:
        return
    params.to_file.write('Current thread: %s\n' % branch.nick)

install_lazy_named_hook('bzrlib.status', 'hooks', 'post_status',
    show_loom_summary, 'loom status')

from bzrlib.revisionspec import revspec_registry
revspec_registry.register_lazy('thread:', 'bzrlib.plugins.loom.revspec',
                               'RevisionSpecThread')
revspec_registry.register_lazy('below:', 'bzrlib.plugins.loom.revspec',
                               'RevisionSpecBelow')

#register loom formats
formats.register_formats()

def test_suite():
    import bzrlib.plugins.loom.tests
    return bzrlib.plugins.loom.tests.test_suite()