~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

Merge bzr.dev into cleanup

Show diffs side-by-side

added added

removed removed

Lines of Context:
456
456
        for node in bt.iter_all_entries():
457
457
            # Node is made up of:
458
458
            # (index, key, value, [references])
459
 
            refs_as_tuples = static_tuple.as_tuples(node[3])
 
459
            try:
 
460
                refs = node[3]
 
461
            except IndexError:
 
462
                refs_as_tuples = None
 
463
            else:
 
464
                refs_as_tuples = static_tuple.as_tuples(refs)
460
465
            as_tuple = (tuple(node[1]), node[2], refs_as_tuples)
461
466
            self.outf.write('%s\n' % (as_tuple,))
462
467
 
2433
2438
            raise errors.BzrCommandError(
2434
2439
                "bzr %s doesn't accept two revisions in different"
2435
2440
                " branches." % command_name)
2436
 
        rev1 = start_spec.in_history(branch)
 
2441
        if start_spec.spec is None:
 
2442
            # Avoid loading all the history.
 
2443
            rev1 = RevisionInfo(branch, None, None)
 
2444
        else:
 
2445
            rev1 = start_spec.in_history(branch)
2437
2446
        # Avoid loading all of history when we know a missing
2438
2447
        # end of range means the last revision ...
2439
2448
        if end_spec.spec is None:
2806
2815
        Option('root',
2807
2816
               type=str,
2808
2817
               help="Name of the root directory inside the exported file."),
 
2818
        Option('per-file-timestamps',
 
2819
               help='Set modification time of files to that of the last '
 
2820
                    'revision in which it was changed.'),
2809
2821
        ]
2810
2822
    def run(self, dest, branch_or_subdir=None, revision=None, format=None,
2811
 
        root=None, filters=False):
 
2823
        root=None, filters=False, per_file_timestamps=False):
2812
2824
        from bzrlib.export import export
2813
2825
 
2814
2826
        if branch_or_subdir is None:
2821
2833
 
2822
2834
        rev_tree = _get_one_revision_tree('export', revision, branch=b, tree=tree)
2823
2835
        try:
2824
 
            export(rev_tree, dest, format, root, subdir, filtered=filters)
 
2836
            export(rev_tree, dest, format, root, subdir, filtered=filters,
 
2837
                   per_file_timestamps=per_file_timestamps)
2825
2838
        except errors.NoSuchExportFormat, e:
2826
2839
            raise errors.BzrCommandError('Unsupported export format: %s' % e.format)
2827
2840
 
5139
5152
               short_name='f',
5140
5153
               type=unicode),
5141
5154
        Option('output', short_name='o',
5142
 
               help='Write merge directive to this file; '
 
5155
               help='Write merge directive to this file or directory; '
5143
5156
                    'use - for stdout.',
5144
5157
               type=unicode),
5145
5158
        Option('strict',
5255
5268
 
5256
5269
    To rename a tag (change the name but keep it on the same revsion), run ``bzr
5257
5270
    tag new-name -r tag:old-name`` and then ``bzr tag --delete oldname``.
 
5271
 
 
5272
    If no tag name is specified it will be determined through the 
 
5273
    'automatic_tag_name' hook. This can e.g. be used to automatically tag
 
5274
    upstream releases by reading configure.ac. See ``bzr help hooks`` for
 
5275
    details.
5258
5276
    """
5259
5277
 
5260
5278
    _see_also = ['commit', 'tags']
5261
 
    takes_args = ['tag_name']
 
5279
    takes_args = ['tag_name?']
5262
5280
    takes_options = [
5263
5281
        Option('delete',
5264
5282
            help='Delete this tag rather than placing it.',
5274
5292
        'revision',
5275
5293
        ]
5276
5294
 
5277
 
    def run(self, tag_name,
 
5295
    def run(self, tag_name=None,
5278
5296
            delete=None,
5279
5297
            directory='.',
5280
5298
            force=None,
5284
5302
        branch.lock_write()
5285
5303
        self.add_cleanup(branch.unlock)
5286
5304
        if delete:
 
5305
            if tag_name is None:
 
5306
                raise errors.BzrCommandError("No tag specified to delete.")
5287
5307
            branch.tags.delete_tag(tag_name)
5288
5308
            self.outf.write('Deleted tag %s.\n' % tag_name)
5289
5309
        else:
5295
5315
                revision_id = revision[0].as_revision_id(branch)
5296
5316
            else:
5297
5317
                revision_id = branch.last_revision()
 
5318
            if tag_name is None:
 
5319
                tag_name = branch.automatic_tag_name(revision_id)
 
5320
                if tag_name is None:
 
5321
                    raise errors.BzrCommandError(
 
5322
                        "Please specify a tag name.")
5298
5323
            if (not force) and branch.tags.has_tag(tag_name):
5299
5324
                raise errors.TagAlreadyExists(tag_name)
5300
5325
            branch.tags.set_tag(tag_name, revision_id)
5736
5761
                    self.outf.write("    <no hooks installed>\n")
5737
5762
 
5738
5763
 
 
5764
class cmd_remove_branch(Command):
 
5765
    """Remove a branch.
 
5766
 
 
5767
    This will remove the branch from the specified location but 
 
5768
    will keep any working tree or repository in place.
 
5769
 
 
5770
    :Examples:
 
5771
 
 
5772
      Remove the branch at repo/trunk::
 
5773
 
 
5774
        bzr remove-branch repo/trunk
 
5775
 
 
5776
    """
 
5777
 
 
5778
    takes_args = ["location?"]
 
5779
 
 
5780
    aliases = ["rmbranch"]
 
5781
 
 
5782
    def run(self, location=None):
 
5783
        if location is None:
 
5784
            location = "."
 
5785
        branch = Branch.open_containing(location)[0]
 
5786
        branch.bzrdir.destroy_branch()
 
5787
        
 
5788
 
5739
5789
class cmd_shelve(Command):
5740
5790
    """Temporarily set aside some changes from the current tree.
5741
5791
 
5924
5974
            self.outf.write('%s %s\n' % (path, location))
5925
5975
 
5926
5976
 
5927
 
# these get imported and then picked up by the scan for cmd_*
5928
 
# TODO: Some more consistent way to split command definitions across files;
5929
 
# we do need to load at least some information about them to know of
5930
 
# aliases.  ideally we would avoid loading the implementation until the
5931
 
# details were needed.
5932
5977
from bzrlib.cmd_version_info import cmd_version_info
5933
5978
from bzrlib.conflicts import cmd_resolve, cmd_conflicts, restore
5934
 
from bzrlib.bundle.commands import (
5935
 
    cmd_bundle_info,
5936
 
    )
5937
5979
from bzrlib.foreign import cmd_dpush
5938
5980
from bzrlib.sign_my_commits import cmd_sign_my_commits