/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: Vincent Ladeuil
  • Date: 2007-06-20 14:25:06 UTC
  • mfrom: (2540 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2646.
  • Revision ID: v.ladeuil+lp@free.fr-20070620142506-txsb1v8538kpsafw
merge bzr.dev @ 2540

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
from bzrlib.branch import Branch
56
56
from bzrlib.bundle.apply_bundle import install_bundle, merge_bundle
57
57
from bzrlib.conflicts import ConflictList
58
 
from bzrlib.revision import common_ancestor
59
58
from bzrlib.revisionspec import RevisionSpec
60
59
from bzrlib.workingtree import WorkingTree
61
60
""")
770
769
                        " leading parent directories."
771
770
                        % location)
772
771
 
773
 
                cur_transport = to_transport
774
 
                needed = [cur_transport]
775
 
                # Recurse upwards until we can create a directory successfully
776
 
                while True:
777
 
                    new_transport = cur_transport.clone('..')
778
 
                    if new_transport.base == cur_transport.base:
779
 
                        raise errors.BzrCommandError("Failed to create path"
780
 
                                                     " prefix for %s."
781
 
                                                     % location)
782
 
                    try:
783
 
                        new_transport.mkdir('.')
784
 
                    except errors.NoSuchFile:
785
 
                        needed.append(new_transport)
786
 
                        cur_transport = new_transport
787
 
                    else:
788
 
                        break
789
 
 
790
 
                # Now we only need to create child directories
791
 
                while needed:
792
 
                    cur_transport = needed.pop()
793
 
                    cur_transport.ensure_base()
 
772
                _create_prefix(to_transport)
794
773
 
795
774
            # Now the target directory exists, but doesn't have a .bzr
796
775
            # directory. So we need to create it, along with any work to create
1094
1073
    takes_options = ['verbose']
1095
1074
 
1096
1075
    @display_command
1097
 
    def run(self, location=None, verbose=False):
 
1076
    def run(self, location=None, verbose=0):
1098
1077
        from bzrlib.info import show_bzrdir_info
1099
1078
        show_bzrdir_info(bzrdir.BzrDir.open_containing(location)[0],
1100
1079
                         verbose=verbose)
1285
1264
    _see_also = ['init-repo', 'branch', 'checkout']
1286
1265
    takes_args = ['location?']
1287
1266
    takes_options = [
 
1267
        Option('create-prefix',
 
1268
               help='Create the path leading up to the branch '
 
1269
                    'if it does not already exist'),
1288
1270
         RegistryOption('format',
1289
1271
                help='Specify a format for this branch. '
1290
1272
                'See "help formats".',
1297
1279
                help='Never change revnos or the existing log.'
1298
1280
                '  Append revisions to it only.')
1299
1281
         ]
1300
 
    def run(self, location=None, format=None, append_revisions_only=False):
 
1282
    def run(self, location=None, format=None, append_revisions_only=False,
 
1283
            create_prefix=False):
1301
1284
        if format is None:
1302
1285
            format = bzrdir.format_registry.make_bzrdir('default')
1303
1286
        if location is None:
1305
1288
 
1306
1289
        to_transport = transport.get_transport(location)
1307
1290
 
1308
 
        # TODO: create-prefix
1309
 
        to_transport.ensure_base()
 
1291
        # The path has to exist to initialize a
 
1292
        # branch inside of it.
 
1293
        # Just using os.mkdir, since I don't
 
1294
        # believe that we want to create a bunch of
 
1295
        # locations if the user supplies an extended path
 
1296
        try:
 
1297
            to_transport.ensure_base()
 
1298
        except errors.NoSuchFile:
 
1299
            if not create_prefix:
 
1300
                raise errors.BzrCommandError("Parent directory of %s"
 
1301
                    " does not exist."
 
1302
                    "\nYou may supply --create-prefix to create all"
 
1303
                    " leading parent directories."
 
1304
                    % location)
 
1305
            _create_prefix(to_transport)
1310
1306
 
1311
1307
        try:
1312
1308
            existing_bzrdir = bzrdir.BzrDir.open_from_transport(to_transport)
2378
2374
class cmd_selftest(Command):
2379
2375
    """Run internal test suite.
2380
2376
    
2381
 
    This creates temporary test directories in the working directory, but no
2382
 
    existing data is affected.  These directories are deleted if the tests
2383
 
    pass, or left behind to help in debugging if they fail and --keep-output
2384
 
    is specified.
2385
 
    
2386
2377
    If arguments are given, they are regular expressions that say which tests
2387
2378
    should run.  Tests matching any expression are run, and other tests are
2388
2379
    not run.
2496
2487
            from bzrlib.tests import clean_selftest_output
2497
2488
            clean_selftest_output()
2498
2489
            return 0
 
2490
        if keep_output:
 
2491
            trace.warning("notice: selftest --keep-output "
 
2492
                          "is no longer supported; "
 
2493
                          "test output is always removed")
2499
2494
 
2500
2495
        if numbered_dirs is None and sys.platform == 'win32':
2501
2496
            numbered_dirs = True
2524
2519
            result = selftest(verbose=verbose, 
2525
2520
                              pattern=pattern,
2526
2521
                              stop_on_failure=one, 
2527
 
                              keep_output=keep_output,
2528
2522
                              transport=transport,
2529
2523
                              test_suite_factory=test_suite_factory,
2530
2524
                              lsprof_timed=lsprof_timed,
2573
2567
    
2574
2568
    @display_command
2575
2569
    def run(self, branch, other):
2576
 
        from bzrlib.revision import MultipleRevisionSources
 
2570
        from bzrlib.revision import ensure_null, MultipleRevisionSources
2577
2571
        
2578
2572
        branch1 = Branch.open_containing(branch)[0]
2579
2573
        branch2 = Branch.open_containing(other)[0]
2580
2574
 
2581
 
        last1 = branch1.last_revision()
2582
 
        last2 = branch2.last_revision()
 
2575
        last1 = ensure_null(branch1.last_revision())
 
2576
        last2 = ensure_null(branch2.last_revision())
2583
2577
 
2584
 
        source = MultipleRevisionSources(branch1.repository, 
2585
 
                                         branch2.repository)
2586
 
        
2587
 
        base_rev_id = common_ancestor(last1, last2, source)
 
2578
        graph = branch1.repository.get_graph(branch2.repository)
 
2579
        base_rev_id = graph.find_unique_lca(last1, last2)
2588
2580
 
2589
2581
        print 'merge base is revision %s' % base_rev_id
2590
2582
 
2849
2841
                                             " merges.  Not cherrypicking or"
2850
2842
                                             " multi-merges.")
2851
2843
            repository = tree.branch.repository
2852
 
            base_revision = common_ancestor(parents[0],
2853
 
                                            parents[1], repository)
 
2844
            graph = repository.get_graph()
 
2845
            base_revision = graph.find_unique_lca(parents[0], parents[1])
2854
2846
            base_tree = repository.revision_tree(base_revision)
2855
2847
            other_tree = repository.revision_tree(parents[1])
2856
2848
            interesting_ids = None
3007
2999
 
3008
3000
class cmd_missing(Command):
3009
3001
    """Show unmerged/unpulled revisions between two branches.
3010
 
 
 
3002
    
3011
3003
    OTHER_BRANCH may be local or remote.
3012
3004
    """
3013
3005
 
3016
3008
    takes_options = [Option('reverse', 'Reverse the order of revisions'),
3017
3009
                     Option('mine-only',
3018
3010
                            'Display changes in the local branch only'),
3019
 
                     Option('theirs-only',
 
3011
                     Option('this' , 'same as --mine-only'),
 
3012
                     Option('theirs-only', 
3020
3013
                            'Display changes in the remote branch only'),
 
3014
                     Option('other', 'same as --theirs-only'),
3021
3015
                     'log-format',
3022
3016
                     'show-ids',
3023
3017
                     'verbose'
3026
3020
 
3027
3021
    @display_command
3028
3022
    def run(self, other_branch=None, reverse=False, mine_only=False,
3029
 
            theirs_only=False, log_format=None, long=False, short=False,
3030
 
            line=False,
3031
 
            show_ids=False, verbose=False):
 
3023
            theirs_only=False, log_format=None, long=False, short=False, line=False, 
 
3024
            show_ids=False, verbose=False, this=False, other=False):
3032
3025
        from bzrlib.missing import find_unmerged, iter_log_revisions
3033
3026
        from bzrlib.log import log_formatter
 
3027
 
 
3028
        if this:
 
3029
          mine_only = this
 
3030
        if other:
 
3031
          theirs_only = other
 
3032
 
3034
3033
        local_branch = Branch.open_containing(u".")[0]
3035
3034
        parent = local_branch.get_parent()
3036
3035
        if other_branch is None:
3580
3579
 
3581
3580
    def run(self, submit_branch=None, public_branch=None, patch_type='bundle',
3582
3581
            sign=False, revision=None, mail_to=None, message=None):
 
3582
        from bzrlib.revision import ensure_null, NULL_REVISION
3583
3583
        if patch_type == 'plain':
3584
3584
            patch_type = None
3585
3585
        branch = Branch.open('.')
3610
3610
                revision_id = revision[0].in_history(branch).rev_id
3611
3611
        else:
3612
3612
            revision_id = branch.last_revision()
 
3613
        revision_id = ensure_null(revision_id)
 
3614
        if revision_id == NULL_REVISION:
 
3615
            raise errors.BzrCommandError('No revisions to bundle.')
3613
3616
        directive = merge_directive.MergeDirective.from_objects(
3614
3617
            branch.repository, revision_id, time.time(),
3615
3618
            osutils.local_time_offset(), submit_branch,
3811
3814
    return conflicts
3812
3815
 
3813
3816
 
 
3817
def _create_prefix(cur_transport):
 
3818
    needed = [cur_transport]
 
3819
    # Recurse upwards until we can create a directory successfully
 
3820
    while True:
 
3821
        new_transport = cur_transport.clone('..')
 
3822
        if new_transport.base == cur_transport.base:
 
3823
            raise errors.BzrCommandError("Failed to create path"
 
3824
                                         " prefix for %s."
 
3825
                                         % location)
 
3826
        try:
 
3827
            new_transport.mkdir('.')
 
3828
        except errors.NoSuchFile:
 
3829
            needed.append(new_transport)
 
3830
            cur_transport = new_transport
 
3831
        else:
 
3832
            break
 
3833
 
 
3834
    # Now we only need to create child directories
 
3835
    while needed:
 
3836
        cur_transport = needed.pop()
 
3837
        cur_transport.ensure_base()
 
3838
 
3814
3839
# Compatibility
3815
3840
merge = _merge_helper
3816
3841
 
3824
3849
from bzrlib.conflicts import cmd_resolve, cmd_conflicts, restore
3825
3850
from bzrlib.bundle.commands import cmd_bundle_revisions
3826
3851
from bzrlib.sign_my_commits import cmd_sign_my_commits
3827
 
from bzrlib.weave_commands import cmd_weave_list, cmd_weave_join, \
 
3852
from bzrlib.weave_commands import cmd_versionedfile_list, cmd_weave_join, \
3828
3853
        cmd_weave_plan_merge, cmd_weave_merge_text