~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Robert Collins
  • Date: 2008-09-02 05:28:37 UTC
  • mfrom: (3675 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3677.
  • Revision ID: robertc@robertcollins.net-20080902052837-ec3qlv41q5e7f6fl
Resolve conflicts with NEWS.

Show diffs side-by-side

added added

removed removed

Lines of Context:
184
184
            raise errors.BzrCommandError('bzr status --revision takes exactly'
185
185
                                         ' one or two revision specifiers')
186
186
 
187
 
        tree, file_list = tree_files(file_list)
188
 
            
 
187
        tree, relfile_list = tree_files(file_list)
 
188
        # Avoid asking for specific files when that is not needed.
 
189
        if relfile_list == ['']:
 
190
            relfile_list = None
 
191
            # Don't disable pending merges for full trees other than '.'.
 
192
            if file_list == ['.']:
 
193
                no_pending = True
 
194
        # A specific path within a tree was given.
 
195
        elif relfile_list is not None:
 
196
            no_pending = True
189
197
        show_tree_status(tree, show_ids=show_ids,
190
 
                         specific_files=file_list, revision=revision,
 
198
                         specific_files=relfile_list, revision=revision,
191
199
                         to_file=self.outf, short=short, versioned=versioned,
192
 
                         show_pending=not no_pending)
 
200
                         show_pending=(not no_pending))
193
201
 
194
202
 
195
203
class cmd_cat_revision(Command):
218
226
        # TODO: jam 20060112 should cat-revision always output utf-8?
219
227
        if revision_id is not None:
220
228
            revision_id = osutils.safe_revision_id(revision_id, warn=False)
221
 
            self.outf.write(b.repository.get_revision_xml(revision_id).decode('utf-8'))
 
229
            try:
 
230
                self.outf.write(b.repository.get_revision_xml(revision_id).decode('utf-8'))
 
231
            except errors.NoSuchRevision:
 
232
                msg = "The repository %s contains no revision %s." % (b.repository.base,
 
233
                    revision_id)
 
234
                raise errors.BzrCommandError(msg)
222
235
        elif revision is not None:
223
236
            for rev in revision:
224
237
                if rev is None:
644
657
                display_url = urlutils.unescape_for_display(stored_loc,
645
658
                        self.outf.encoding)
646
659
                if not is_quiet():
647
 
                    self.outf.write("Using saved location: %s\n" % display_url)
 
660
                    self.outf.write("Using saved parent location: %s\n" % display_url)
648
661
                location = stored_loc
649
662
 
650
663
        if mergeable is not None:
793
806
            else:
794
807
                display_url = urlutils.unescape_for_display(stored_loc,
795
808
                        self.outf.encoding)
796
 
                self.outf.write("Using saved location: %s\n" % display_url)
 
809
                self.outf.write("Using saved push location: %s\n" % display_url)
797
810
                location = stored_loc
798
811
 
799
812
        _show_push_branch(br_from, revision_id, location, self.outf,
1066
1079
class cmd_remove(Command):
1067
1080
    """Remove files or directories.
1068
1081
 
1069
 
    This makes bzr stop tracking changes to the specified files and
1070
 
    delete them if they can easily be recovered using revert.
1071
 
 
1072
 
    You can specify one or more files, and/or --new.  If you specify --new,
1073
 
    only 'added' files will be removed.  If you specify both, then new files
1074
 
    in the specified directories will be removed.  If the directories are
1075
 
    also new, they will also be removed.
 
1082
    This makes bzr stop tracking changes to the specified files. bzr will delete
 
1083
    them if they can easily be recovered using revert. If no options or
 
1084
    parameters are given bzr will scan for files that are being tracked by bzr
 
1085
    but missing in your tree and stop tracking them for you.
1076
1086
    """
1077
1087
    takes_args = ['file*']
1078
1088
    takes_options = ['verbose',
1079
 
        Option('new', help='Remove newly-added files.'),
 
1089
        Option('new', help='Only remove files that have never been committed.'),
1080
1090
        RegistryOption.from_kwargs('file-deletion-strategy',
1081
1091
            'The file deletion mode to be used.',
1082
1092
            title='Deletion Strategy', value_switches=True, enum_switch=False,
1085
1095
            keep="Don't delete any files.",
1086
1096
            force='Delete all the specified files, even if they can not be '
1087
1097
                'recovered and even if they are non-empty directories.')]
1088
 
    aliases = ['rm']
 
1098
    aliases = ['rm', 'del']
1089
1099
    encoding_type = 'replace'
1090
1100
 
1091
1101
    def run(self, file_list, verbose=False, new=False,
1094
1104
 
1095
1105
        if file_list is not None:
1096
1106
            file_list = [f for f in file_list]
1097
 
        elif not new:
1098
 
            raise errors.BzrCommandError('Specify one or more files to'
1099
 
            ' remove, or use --new.')
1100
1107
 
1101
 
        if new:
1102
 
            added = tree.changes_from(tree.basis_tree(),
1103
 
                specific_files=file_list).added
1104
 
            file_list = sorted([f[0] for f in added], reverse=True)
1105
 
            if len(file_list) == 0:
1106
 
                raise errors.BzrCommandError('No matching files.')
1107
 
        tree.remove(file_list, verbose=verbose, to_file=self.outf,
1108
 
            keep_files=file_deletion_strategy=='keep',
1109
 
            force=file_deletion_strategy=='force')
 
1108
        tree.lock_write()
 
1109
        try:
 
1110
            # Heuristics should probably all move into tree.remove_smart or
 
1111
            # some such?
 
1112
            if new:
 
1113
                added = tree.changes_from(tree.basis_tree(),
 
1114
                    specific_files=file_list).added
 
1115
                file_list = sorted([f[0] for f in added], reverse=True)
 
1116
                if len(file_list) == 0:
 
1117
                    raise errors.BzrCommandError('No matching files.')
 
1118
            elif file_list is None:
 
1119
                # missing files show up in iter_changes(basis) as
 
1120
                # versioned-with-no-kind.
 
1121
                missing = []
 
1122
                for change in tree.iter_changes(tree.basis_tree()):
 
1123
                    # Find paths in the working tree that have no kind:
 
1124
                    if change[1][1] is not None and change[6][1] is None:
 
1125
                        missing.append(change[1][1])
 
1126
                file_list = sorted(missing, reverse=True)
 
1127
                file_deletion_strategy = 'keep'
 
1128
            tree.remove(file_list, verbose=verbose, to_file=self.outf,
 
1129
                keep_files=file_deletion_strategy=='keep',
 
1130
                force=file_deletion_strategy=='force')
 
1131
        finally:
 
1132
            tree.unlock()
1110
1133
 
1111
1134
 
1112
1135
class cmd_file_id(Command):
2643
2666
                            help='Load a test id list from a text file.'),
2644
2667
                     ListOption('debugflag', type=str, short_name='E',
2645
2668
                                help='Turn on a selftest debug flag.'),
2646
 
                     Option('starting-with', type=str, argname='TESTID',
2647
 
                            short_name='s',
2648
 
                            help='Load only the tests starting with TESTID.'),
 
2669
                     ListOption('starting-with', type=str, argname='TESTID',
 
2670
                                param_name='starting_with', short_name='s',
 
2671
                                help=
 
2672
                                'Load only the tests starting with TESTID.'),
2649
2673
                     ]
