/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 bzrlib/builtins.py

Update to bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1585
1585
 
1586
1586
    hidden = True
1587
1587
    _see_also = ['status', 'ls']
 
1588
    takes_options = [
 
1589
            Option('null',
 
1590
                   help='Write an ascii NUL (\\0) separator '
 
1591
                   'between files rather than a newline.')
 
1592
            ]
1588
1593
 
1589
1594
    @display_command
1590
 
    def run(self):
 
1595
    def run(self, null=False):
1591
1596
        tree = WorkingTree.open_containing(u'.')[0]
1592
1597
        td = tree.changes_from(tree.basis_tree())
1593
1598
        for path, id, kind, text_modified, meta_modified in td.modified:
1594
 
            self.outf.write(path + '\n')
 
1599
            if null:
 
1600
                self.outf.write(path + '\0')
 
1601
            else:
 
1602
                self.outf.write(osutils.quotefn(path) + '\n')
1595
1603
 
1596
1604
 
1597
1605
class cmd_added(Command):
1600
1608
 
1601
1609
    hidden = True
1602
1610
    _see_also = ['status', 'ls']
 
1611
    takes_options = [
 
1612
            Option('null',
 
1613
                   help='Write an ascii NUL (\\0) separator '
 
1614
                   'between files rather than a newline.')
 
1615
            ]
1603
1616
 
1604
1617
    @display_command
1605
 
    def run(self):
 
1618
    def run(self, null=False):
1606
1619
        wt = WorkingTree.open_containing(u'.')[0]
1607
1620
        wt.lock_read()
1608
1621
        try:
1619
1632
                    path = inv.id2path(file_id)
1620
1633
                    if not os.access(osutils.abspath(path), os.F_OK):
1621
1634
                        continue
1622
 
                    self.outf.write(path + '\n')
 
1635
                    if null:
 
1636
                        self.outf.write(path + '\0')
 
1637
                    else:
 
1638
                        self.outf.write(osutils.quotefn(path) + '\n')
1623
1639
            finally:
1624
1640
                basis.unlock()
1625
1641
        finally:
1820
1836
            Option('from-root',
1821
1837
                   help='Print paths relative to the root of the branch.'),
1822
1838
            Option('unknown', help='Print unknown files.'),
1823
 
            Option('versioned', help='Print versioned files.'),
 
1839
            Option('versioned', help='Print versioned files.',
 
1840
                   short_name='V'),
1824
1841
            Option('ignored', help='Print ignored files.'),
