~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Alexander Belchenko
  • Date: 2007-10-04 05:50:44 UTC
  • mfrom: (2881 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2884.
  • Revision ID: bialix@ukr.net-20071004055044-pb88kgkfayawro8n
merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
from bzrlib.lazy_import import lazy_import
23
23
lazy_import(globals(), """
24
24
import codecs
25
 
import errno
26
25
import sys
27
 
import tempfile
28
26
import time
29
27
 
30
28
import bzrlib
31
29
from bzrlib import (
32
 
    branch,
33
30
    bugtracker,
34
31
    bundle,
35
32
    bzrdir,
43
40
    merge_directive,
44
41
    osutils,
45
42
    reconfigure,
46
 
    registry,
47
 
    repository,
48
43
    revision as _mod_revision,
49
 
    revisionspec,
50
44
    symbol_versioning,
51
45
    transport,
52
46
    tree as _mod_tree,
62
56
 
63
57
from bzrlib.commands import Command, display_command
64
58
from bzrlib.option import ListOption, Option, RegistryOption, custom_help
65
 
from bzrlib.progress import DummyProgress, ProgressPhase
66
 
from bzrlib.trace import mutter, note, log_error, warning, is_quiet, info
 
59
from bzrlib.trace import mutter, note, warning, is_quiet, info
67
60
 
68
61
 
69
62
def tree_files(file_list, default_branch=u'.'):
1430
1423
               help='Pass these options to the external diff program.'),
1431
1424
        Option('prefix', type=str,
1432
1425
               short_name='p',
1433
 
               help='Set prefixes to added to old and new filenames, as '
 
1426
               help='Set prefixes added to old and new filenames, as '
1434
1427
                    'two values separated by a colon. (eg "old/:new/").'),
1435
1428
        'revision',
1436
1429
        'change',
2254
2247
    def run(self, message=None, file=None, verbose=False, selected_list=None,
2255
2248
            unchanged=False, strict=False, local=False, fixes=None,
2256
2249
            author=None, show_diff=False):
2257
 
        from bzrlib.commit import (
2258
 
            NullCommitReporter,
2259
 
            ReportCommitToLog
2260
 
        )
2261
2250
        from bzrlib.errors import (
2262
2251
            PointlessCommit,
2263
2252
            ConflictsInTree,
2638
2627
    
2639
2628
    @display_command
2640
2629
    def run(self, branch, other):
2641
 
        from bzrlib.revision import ensure_null, MultipleRevisionSources
 
2630
        from bzrlib.revision import ensure_null
2642
2631
        
2643
2632
        branch1 = Branch.open_containing(branch)[0]
2644
2633
        branch2 = Branch.open_containing(other)[0]
2701
2690
    _see_also = ['update', 'remerge', 'status-flags']
2702
2691
    takes_args = ['branch?']
2703
2692
    takes_options = [
 
2693
        'change',
2704
2694
        'revision',
2705
2695
        Option('force',
2706
2696
               help='Merge even if the destination tree has uncommitted changes.'),
2728
2718
            uncommitted=False, pull=False,
2729
2719
            directory=None,
2730
2720
            ):
2731
 
        from bzrlib.tag import _merge_tags_if_possible
2732
2721
        # This is actually a branch (or merge-directive) *location*.
2733
2722
        location = branch
2734
2723
        del branch
2789
2778
                return 0
2790
2779
            if pull:
2791
2780
                if merger.interesting_files is not None:
2792
 
                    raise BzrCommandError('Cannot pull individual files')
 
2781
                    raise errors.BzrCommandError('Cannot pull individual files')
2793
2782
                if (merger.base_rev_id == tree.last_revision()):
2794
2783
                    result = tree.pull(merger.other_branch, False,
2795
2784
                                       merger.other_rev_id)
3048
3037
 
3049
3038
    _see_also = ['cat', 'export']
3050
3039
    takes_options = [
3051
 
            'revision',
3052
 
            Option('no-backup', "Do not save backups of reverted files."),
3053
 
            ]
 
3040
        'revision',
 
3041
        Option('no-backup', "Do not save backups of reverted files."),
 
3042
        Option('forget-merges',
 
3043
               'Remove pending merge marker, without changing any files.'),
 
3044
        ]
3054
3045
    takes_args = ['file*']
3055
3046
 
3056
 
    def run(self, revision=None, no_backup=False, file_list=None):
3057
 
        if file_list is not None:
3058
 
            if len(file_list) == 0:
3059
 
                raise errors.BzrCommandError("No files specified")
3060
 
        
 
3047
    def run(self, revision=None, no_backup=False, file_list=None,
 
3048
            forget_merges=None):
3061
3049
        tree, file_list = tree_files(file_list)
 
3050
        if forget_merges:
 
3051
            tree.set_parent_ids(tree.get_parent_ids()[:1])
 
3052
        else:
 
3053
            self._revert_tree_to_revision(tree, revision, file_list, no_backup)
 
3054
 
 
3055
    @staticmethod
 
3056
    def _revert_tree_to_revision(tree, revision, file_list, no_backup):
3062
3057
        if revision is None:
3063
 
            # FIXME should be tree.last_revision
3064
3058
            rev_id = tree.last_revision()
3065
3059
        elif len(revision) != 1:
3066
3060
            raise errors.BzrCommandError('bzr revert --revision takes exactly 1 argument')
3068
3062
            rev_id = revision[0].in_history(tree.branch).rev_id
3069
3063
        pb = ui.ui_factory.nested_progress_bar()
3070
3064
        try:
3071
 
            tree.revert(file_list, 
 
3065
            tree.revert(file_list,
3072
3066
                        tree.branch.repository.revision_tree(rev_id),
3073
3067
                        not no_backup, pb, report_changes=True)
3074
3068
        finally:
3160
3154
            theirs_only=False, log_format=None, long=False, short=False, line=False, 
3161
3155
            show_ids=False, verbose=False, this=False, other=False):
3162
3156
        from bzrlib.missing import find_unmerged, iter_log_revisions
3163
 
        from bzrlib.log import log_formatter
3164
3157
 
3165
3158
        if this:
3166
3159
          mine_only = this
3475
3468
            dry_run=False, verbose=False,
3476
3469
            revision=None, force=False):
3477
3470
        from bzrlib.log import log_formatter, show_log
3478
 
        import sys
3479
3471
        from bzrlib.uncommit import uncommit
3480
3472
 
3481
3473
        if location is None:
3901
3893
 
3902
3894
    def _run(self, submit_branch, revision, public_branch, remember, format,
3903
3895
             no_bundle, no_patch, output, from_, mail_to, message):
3904
 
        from bzrlib.revision import ensure_null, NULL_REVISION
 
3896
        from bzrlib.revision import NULL_REVISION
3905
3897
        if output is None:
3906
3898
            outfile = StringIO()
3907
3899
        elif output == '-':
4185
4177
    def run(self, location=None, target_type=None, bind_to=None, force=False):
4186
4178
        directory = bzrdir.BzrDir.open(location)
4187
4179
        if target_type is None:
4188
 
            raise BzrCommandError('No target configuration specified')
 
4180
            raise errors.BzrCommandError('No target configuration specified')
4189
4181
        elif target_type == 'branch':
4190
4182
            reconfiguration = reconfigure.Reconfigure.to_branch(directory)
4191
4183
        elif target_type == 'tree':