~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Vincent Ladeuil
  • Date: 2011-02-10 12:37:27 UTC
  • mto: This revision was merged to the branch mainline in revision 5661.
  • Revision ID: v.ladeuil+lp@free.fr-20110210123727-8e0pu4wtlt6fj7nf
thread is already a python module, avoid confusion and use cethread instead.

Show diffs side-by-side

added added

removed removed

Lines of Context:
413
413
                self.outf.write(page_bytes[:header_end])
414
414
                page_bytes = data
415
415
            self.outf.write('\nPage %d\n' % (page_idx,))
416
 
            if len(page_bytes) == 0:
417
 
                self.outf.write('(empty)\n');
418
 
            else:
419
 
                decomp_bytes = zlib.decompress(page_bytes)
420
 
                self.outf.write(decomp_bytes)
421
 
                self.outf.write('\n')
 
416
            decomp_bytes = zlib.decompress(page_bytes)
 
417
            self.outf.write(decomp_bytes)
 
418
            self.outf.write('\n')
422
419
 
423
420
    def _dump_entries(self, trans, basename):
424
421
        try:
1205
1202
 
1206
1203
    To retrieve the branch as of a particular revision, supply the --revision
1207
1204
    parameter, as in "branch foo/bar -r 5".
1208
 
 
1209
 
    The synonyms 'clone' and 'get' for this command are deprecated.
1210
1205
    """
1211
1206
 
1212
1207
    _see_also = ['checkout']
1242
1237
            files_from=None):
1243
1238
        from bzrlib import switch as _mod_switch
1244
1239
        from bzrlib.tag import _merge_tags_if_possible
1245
 
        if self.invoked_as in ['get', 'clone']:
1246
 
            ui.ui_factory.show_user_warning(
1247
 
                'deprecated_command',
1248
 
                deprecated_name=self.invoked_as,
1249
 
                recommended_name='branch',
1250
 
                deprecated_in_version='2.4')
1251
1240
        accelerator_tree, br_from = bzrdir.BzrDir.open_tree_or_branch(
1252
1241
            from_location)
1253
1242
        if not (hardlink or files_from):
2796
2785
            bzr ignore "RE:(?!debian/).*"
2797
2786
        
2798
2787
        Ignore everything except the "local" toplevel directory,
2799
 
        but always ignore autosave files ending in ~, even under local/::
 
2788
        but always ignore "*~" autosave files, even under local/::
2800
2789
        
2801
2790
            bzr ignore "*"
2802
2791
            bzr ignore "!./local"
2930
2919
         zip                          .zip
2931
2920
      =================       =========================
2932
2921
    """
2933
 
    encoding = 'exact'
2934
2922
    takes_args = ['dest', 'branch_or_subdir?']