1825
1842
            Option('null',
1826
1843
                   help='Write an ascii NUL (\\0) separator '
2540
2557
        print branch.nick
2541
2558
 
2542
2559
 
 
2560
class cmd_alias(Command):
 
2561
    """Set/unset and display aliases.
 
2562
 
 
2563
    :Examples:
 
2564
        Show the current aliases::
 
2565
 
 
2566
            bzr alias
 
2567
 
 
2568
        Show the alias specified for 'll'::
 
2569
 
 
2570
            bzr alias ll
 
2571
 
 
2572
        Set an alias for 'll'::
 
2573
 
 
2574
            bzr alias ll="log --line -r-10..-1"
 
2575
 
 
2576
        To remove an alias for 'll'::
 
2577
 
 
2578
            bzr alias --remove ll
 
2579
 
 
2580
    """
 
2581
    takes_args = ['name?']
 
2582
    takes_options = [
 
2583
        Option('remove', help='Remove the alias.'),
 
2584
        ]
 
2585
 
 
2586
    def run(self, name=None, remove=False):
 
2587
        if remove:
 
2588
            self.remove_alias(name)
 
2589
        elif name is None:
 
2590
            self.print_aliases()
 
2591
        else:
 
2592
            equal_pos = name.find('=')
 
2593
            if equal_pos == -1:
 
2594
                self.print_alias(name)
 
2595
            else:
 
2596
                self.set_alias(name[:equal_pos], name[equal_pos+1:])
 
2597
 
 
2598
    def remove_alias(self, alias_name):
 
2599
        if alias_name is None:
 
2600
            raise errors.BzrCommandError(
 
2601
                'bzr alias --remove expects an alias to remove.')
 
2602
        # If alias is not found, print something like:
 
2603
        # unalias: foo: not found
 
2604
        c = config.GlobalConfig()
 
2605
        c.unset_alias(alias_name)
 
2606
 
 
2607
    @display_command
 
2608
    def print_aliases(self):
 
2609
        """Print out the defined aliases in a similar format to bash."""
 
2610
        aliases = config.GlobalConfig().get_aliases()
 
2611
        for key, value in sorted(aliases.iteritems()):
 
2612
            self.outf.write('bzr alias %s="%s"\n' % (key, value))
 
2613
 
 
2614
    @display_command
 
2615
    def print_alias(self, alias_name):
 
2616
        from bzrlib.commands import get_alias
 
2617
        alias = get_alias(alias_name)
 
2618
        if alias is None:
 
2619
            self.outf.write("bzr alias: %s: not found\n" % alias_name)
 
2620
        else:
 
2621
            self.outf.write(
 
2622
                'bzr alias %s="%s"\n' % (alias_name, ' '.join(alias)))
 
2623
 
 
2624
    def set_alias(self, alias_name, alias_command):
 
2625
        """Save the alias in the global config."""
 
2626
        c = config.GlobalConfig()
 
2627
        c.set_alias(alias_name, alias_command)
 
2628
 
 
2629
 
2543
2630
class cmd_selftest(Command):
2544
2631
    """Run internal test suite.
2545
2632
    
2638
2725
                            help='Load a test id list from a text file.'),
2639
2726
                     ListOption('debugflag', type=str, short_name='E',
2640
2727
                                help='Turn on a selftest debug flag.'),
 
2728
                     Option('starting-with', type=str, argname='TESTID',
 
2729
                            short_name='s',
 
2730
                            help='Load only the tests starting with TESTID.'),
2641
2731
                     ]
2642
2732
    encoding_type = 'replace'
2643
2733
 
2646
2736
            lsprof_timed=None, cache_dir=None,
2647
2737
            first=False, list_only=False,
2648
2738
            randomize=None, exclude=None, strict=False,
2649
 
            load_list=None, debugflag=None):
 
2739
            load_list=None, debugflag=None, starting_with=None):
2650
2740
        import bzrlib.ui
2651
2741
        from bzrlib.tests import selftest
2652
2742
        import bzrlib.benchmarks as benchmarks
2653
2743
        from bzrlib.benchmarks import tree_creator
2654
2744
 
 
2745
        # Make deprecation warnings visible, unless -Werror is set
 
2746
        symbol_versioning.activate_deprecation_warnings(override=False)
 
2747
 
2655
2748
        if cache_dir is not None:
2656
2749
            tree_creator.TreeCreator.CACHE_ROOT = osutils.abspath(cache_dir)
2657
2750
        if not list_only:
2690
2783
                              strict=strict,
2691
2784
                              load_list=load_list,
2692
2785
                              debug_flags=debugflag,
 
2786
                              starting_with=starting_with,
2693
2787
                              )
2694
2788
        finally:
2695
2789
            if benchfile is not None:
3304
3398
        from bzrlib.missing import find_unmerged, iter_log_revisions
3305
3399
 
3306
3400
        if this:
3307
 
          mine_only = this
 
3401
            mine_only = this
3308
3402
        if other:
3309
 
          theirs_only = other
 
3403
            theirs_only = other
 
3404
        # TODO: We should probably check that we don't have mine-only and
 
3405
        #       theirs-only set, but it gets complicated because we also have
 
3406
        #       this and other which could be used.
 
3407
        restrict = 'all'
 
3408
        if mine_only:
 
3409
            restrict = 'local'
 
3410
        elif theirs_only:
 
3411
            restrict = 'remote'
3310
3412
 
3311
3413
        local_branch = Branch.open_containing(u".")[0]
3312
3414
        parent = local_branch.get_parent()
3326
3428
        try:
3327
3429
            remote_branch.lock_read()
3328
3430
            try:
3329
 
                local_extra, remote_extra = find_unmerged(local_branch,
3330
 
                                                          remote_branch)
 
3431
                local_extra, remote_extra = find_unmerged(
 
3432
                    local_branch, remote_branch, restrict)
 
3433
 
3331
3434
                if log_format is None:
3332
3435
                    registry = log.log_formatter_registry
3333
3436
                    log_format = registry.get_default(local_branch)
3335
3438
                                show_ids=show_ids,
3336
3439
                                show_timezone='original')
3337
3440
                if reverse is False:
3338
 
                    local_extra.reverse()
3339
 
                    remote_extra.reverse()
 
3441
                    if local_extra is not None:
 
3442
                        local_extra.reverse()
 
3443
                    if remote_extra is not None:
 
3444
                        remote_extra.reverse()
 
3445
 
 
3446
                status_code = 0
3340
3447
                if local_extra and not theirs_only:
3341
3448
                    self.outf.write("You have %d extra revision(s):\n" %
3342
3449
                                    len(local_extra))
3345
3452
                                        verbose):
3346
3453
                        lf.log_revision(revision)
3347
3454
                    printed_local = True
 
3455
                    status_code = 1
3348
3456
                else:
3349
3457
                    printed_local = False
 
3458
 
3350
3459
                if remote_extra and not mine_only:
3351
3460
                    if printed_local is True:
3352
3461
                        self.outf.write("\n\n\n")
3356
3465
                                        remote_branch.repository,
3357
3466
                                        verbose):
3358
3467
                        lf.log_revision(revision)
3359
 
                if not remote_extra and not local_extra:
3360
 
                    status_code = 0
 
3468
                    status_code = 1
 
3469
 
 
3470
                if mine_only and not local_extra:
 
3471
                    # We checked local, and found nothing extra
 
3472
                    self.outf.write('This branch is up to date.\n')
 
3473
                elif theirs_only and not remote_extra:
 
3474
                    # We checked remote, and found nothing extra
 
3475
                    self.outf.write('Other branch is up to date.\n')
 
3476
                elif not (mine_only or theirs_only or local_extra or
 
3477
                          remote_extra):
 
3478
                    # We checked both branches, and neither one had extra
 
3479
                    # revisions
3361
3480
                    self.outf.write("Branches are up to date.\n")
3362
 
                else:
3363
 
                    status_code = 1
3364
3481
            finally:
3365
3482
                remote_branch.unlock()
3366
3483
        finally: