~benoit.pierre/bzrtools/shell_improvements

« back to all changes in this revision

Viewing changes to command_classes.py

  • Committer: Benoît Pierre
  • Date: 2009-08-02 12:55:24 UTC
  • mfrom: (682.1.36 bzrtools)
  • Revision ID: benoit.pierre@gmail.com-20090802125524-1p2oot1y2l0y3o9w
Merge with upstream.

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
import errno
 
20
 
19
21
import bzrlib
20
22
 
21
23
from bzrlib.lazy_import import lazy_import
39
41
import bzrlib.ignores
40
42
from bzrlib.trace import note
41
43
from bzrlib.option import Option, RegistryOption
 
44
from bzrlib.workingtree import WorkingTree
42
45
 
43
46
from command import BzrToolsCommand
44
47
 
45
48
 
46
 
class cmd_clean_tree(BzrToolsCommand):
47
 
    """Remove unwanted files from working tree.
48
 
 
49
 
    By default, only unknown files, not ignored files, are deleted.  Versioned
50
 
    files are never deleted.
51
 
 
52
 
    Another class is 'detritus', which includes files emitted by bzr during
53
 
    normal operations and selftests.  (The value of these files decreases with
54
 
    time.)
55
 
 
56
 
    If no options are specified, unknown files are deleted.  Otherwise, option
57
 
    flags are respected, and may be combined.
58
 
 
59
 
    To check what clean-tree will do, use --dry-run.
60
 
    """
61
 
    takes_options = [Option('ignored', help='Delete all ignored files.'),
62
 
                     Option('detritus', help='Delete conflict files, merge'
63
 
                            ' backups, and failed selftest dirs.'),
64
 
                     Option('unknown',
65
 
                            help='Delete files unknown to bzr (default).'),
66
 
                     Option('dry-run', help='Show files to delete instead of'
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):
71
 
        from clean_tree import clean_tree
72
 
        if not (unknown or ignored or detritus):
73
 
            unknown = True
74
 
        if dry_run:
75
 
            force = True
76
 
        clean_tree('.', unknown=unknown, ignored=ignored, detritus=detritus, 
77
 
                   dry_run=dry_run, no_prompt=force)
78
 
 
79
 
 
80
49
class cmd_graph_ancestry(BzrToolsCommand):
81
50
    """Produce ancestry graphs using dot.
82
51
    
151
120
    takes_options = [Option('no-fix', help="Skip additional synchonization.")]
152
121
    def run(self, branch=None, no_fix=False):
153
122
        from fetch_ghosts import fetch_ghosts
154
 
        fetch_ghosts(branch, no_fix)
 
123
        fetch_ghosts(branch, do_reconcile=not no_fix)
155
124
 
156
125
strip_help="""Strip the smallest prefix containing num leading slashes  from \
157
126
each file name found in the patch file."""
199
168
    don't depend on each other.
200
169
 
201
170
    While you have patches on the shelf you can view and manipulate them with
202
 
    the 'shelf' command. Run 'bzr shelf -h' for more info.
 
171
    the 'shelf1' command. Run 'bzr shelf1 -h' for more info.
203
172
    """
204
173
 
205
 
    aliases = ['shelve']
206
174
    takes_args = ['file*']
207
175
    takes_options = [Option('message',
208
176
            help='A message to associate with the shelved changes.',
226
194
        return 0
227
195
 
228
196
 
229
 
# The following classes are only used as subcommands for 'shelf', they're
 
197
# The following classes are only used as subcommands for 'shelf1', they're
230
198
# not to be registered directly with bzr.
231
199
 
232
200
class cmd_shelf_list(bzrlib.commands.Command):
268
236
        self.shelf.upgrade()
269
237
 
270
238
 
271
 
class cmd_shelf(BzrToolsCommand):
 
239
class cmd_shelf1(BzrToolsCommand):
272
240
    """Perform various operations on your shelved patches. See also shelve1."""
273
241
    takes_args = ['subcommand', 'args*']
274
242
 
342
310
 
343
311
    See 'shelve1' for more information.
344
312
    """
345
 
    aliases = ['unshelve']
346
313
    takes_options = [
347
314
            Option('all', help='Unshelve all changes without prompting.'),
348
315
            Option('force', help='Force unshelving even if errors occur.'),
550
517
        colordiff(color, check_style, *args, **kwargs)
551
518
 
552
519
 
 
520
class cmd_conflict_diff(BzrToolsCommand):
 
521
 
 
522
    """Compare a conflicted file against BASE."""
 
523
 
 
524
    encoding_type = 'exact'
 
525
    takes_args = ['file']
 
526
    takes_options = [
 
527
        RegistryOption.from_kwargs('direction', 'Direction of comparison.',
 
528
            value_switches=True, enum_switch=False,
 
529
            other='Compare OTHER against common base.',
 
530
            this='Compare THIS against common base.')]
 
531
 
 
532
    def run(self, file, direction='other'):
 
533
        from bzrlib.plugins.bzrtools.colordiff import DiffWriter
 
534
        from conflict_diff import conflict_diff
 
535
        dw = DiffWriter(self.outf, check_style=False, color='auto')
 
536
        conflict_diff(dw, file, direction)
 
537
 
 
538
 
553
539
class cmd_rspush(BzrToolsCommand):
554
540
    """Upload this branch to another location using rsync.
555
541
 
593
579
                source_tree.unlock()
594
580
        finally:
595
581
            target_tree.unlock()
 
582
 
 
583
 
 
584
class cmd_create_mirror(BzrToolsCommand):
 
585
    """Create a mirror of another branch.
 
586
 
 
587
    This is similar to `bzr branch`, but copies more settings, including the
 
588
    submit branch and nickname.
 
589
 
 
590
    It sets the public branch and parent of the target to the source location.
 
591
    """
 
592
 
 
593
    takes_args = ['source', 'target']
 
594
 
 
595
    def run(self, source, target):
 
596
        source_branch = Branch.open(source)
 
597
        from bzrlib.plugins.bzrtools.mirror import create_mirror
 
598
        create_mirror(source_branch, target, [])