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