2650
2674
    encoding_type = 'replace'
2651
2675
 
3052
3076
        Report if the remembered location was used.
3053
3077
        """
3054
3078
        stored_location = tree.branch.get_submit_branch()
 
3079
        stored_location_type = "submit"
3055
3080
        if stored_location is None:
3056
3081
            stored_location = tree.branch.get_parent()
 
3082
            stored_location_type = "parent"
3057
3083
        mutter("%s", stored_location)
3058
3084
        if stored_location is None:
3059
3085
            raise errors.BzrCommandError("No location specified or remembered")
3060
3086
        display_url = urlutils.unescape_for_display(stored_location, 'utf-8')
3061
 
        note(u"%s remembered location %s", verb_string, display_url)
 
3087
        note(u"%s remembered %s location %s", verb_string,
 
3088
                stored_location_type, display_url)
3062
3089
        return stored_location
3063
3090
 
3064
3091
 
3323
3350
                                             " or specified.")
3324
3351
            display_url = urlutils.unescape_for_display(parent,
3325
3352
                                                        self.outf.encoding)
3326
 
            self.outf.write("Using last location: " + display_url + "\n")
 
3353
            self.outf.write("Using saved parent location: "
 
3354
                    + display_url + "\n")
3327
3355
 
3328
3356
        remote_branch = Branch.open(other_branch)
3329
3357
        if remote_branch.base == local_branch.base:
3769
3797
                    print 'Canceled'
3770
3798
                    return 0
3771
3799
 
 
3800
        mutter('Uncommitting from {%s} to {%s}',
 
3801
               last_rev_id, rev_id)
3772
3802
        uncommit(b, tree=tree, dry_run=dry_run, verbose=verbose,
3773
3803
                 revno=revno, local=local)
 
3804
        note('You can restore the old tip by running:\n'
 
3805
             '  bzr pull . -r revid:%s', last_rev_id)
3774
3806
 
3775
3807
 
3776
3808
class cmd_break_lock(Command):
4090
4122
    (For Thunderbird 1.5, this works around some bugs.)  Supported values for
4091
4123
    specific clients are "evolution", "kmail", "mutt", and "thunderbird";
4092
4124
    generic options are "default", "editor", "emacsclient", "mapi", and
4093
 
    "xdg-email".
 
4125
    "xdg-email".  Plugins may also add supported clients.
4094
4126
 
4095
4127
    If mail is being sent, a to address is required.  This can be supplied
4096
4128
    either on the commandline, by setting the submit_to configuration
4168
4200
                raise errors.BzrCommandError(
4169
4201
                    '--remember requires a branch to be specified.')
4170
4202
            stored_submit_branch = branch.get_submit_branch()
4171
 
            remembered_submit_branch = False
 
4203
            remembered_submit_branch = None
4172
4204
            if submit_branch is None:
4173
4205
                submit_branch = stored_submit_branch
4174
 
                remembered_submit_branch = True
 
4206
                remembered_submit_branch = "submit"
4175
4207
            else:
4176
4208
                if stored_submit_branch is None or remember:
4177
4209
                    branch.set_submit_branch(submit_branch)
4178
4210
            if submit_branch is None:
4179
4211
                submit_branch = branch.get_parent()
4180
 
                remembered_submit_branch = True
 
4212
                remembered_submit_branch = "parent"
4181
4213
            if submit_branch is None:
4182
4214
                raise errors.BzrCommandError('No submit branch known or'
4183
4215
                                             ' specified')
4184
 
            if remembered_submit_branch:
4185
 
                note('Using saved location "%s" to determine what changes to submit.', submit_branch)
 
4216
            if remembered_submit_branch is not None:
 
4217
                note('Using saved %s location "%s" to determine what '
 
4218
                        'changes to submit.', remembered_submit_branch,
 
4219
                        submit_branch)
4186
4220
 
4187
4221
            if mail_to is None:
4188
4222
                submit_config = Branch.open(submit_branch).get_config()