/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

  • Committer: Michael Hudson
  • Date: 2007-11-29 18:58:23 UTC
  • mfrom: (3048 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3189.
  • Revision ID: michael.hudson@canonical.com-20071129185823-vpokl0unnsjib0xw
merge bzr.dev
a bit involved, hope i got it all right!

Show diffs side-by-side

added added

removed removed

Lines of Context:
1255
1255
        bzr init
1256
1256
        bzr add .
1257
1257
        bzr status
1258
 
        bzr commit -m 'imported project'
 
1258
        bzr commit -m "imported project"
1259
1259
    """
1260
1260
 
1261
1261
    _see_also = ['init-repository', 'branch', 'checkout']
1915
1915
 
1916
1916
        Ignore class files in all directories::
1917
1917
 
1918
 
            bzr ignore '*.class'
1919
 
 
1920
 
        Ignore .o files under the lib directory::
1921
 
 
1922
 
            bzr ignore 'lib/**/*.o'
1923
 
 
1924
 
        Ignore .o files under the lib directory::
1925
 
 
1926
 
            bzr ignore 'RE:lib/.*\.o'
 
1918
            bzr ignore "*.class"
 
1919
 
 
1920
        Ignore .o files under the lib directory::
 
1921
 
 
1922
            bzr ignore "lib/**/*.o"
 
1923
 
 
1924
        Ignore .o files under the lib directory::
 
1925
 
 
1926
            bzr ignore "RE:lib/.*\.o"
1927
1927
    """
1928
1928
 
1929
1929
    _see_also = ['status', 'ignored']
2115
2115
        if revision is not None and len(revision) != 1:
2116
2116
            raise errors.BzrCommandError("bzr cat --revision takes exactly"
2117
2117
                                        " one number")
2118
 
 
2119
2118
        tree = None
2120
2119
        try:
2121
2120
            tree, b, relpath = \
2125
2124
 
2126
2125
        if revision is not None and revision[0].get_branch() is not None:
2127
2126
            b = Branch.open(revision[0].get_branch())
 
2127
        b.lock_read()
 
2128
        try:
 
2129
            return self._run(tree, b, relpath, filename, revision,
 
2130
                name_from_revision)
 
2131
        finally:
 
2132
            b.unlock()
 
2133
 
 
2134
    def _run(self, tree, b, relpath, filename, revision, name_from_revision):
2128
2135
        if tree is None:
2129
2136
            tree = b.basis_tree()
2130
2137
        if revision is None:
2437
2444
 
2438
2445
        Set the current user::
2439
2446
 
2440
 
            bzr whoami 'Frank Chu <fchu@example.com>'
 
2447
            bzr whoami "Frank Chu <fchu@example.com>"
2441
2448
    """
2442
2449
    takes_options = [ Option('email',
2443
2450
                             help='Display email address only.'),
2686
2693
        
2687
2694
        branch1 = Branch.open_containing(branch)[0]
2688
2695
        branch2 = Branch.open_containing(other)[0]
2689
 
 
2690
 
        last1 = ensure_null(branch1.last_revision())
2691
 
        last2 = ensure_null(branch2.last_revision())
2692
 
 
2693
 
        graph = branch1.repository.get_graph(branch2.repository)
2694
 
        base_rev_id = graph.find_unique_lca(last1, last2)
2695
 
 
2696
 
        print 'merge base is revision %s' % base_rev_id
 
2696
        branch1.lock_read()
 
2697
        try:
 
2698
            branch2.lock_read()
 
2699
            try:
 
2700
                last1 = ensure_null(branch1.last_revision())
 
2701
                last2 = ensure_null(branch2.last_revision())
 
2702
 
 
2703
                graph = branch1.repository.get_graph(branch2.repository)
 
2704
                base_rev_id = graph.find_unique_lca(last1, last2)
 
2705
 
 
2706
                print 'merge base is revision %s' % base_rev_id
 
2707
            finally:
 
2708
                branch2.unlock()
 
2709
        finally:
 
2710
            branch1.unlock()
2697
2711
 
2698
2712
 
2699
2713
class cmd_merge(Command):
2817
2831
                merger = _mod_merge.Merger.from_uncommitted(tree, other_tree,
2818
2832
                    pb)
2819
2833
                allow_pending = False
 
2834
                if other_path != '':
 
2835
                    merger.interesting_files = [other_path]
2820
2836
 
2821
2837
            if merger is None:
2822
2838
                merger, allow_pending = self._get_merger_from_branch(tree,
3072
3088
    last committed revision is used.
3073
3089
 
3074
3090
    To remove only some changes, without reverting to a prior version, use
3075
 
    merge instead.  For example, "merge . --r-2..-3" will remove the changes
3076
 
    introduced by -2, without affecting the changes introduced by -1.  Or
3077
 
    to remove certain changes on a hunk-by-hunk basis, see the Shelf plugin.
 
3091
    merge instead.  For example, "merge . --revision -2..-3" will remove the
 
3092
    changes introduced by -2, without affecting the changes introduced by -1.
 
3093
    Or to remove certain changes on a hunk-by-hunk basis, see the Shelf plugin.
3078
3094
    
3079
3095
    By default, any files that have been manually changed will be backed up
3080
3096
    first.  (Files changed only by merge are not backed up.)  Backup files have
3422
3438
    takes_options = ['revision']
3423
3439
    
3424
3440
    def run(self, revision_id_list=None, revision=None):
3425
 
        import bzrlib.gpg as gpg
3426
3441
        if revision_id_list is not None and revision is not None:
3427
3442
            raise errors.BzrCommandError('You can only supply one of revision_id or --revision')
3428
3443
        if revision_id_list is None and revision is None:
3429
3444
            raise errors.BzrCommandError('You must supply either --revision or a revision_id')
3430
3445
        b = WorkingTree.open_containing(u'.')[0].branch
 
3446
        b.lock_write()
 
3447
        try:
 
3448
            return self._run(b, revision_id_list, revision)
 
3449
        finally:
 
3450
            b.unlock()
 
3451
 
 
3452
    def _run(self, b, revision_id_list, revision):
 
3453
        import bzrlib.gpg as gpg
3431
3454
        gpg_strategy = gpg.GPGStrategy(b.get_config())
3432
3455
        if revision_id_list is not None:
3433
 
            for revision_id in revision_id_list:
3434
 
                b.repository.sign_revision(revision_id, gpg_strategy)
 
3456
            b.repository.start_write_group()
 
3457
            try:
 
3458
                for revision_id in revision_id_list:
 
3459
                    b.repository.sign_revision(revision_id, gpg_strategy)
 
3460
            except:
 
3461
                b.repository.abort_write_group()
 
3462
                raise
 
3463
            else:
 
3464
                b.repository.commit_write_group()
3435
3465
        elif revision is not None:
3436
3466
            if len(revision) == 1:
3437
3467
                revno, rev_id = revision[0].in_history(b)
3438
 
                b.repository.sign_revision(rev_id, gpg_strategy)
 
3468
                b.repository.start_write_group()
 
3469
                try:
 
3470
                    b.repository.sign_revision(rev_id, gpg_strategy)
 
3471
                except:
 
3472
                    b.repository.abort_write_group()
 
3473
                    raise
 
3474
                else:
 
3475
                    b.repository.commit_write_group()
3439
3476
            elif len(revision) == 2:
3440
3477
                # are they both on rh- if so we can walk between them
3441
3478
                # might be nice to have a range helper for arbitrary
3446
3483
                    to_revno = b.revno()
3447
3484
                if from_revno is None or to_revno is None:
3448
3485
                    raise errors.BzrCommandError('Cannot sign a range of non-revision-history revisions')
3449
 
                for revno in range(from_revno, to_revno + 1):
3450
 
                    b.repository.sign_revision(b.get_rev_id(revno), 
3451
 
                                               gpg_strategy)
 
3486
                b.repository.start_write_group()
 
3487
                try:
 
3488
                    for revno in range(from_revno, to_revno + 1):
 
3489
                        b.repository.sign_revision(b.get_rev_id(revno),
 
3490
                                                   gpg_strategy)
 
3491
                except:
 
3492
                    b.repository.abort_write_group()
 
3493
                    raise
 
3494
                else:
 
3495
                    b.repository.commit_write_group()
3452
3496
            else:
3453
3497
                raise errors.BzrCommandError('Please supply either one revision, or a range.')
3454
3498
 
3652
3696
        from bzrlib.smart import medium, server
3653
3697
        from bzrlib.transport import get_transport
3654
3698
        from bzrlib.transport.chroot import ChrootServer
3655
 
        from bzrlib.transport.remote import BZR_DEFAULT_PORT, BZR_DEFAULT_INTERFACE
3656
3699
        if directory is None:
3657
3700
            directory = os.getcwd()
3658
3701
        url = urlutils.local_path_to_url(directory)
3665
3708
            smart_server = medium.SmartServerPipeStreamMedium(
3666
3709
                sys.stdin, sys.stdout, t)
3667
3710
        else:
3668
 
            host = BZR_DEFAULT_INTERFACE
 
3711
            host = medium.BZR_DEFAULT_INTERFACE
3669
3712
            if port is None:
3670
 
                port = BZR_DEFAULT_PORT
 
3713
                port = medium.BZR_DEFAULT_PORT
3671
3714
            else:
3672
3715
                if ':' in port:
3673
3716
                    host, port = port.split(':')
3965
4008
            outfile = open(output, 'wb')
3966
4009
        try:
3967
4010
            branch = Branch.open_containing(from_)[0]
 
4011
            # we may need to write data into branch's repository to calculate
 
4012
            # the data to send.
 
4013
            branch.lock_write()
3968
4014
            if output is None:
3969
4015
                config = branch.get_config()
3970
4016
                if mail_to is None:
4052
4098
        finally:
4053
4099
            if output != '-':
4054
4100
                outfile.close()
 
4101
            branch.unlock()
4055
4102
 
4056
4103
 
4057
4104
class cmd_bundle_revisions(cmd_send):
4278
4325
        reconfiguration.apply(force)
4279
4326
 
4280
4327
 
 
4328
class cmd_switch(Command):
 
4329
    """Set the branch of a lightweight checkout and update."""
 
4330
 
 
4331
    takes_args = ['to_location']
 
4332
 
 
4333
    def run(self, to_location):
 
4334
        from bzrlib import switch
 
4335
        to_branch = Branch.open(to_location)
 
4336
        tree_location = '.'
 
4337
        control_dir = bzrdir.BzrDir.open_containing(tree_location)[0]
 
4338
        switch.switch(control_dir, to_branch)
 
4339
        note('Switched to branch: %s',
 
4340
            urlutils.unescape_for_display(to_branch.base, 'utf-8'))
 
4341
 
 
4342
 
4281
4343
def _create_prefix(cur_transport):
4282
4344
    needed = [cur_transport]
4283
4345
    # Recurse upwards until we can create a directory successfully