~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to command_classes.py

  • Committer: Aaron Bentley
  • Date: 2009-01-08 00:40:57 UTC
  • Revision ID: aaron@aaronbentley.com-20090108004057-4x1rbrxqsl1elpws
Get tests running correctly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
#    along with this program; if not, write to the Free Software
17
17
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
18
 
19
 
"""\
20
 
Various useful plugins for working with bzr.
21
 
"""
22
 
 
23
19
import bzrlib
24
20
 
25
21
from bzrlib.lazy_import import lazy_import
28
24
import shelf
29
25
""")
30
26
 
31
 
from version import version_info, __version__
32
27
from command import BzrToolsCommand
33
28
from errors import CommandError
34
29
from patchsource import BzrPatchSource
43
38
from bzrlib.errors import BzrCommandError
44
39
import bzrlib.ignores
45
40
from bzrlib.trace import note
46
 
from bzrlib.option import Option
47
 
sys.path.insert(0, os.path.realpath(os.path.join(os.path.dirname(__file__),
48
 
                                                 "external")))
 
41
from bzrlib.option import Option, RegistryOption
49
42
 
50
 
import show_paths
51
43
from command import BzrToolsCommand
52
44
 
53
 
bzrlib.ignores.add_runtime_ignores(['./.shelf'])
54
 
 
55
45
 
56
46
class cmd_clean_tree(BzrToolsCommand):
57
47
    """Remove unwanted files from working tree.
74
64
                     Option('unknown',
75
65
                            help='Delete files unknown to bzr (default).'),
76
66
                     Option('dry-run', help='Show files to delete instead of'
77
 
                            ' deleting them.')]
78
 
    def run(self, unknown=False, ignored=False, detritus=False, dry_run=False):
 
67
                            ' deleting them.'),
 
68
                     Option('force', help='Do not prompt before deleting.')]
 
69
    def run(self, unknown=False, ignored=False, detritus=False, dry_run=False,
 
70
            force=False):
79
71
        from clean_tree import clean_tree
80
72
        if not (unknown or ignored or detritus):
81
73
            unknown = True
 
74
        if dry_run:
 
75
            force = True
82
76
        clean_tree('.', unknown=unknown, ignored=ignored, detritus=detritus, 
83
 
                   dry_run=dry_run)
 
77
                   dry_run=dry_run, no_prompt=force)
84
78
 
85
79
 
86
80
class cmd_graph_ancestry(BzrToolsCommand):
178
172
        return patch(wt, filename, strip, silent)
179
173
 
180
174
 
181
 
class cmd_shelve(BzrToolsCommand):
 
175
class cmd_shelve1(BzrToolsCommand):
182
176
    """Temporarily set aside some changes from the current tree.
183
177
 
184
178
    Shelve allows you to temporarily put changes you've made "on the shelf",
185
179
    ie. out of the way, until a later time when you can bring them back from
186
 
    the shelf with the 'unshelve' command.
 
180
    the shelf with the 'unshelve1' command.
187
181
 
188
182
    Shelve is intended to help separate several sets of text changes that have
189
183
    been inappropriately mingled.  If you just want to get rid of all changes
190
184
    (text and otherwise) and you don't need to restore them later, use revert.
191
 
    If you want to shelve all text changes at once, use shelve --all.
 
185
    If you want to shelve all text changes at once, use shelve1 --all.
192
186
 
193
 
    By default shelve asks you what you want to shelve, press '?' at the
194
 
    prompt to get help. To shelve everything run shelve --all.
 
187
    By default shelve1 asks you what you want to shelve, press '?' at the
 
188
    prompt to get help. To shelve everything run shelve1 --all.
195
189
 
196
190
    If filenames are specified, only the changes to those files will be
197
191
    shelved, other files will be left untouched.
199
193
    If a revision is specified, changes since that revision will be shelved.
200
194
 
201
195
    You can put multiple items on the shelf. Normally each time you run
202
 
    unshelve the most recently shelved changes will be reinstated. However,
 
196
    unshelve1 the most recently shelved changes will be reinstated. However,
203
197
    you can also unshelve changes in a different order by explicitly
204
 
    specifiying which changes to unshelve. This works best when the changes
 
198
    specifiying which changes to unshelve1. This works best when the changes
205
199
    don't depend on each other.
206
200
 
207
201
    While you have patches on the shelf you can view and manipulate them with
208
 
    the 'shelf' command. Run 'bzr shelf -h' for more info.
 
202
    the 'shelf1' command. Run 'bzr shelf1 -h' for more info.
209
203
    """
210
204
 
211
205
    takes_args = ['file*']
231
225
        return 0
232
226
 
233
227
 
234
 
# The following classes are only used as subcommands for 'shelf', they're
 
228
# The following classes are only used as subcommands for 'shelf1', they're
235
229
# not to be registered directly with bzr.
236
230
 
237
231
class cmd_shelf_list(bzrlib.commands.Command):
273
267
        self.shelf.upgrade()
274
268
 
275
269
 
276
 
