3331
3332
class cmd_upgrade(Command):
3332
__doc__ = """Upgrade branch storage to current format.
3334
The check command or bzr developers may sometimes advise you to run
3335
this command. When the default format has changed you may also be warned
3336
during other operations to upgrade.
3333
__doc__ = """Upgrade a repository, branch or working tree to a newer format.
3335
When the default format has changed after a major new release of
3336
Bazaar, you may be informed during certain operations that you
3337
should upgrade. Upgrading to a newer format may improve performance
3338
or make new features available. It may however limit interoperability
3339
with older repositories or with older versions of Bazaar.
3341
If you wish to upgrade to a particular format rather than the
3342
current default, that can be specified using the --format option.
3343
As a consequence, you can use the upgrade command this way to
3344
"downgrade" to an earlier format, though some conversions are
3345
a one way process (e.g. changing from the 1.x default to the
3346
2.x default) so downgrading is not always possible.
3348
A backup.bzr.~#~ directory is created at the start of the conversion
3349
process (where # is a number). By default, this is left there on
3350
completion. If the conversion fails, delete the new .bzr directory
3351
and rename this one back in its place. Use the --clean option to ask
3352
for the backup.bzr directory to be removed on successful conversion.
3353
Alternatively, you can delete it by hand if everything looks good
3356
If the location given is a shared repository, dependent branches
3357
are also converted provided the repository converts successfully.
3358
If the conversion of a branch fails, remaining branches are still
3361
For more information on upgrades, see the Bazaar Upgrade Guide,
3362
http://doc.bazaar.canonical.com/latest/en/upgrade-guide/.
3339
_see_also = ['check']
3365
_see_also = ['check', 'reconcile', 'formats']
3340
3366
takes_args = ['url?']
3341
3367
takes_options = [
3342
RegistryOption('format',
3343
help='Upgrade to a specific format. See "bzr help'
3344
' formats" for details.',
3345
lazy_registry=('bzrlib.bzrdir', 'format_registry'),
3346
converter=lambda name: bzrdir.format_registry.make_bzrdir(name),
3347
value_switches=True, title='Branch format'),
3368
RegistryOption('format',
3369
help='Upgrade to a specific format. See "bzr help'
3370
' formats" for details.',
3371
lazy_registry=('bzrlib.bzrdir', 'format_registry'),
3372
converter=lambda name: bzrdir.format_registry.make_bzrdir(name),
3373
value_switches=True, title='Branch format'),
3375
help='Remove the backup.bzr directory if successful.'),
3377
help="Show what would be done, but don't actually do anything."),
3350
def run(self, url='.', format=None):
3380
def run(self, url='.', format=None, clean=False, dry_run=False):
3351
3381
from bzrlib.upgrade import upgrade
3352
upgrade(url, format)
3382
exceptions = upgrade(url, format, clean_up=clean, dry_run=dry_run)
3384
if len(exceptions) == 1:
3385
# Compatibility with historical behavior
3355
3391
class cmd_whoami(Command):
5448
5488
takes_options = [
5449
5489
custom_help('directory',
5450
5490
help='Branch whose tags should be displayed.'),
5451
RegistryOption.from_kwargs('sort',
5491
RegistryOption('sort',
5452
5492
'Sort tags by different criteria.', title='Sorting',
5453
natural='Sort numeric substrings as numbers:'
5454
' suitable for version numbers. (default)',
5455
alpha='Sort tags lexicographically.',
5456
time='Sort tags chronologically.',
5493
lazy_registry=('bzrlib.tag', 'tag_sort_methods')
5462
5499
@display_command
5500
def run(self, directory='.', sort=None, show_ids=False, revision=None):
5501
from bzrlib.tag import tag_sort_methods
5469
5502
branch, relpath = Branch.open_containing(directory)
5471
5504
tags = branch.tags.get_tag_dict().items()
5480
5513
# only show revisions between revid1 and revid2 (inclusive)
5481
5514
tags = [(tag, revid) for tag, revid in tags if
5482
5515
graph.is_between(revid, revid1, revid2)]
5483
if sort == 'natural':
5484
def natural_sort_key(tag):
5485
return [f(s) for f,s in
5486
zip(itertools.cycle((unicode.lower,int)),
5487
re.split('([0-9]+)', tag[0]))]
5488
tags.sort(key=natural_sort_key)
5489
elif sort == 'alpha':
5491
elif sort == 'time':
5493
for tag, revid in tags:
5495
revobj = branch.repository.get_revision(revid)
5496
except errors.NoSuchRevision:
5497
timestamp = sys.maxint # place them at the end
5499
timestamp = revobj.timestamp
5500
timestamps[revid] = timestamp
5501
tags.sort(key=lambda x: timestamps[x[1]])
5517
sort = tag_sort_methods.get()
5502
5519
if not show_ids:
5503
5520
# [ (tag, revid), ... ] -> [ (tag, dotted_revno), ... ]
5504
5521
for index, (tag, revid) in enumerate(tags):