/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: Aaron Bentley
  • Date: 2009-09-29 04:40:55 UTC
  • mfrom: (4717 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4718.
  • Revision ID: aaron@aaronbentley.com-20090929044055-e9jtpmz6eyut711h
Merged bzr.dev into fix_get_mtime.

Show diffs side-by-side

added added

removed removed

Lines of Context:
120
120
 
121
121
 
122
122
def _get_one_revision_tree(command_name, revisions, branch=None, tree=None):
 
123
    """Get a revision tree. Not suitable for commands that change the tree.
 
124
    
 
125
    Specifically, the basis tree in dirstate trees is coupled to the dirstate
 
126
    and doing a commit/uncommit/pull will at best fail due to changing the
 
127
    basis revision data.
 
128
 
 
129
    If tree is passed in, it should be already locked, for lifetime management
 
130
    of the trees internal cached state.
 
131
    """
123
132
    if branch is None:
124
133
        branch = tree.branch
125
134
    if revisions is None:
452
461
            raise errors.BzrCommandError("You cannot remove the working tree"
453
462
                                         " of a remote path")
454
463
        if not force:
455
 
            # XXX: What about pending merges ? -- vila 20090629
456
 
            if working.has_changes(working.basis_tree()):
 
464
            if (working.has_changes(working.basis_tree())
 
465
                or len(working.get_parent_ids()) > 1):
457
466
                raise errors.UncommittedChanges(working)
458
467
 
459
468
        working_path = working.bzrdir.root_transport.base
1664
1673
                lazy_registry=('bzrlib.bzrdir', 'format_registry'),
1665
1674
                converter=lambda name: bzrdir.format_registry.make_bzrdir(name),
1666
1675
                value_switches=True,
1667
 
                title="Branch Format",
 
1676
                title="Branch format",
1668
1677
                ),
1669
1678
         Option('append-revisions-only',
1670
1679
                help='Never change revnos or the existing log.'
3029
3038
                raise errors.BzrCommandError("empty commit message specified")
3030
3039
            return my_message
3031
3040
 
 
3041
        # The API permits a commit with a filter of [] to mean 'select nothing'
 
3042
        # but the command line should not do that.
 
3043
        if not selected_list:
 
3044
            selected_list = None
3032
3045
        try:
3033
3046
            tree.commit(message_callback=get_message,
3034
3047
                        specific_files=selected_list,
3327
3340
    Tests that need working space on disk use a common temporary directory,
3328
3341
    typically inside $TMPDIR or /tmp.
3329
3342
 
 
3343
    If you set BZR_TEST_PDB=1 when running selftest, failing tests will drop
 
3344
    into a pdb postmortem session.
 
3345
 
3330
3346
    :Examples:
3331
3347
        Run only tests relating to 'ignore'::
3332
3348
 
3369
3385
                     Option('lsprof-timed',
3370
3386
                            help='Generate lsprof output for benchmarked'
3371
3387
                                 ' sections of code.'),
 
3388
                     Option('lsprof-tests',
 
3389
                            help='Generate lsprof output for each test.'),
3372
3390
                     Option('cache-dir', type=str,
3373
3391
                            help='Cache intermediate benchmark output in this '
3374
3392
                                 'directory.'),
3415
3433
            first=False, list_only=False,
3416
3434
            randomize=None, exclude=None, strict=False,
3417
3435
            load_list=None, debugflag=None, starting_with=None, subunit=False,
3418
 
            parallel=None):
 
3436
            parallel=None, lsprof_tests=False):
3419
3437
        from bzrlib.tests import selftest
3420
3438
        import bzrlib.benchmarks as benchmarks
3421
3439
        from bzrlib.benchmarks import tree_creator
3455
3473
                              "transport": transport,
3456
3474
                              "test_suite_factory": test_suite_factory,
3457
3475
                              "lsprof_timed": lsprof_timed,
 
3476
                              "lsprof_tests": lsprof_tests,
3458
3477
                              "bench_history": benchfile,
3459
3478
                              "matching_tests_first": first,
3460
3479
                              "list_only": list_only,
3637
3656
        verified = 'inapplicable'
3638
3657
        tree = WorkingTree.open_containing(directory)[0]
3639
3658
 
3640
 
        # die as quickly as possible if there are uncommitted changes
3641
3659
        try:
3642
3660
            basis_tree = tree.revision_tree(tree.last_revision())
3643
3661
        except errors.NoSuchRevision:
3644
3662
            basis_tree = tree.basis_tree()
 
3663
 
 
3664
        # die as quickly as possible if there are uncommitted changes
3645
3665
        if not force:
3646
 
            if tree.has_changes(basis_tree):
 
3666
            if tree.has_changes(basis_tree) or len(tree.get_parent_ids()) > 1:
3647
3667
                raise errors.UncommittedChanges(tree)
3648
3668
 
3649
3669
        view_info = _get_view_info_for_change_reporter(tree)
5631
5651
        if writer is None:
5632
5652
            writer = bzrlib.option.diff_writer_registry.get()
5633
5653
        try:
5634
 
            Shelver.from_args(writer(sys.stdout), revision, all, file_list,
5635
 
                              message, destroy=destroy).run()
 
5654
            shelver = Shelver.from_args(writer(sys.stdout), revision, all,
 
5655
                file_list, message, destroy=destroy)
 
5656
            try:
 
5657
                shelver.run()
 
5658
            finally:
 
5659
                shelver.work_tree.unlock()
5636
5660
        except errors.UserAbort:
5637
5661
            return 0
5638
5662
 
5677
5701
 
5678
5702
    def run(self, shelf_id=None, action='apply'):
5679
5703
        from bzrlib.shelf_ui import Unshelver
5680
 
        Unshelver.from_args(shelf_id, action).run()
 
5704
        unshelver = Unshelver.from_args(shelf_id, action)
 
5705
        try:
 
5706
            unshelver.run()
 
5707
        finally:
 
5708
            unshelver.tree.unlock()
5681
5709
 
5682
5710
 
5683
5711
class cmd_clean_tree(Command):