class cmd_shelf(BzrToolsCommand):
277
 
    """Perform various operations on your shelved patches. See also shelve."""
 
270
class cmd_shelf1(BzrToolsCommand):
 
271
    """Perform various operations on your shelved patches. See also shelve1."""
278
272
    takes_args = ['subcommand', 'args*']
279
273
 
280
274
    subcommands = [cmd_shelf_list, cmd_shelf_delete, cmd_shelf_switch,
339
333
        return text
340
334
 
341
335
 
342
 
class cmd_unshelve(BzrToolsCommand):
 
336
class cmd_unshelve1(BzrToolsCommand):
343
337
    """Restore shelved changes.
344
338
 
345
339
    By default the most recently shelved changes are restored. However if you
346
340
    specify a patch by name those changes will be restored instead.
347
341
 
348
 
    See 'shelve' for more information.
 
342
    See 'shelve1' for more information.
349
343
    """
350
344
    takes_options = [
351
345
            Option('all', help='Unshelve all changes without prompting.'),
538
532
    """A color version of bzr's diff"""
539
533
    takes_args = property(lambda x: get_cmd_object('diff').takes_args)
540
534
    takes_options = list(get_cmd_object('diff').takes_options) + [
 
535
        RegistryOption.from_kwargs('color',
 
536
            'Color mode to use.',
 
537
            title='Color Mode', value_switches=False, enum_switch=True,
 
538
            never='Never colorize output.',
 
539
            auto='Only colorize output if terminal supports it and STDOUT is a'
 
540
            ' TTY.',
 
541
            always='Always colorize output (default).'),
541
542
        Option('check-style',
542
543
            help='Warn if trailing whitespace or spurious changes have been'
543
544
                 ' added.')]
544
545
 
545
 
    def run(self, check_style=False, *args, **kwargs):
 
546
    def run(self, color='always', check_style=False, *args, **kwargs):
546
547
        from colordiff import colordiff
547
 
        colordiff(check_style, *args, **kwargs)
 
548
        colordiff(color, check_style, *args, **kwargs)
548
549
 
549
550
 
550
551
class cmd_rspush(BzrToolsCommand):
590
591
                source_tree.unlock()
591
592
        finally:
592
593
            target_tree.unlock()
593
 
 
594
 
from heads import cmd_heads
595
 
commands = [
596
 
            cmd_branches,
597
 
            cmd_branch_history,
598
 
            cmd_cbranch,
599
 
            cmd_cdiff,
600
 
            cmd_clean_tree,
601
 
            cmd_fetch_ghosts,
602
 
            cmd_graph_ancestry,
603
 
            cmd_heads,
604
 
            cmd_import,
605
 
            cmd_link_tree,
606
 
            cmd_multi_pull,
607
 
            cmd_patch,
608
 
            cmd_rspush,
609
 
            cmd_shelf,
610
 
            cmd_shell,
611
 
            cmd_shelve,
612
 
            cmd_trees,
613
 
            cmd_unshelve,
614
 
            cmd_zap,
615
 
            ]
616
 
 
617
 
 
618
 
if hasattr(bzrlib.commands, 'register_command'):
619
 
    for command in commands:
620
 
        bzrlib.commands.register_command(command)
621
 
 
622
 
 
623
 
def test_suite():
624
 
    from bzrlib.tests.TestUtil import TestLoader
625
 
    import tests
626
 
    from doctest import DocTestSuite, ELLIPSIS
627
 
    from unittest import TestSuite
628
 
    import bzrtools
629
 
    import tests.clean_tree
630
 
    import tests.test_dotgraph
631
 
    import tests.is_clean
632
 
    import tests.test_cbranch
633
 
    import tests.test_link_tree
634
 
    import tests.test_patch
635
 
    import tests.test_rspush
636
 
    import tests.upstream_import
637
 
    import zap
638
 
    import tests.blackbox
639
 
    import tests.shelf_tests
640
 
    result = TestSuite()
641
 
    result.addTest(DocTestSuite(bzrtools, optionflags=ELLIPSIS))
642
 
    result.addTest(tests.clean_tree.test_suite())
643
 
    result.addTest(tests.test_suite())
644
 
    result.addTest(TestLoader().loadTestsFromModule(tests.shelf_tests))
645
 
    result.addTest(tests.blackbox.test_suite())
646
 
    result.addTest(tests.upstream_import.test_suite())
647
 
    result.addTest(zap.test_suite())
648
 
    result.addTest(TestLoader().loadTestsFromModule(tests.test_dotgraph))
649
 
    result.addTest(TestLoader().loadTestsFromModule(tests.is_clean))
650
 
    result.addTest(TestLoader().loadTestsFromModule(tests.test_link_tree))
651
 
    result.addTest(TestLoader().loadTestsFromModule(tests.test_patch))
652
 
    result.addTest(TestLoader().loadTestsFromModule(tests.test_rspush))
653
 
    result.addTest(TestLoader().loadTestsFromModule(tests.test_cbranch))
654
 
    return result