2935
2923
    takes_options = ['directory',
2936
2924
        Option('format',
3114
3102
      to trigger updates to external systems like bug trackers. The --fixes
3115
3103
      option can be used to record the association between a revision and
3116
3104
      one or more bugs. See ``bzr help bugs`` for details.
 
3105
 
 
3106
      A selective commit may fail in some cases where the committed
 
3107
      tree would be invalid. Consider::
 
3108
  
 
3109
        bzr init foo
 
3110
        mkdir foo/bar
 
3111
        bzr add foo/bar
 
3112
        bzr commit foo -m "committing foo"
 
3113
        bzr mv foo/bar foo/baz
 
3114
        mkdir foo/bar
 
3115
        bzr add foo/bar
 
3116
        bzr commit foo/bar -m "committing bar but not baz"
 
3117
  
 
3118
      In the example above, the last commit will fail by design. This gives
 
3119
      the user the opportunity to decide whether they want to commit the
 
3120
      rename at the same time, separately first, or not at all. (As a general
 
3121
      rule, when in doubt, Bazaar has a policy of Doing the Safe Thing.)
3117
3122
    """
 
3123
    # TODO: Run hooks on tree to-be-committed, and after commit.
 
3124
 
 
3125
    # TODO: Strict commit that fails if there are deleted files.
 
3126
    #       (what does "deleted files" mean ??)
 
3127
 
 
3128
    # TODO: Give better message for -s, --summary, used by tla people
 
3129
 
 
3130
    # XXX: verbose currently does nothing
3118
3131
 
3119
3132
    _see_also = ['add', 'bugs', 'hooks', 'uncommit']
3120
3133
    takes_args = ['selected*']
3152
3165
             Option('show-diff', short_name='p',
3153
3166
                    help='When no message is supplied, show the diff along'
3154
3167
                    ' with the status summary in the message editor.'),
3155
 
             Option('lossy', 
3156
 
                    help='When committing to a foreign version control '
3157
 
                    'system do not push data that can not be natively '
3158
 
                    'represented.'),
3159
3168
             ]
3160
3169
    aliases = ['ci', 'checkin']
3161
3170
 
3180
3189
 
3181
3190
    def run(self, message=None, file=None, verbose=False, selected_list=None,
3182
3191
            unchanged=False, strict=False, local=False, fixes=None,
3183
 
            author=None, show_diff=False, exclude=None, commit_time=None,
3184
 
            lossy=False):
 
3192
            author=None, show_diff=False, exclude=None, commit_time=None):
3185
3193
        from bzrlib.errors import (
3186
3194
            PointlessCommit,
3187
3195
            ConflictsInTree,
3201
3209
                raise errors.BzrCommandError(
3202
3210
                    "Could not parse --commit-time: " + str(e))
3203
3211
 
 
3212
        # TODO: Need a blackbox test for invoking the external editor; may be
 
3213
        # slightly problematic to run this cross-platform.
 
3214
 
 
3215
        # TODO: do more checks that the commit will succeed before
 
3216
        # spending the user's valuable time typing a commit message.
 
3217
 
3204
3218
        properties = {}
3205
3219
 
3206
3220
        tree, selected_list = WorkingTree.open_containing_paths(selected_list)
3283
3297
                        reporter=None, verbose=verbose, revprops=properties,
3284
3298
                        authors=author, timestamp=commit_stamp,
3285
3299
                        timezone=offset,
3286
 
                        exclude=tree.safe_relpath_files(exclude),
3287
 
                        lossy=lossy)
 
3300
                        exclude=tree.safe_relpath_files(exclude))
3288
3301
        except PointlessCommit:
3289
3302
            raise errors.BzrCommandError("No changes to commit."
3290
 
                " Please 'bzr add' the files you want to commit, or use"
3291
 
                " --unchanged to force an empty commit.")
 
3303
                              " Use --unchanged to commit anyhow.")
3292
3304
        except ConflictsInTree:
3293
3305
            raise errors.BzrCommandError('Conflicts detected in working '
3294
3306
                'tree.  Use "bzr conflicts" to list, "bzr resolve FILE" to'
3999
4011
            merger.other_rev_id is not None):
4000
4012
            note('Nothing to do.')
4001
4013
            return 0
4002
 
        if pull and not preview:
 
4014
        if pull:
4003
4015
            if merger.interesting_files is not None:
4004
4016
                raise errors.BzrCommandError('Cannot pull individual files')
4005
4017
            if (merger.base_rev_id == tree.last_revision()):
4693
4705
    @display_command
4694
4706
    def run(self, filename, all=False, long=False, revision=None,
4695
4707
            show_ids=False, directory=None):
4696
 
        from bzrlib.annotate import (
4697
 
            annotate_file_tree,
4698
 
            )
 
4708
        from bzrlib.annotate import annotate_file, annotate_file_tree
4699
4709
        wt, branch, relpath = \
4700
4710
            _open_directory_or_containing_tree_or_branch(filename, directory)
4701
4711
        if wt is not None:
4704
4714
            self.add_cleanup(branch.lock_read().unlock)
4705
4715
        tree = _get_one_revision_tree('annotate', revision, branch=branch)
4706
4716
        self.add_cleanup(tree.lock_read().unlock)
4707
 
        if wt is not None and revision is None:
 
4717
        if wt is not None:
4708
4718
            file_id = wt.path2id(relpath)
4709
4719
        else:
4710
4720
            file_id = tree.path2id(relpath)
4711
4721
        if file_id is None:
4712
4722
            raise errors.NotVersionedError(filename)
 
4723
        file_version = tree.inventory[file_id].revision
4713
4724
        if wt is not None and revision is None:
4714
4725
            # If there is a tree and we're not annotating historical
4715
4726
            # versions, annotate the working tree's content.
4716
4727
            annotate_file_tree(wt, file_id, self.outf, long, all,
4717
4728
                show_ids=show_ids)
4718
4729
        else:
4719
 
            annotate_file_tree(tree, file_id, self.outf, long, all,
4720
 
                show_ids=show_ids, branch=branch)
 
4730
            annotate_file(branch, file_version, file_id, long, all, self.outf,
 
4731
                          show_ids=show_ids)
4721
4732
 
4722
4733
 
4723
4734
class cmd_re_sign(Command):
5552
5563
                    revno = branch.revision_id_to_dotted_revno(revid)
5553
5564
                    if isinstance(revno, tuple):
5554
5565
                        revno = '.'.join(map(str, revno))
5555
 
                except (errors.NoSuchRevision, errors.GhostRevisionsHaveNoRevno):
 
5566
                except errors.NoSuchRevision:
5556
5567
                    # Bad tag data/merges can lead to tagged revisions
5557
5568
                    # which are not in this branch. Fail gracefully ...
5558
5569
                    revno = '?'
6089
6100
    """
6090
6101
    takes_options = ['directory',
6091
6102
                     Option('ignored', help='Delete all ignored files.'),
6092
 
                     Option('detritus', help='Delete conflict files, merge and revert'
 
6103
                     Option('detritus', help='Delete conflict files, merge'
6093
6104
                            ' backups, and failed selftest dirs.'),
6094
6105
                     Option('unknown',
6095
6106
                            help='Delete files unknown to bzr (default).'),
6154
6165
            self.outf.write('%s %s\n' % (path, location))
6155
6166
 
6156
6167
 
6157
 
class cmd_export_pot(Command):
6158
 
    __doc__ = """Export command helps and error messages in po format."""
6159
 
 
6160
 
    hidden = True
6161
 
 
6162
 
    def run(self):
6163
 
        from bzrlib.export_pot import export_pot
6164
 
        export_pot(self.outf)
6165
 
 
6166
 
 
6167
6168
def _register_lazy_builtins():
6168
6169
    # register lazy builtins from other modules; called at startup and should
6169
6170
    # be only called once.