544
547
wt = WorkingTree.open_containing(directory)[0]
550
self.add_cleanup(wt.unlock)
547
551
except (errors.NoWorkingTree, errors.NotLocalUrl):
549
553
b = Branch.open_containing(directory)[0]
553
if revision is not None:
554
revision_ids.extend(rev.as_revision_id(b) for rev in revision)
555
if revision_info_list is not None:
556
for rev_str in revision_info_list:
557
rev_spec = RevisionSpec.from_string(rev_str)
558
revision_ids.append(rev_spec.as_revision_id(b))
559
# No arguments supplied, default to the last revision
560
if len(revision_ids) == 0:
563
raise errors.NoWorkingTree(directory)
564
revision_ids.append(wt.last_revision())
566
revision_ids.append(b.last_revision())
570
for revision_id in revision_ids:
572
dotted_revno = b.revision_id_to_dotted_revno(revision_id)
573
revno = '.'.join(str(i) for i in dotted_revno)
574
except errors.NoSuchRevision:
576
maxlen = max(maxlen, len(revno))
577
revinfos.append([revno, revision_id])
555
self.add_cleanup(b.unlock)
557
if revision is not None:
558
revision_ids.extend(rev.as_revision_id(b) for rev in revision)
559
if revision_info_list is not None:
560
for rev_str in revision_info_list:
561
rev_spec = RevisionSpec.from_string(rev_str)
562
revision_ids.append(rev_spec.as_revision_id(b))
563
# No arguments supplied, default to the last revision
564
if len(revision_ids) == 0:
567
raise errors.NoWorkingTree(directory)
568
revision_ids.append(wt.last_revision())
570
revision_ids.append(b.last_revision())
574
for revision_id in revision_ids:
576
dotted_revno = b.revision_id_to_dotted_revno(revision_id)
577
revno = '.'.join(str(i) for i in dotted_revno)
578
except errors.NoSuchRevision:
580
maxlen = max(maxlen, len(revno))
581
revinfos.append([revno, revision_id])
584
584
for ri in revinfos:
585
585
self.outf.write('%*s %s\n' % (maxlen, ri[0], ri[1]))
734
732
revision = _get_one_revision('inventory', revision)
735
733
work_tree, file_list = tree_files(file_list)
736
734
work_tree.lock_read()
738
if revision is not None:
739
tree = revision.as_tree(work_tree.branch)
741
extra_trees = [work_tree]
747
if file_list is not None:
748
file_ids = tree.paths2ids(file_list, trees=extra_trees,
749
require_versioned=True)
750
# find_ids_across_trees may include some paths that don't
752
entries = sorted((tree.id2path(file_id), tree.inventory[file_id])
753
for file_id in file_ids if file_id in tree)
755
entries = tree.inventory.entries()
758
if tree is not work_tree:
735
self.add_cleanup(work_tree.unlock)
736
if revision is not None:
737
tree = revision.as_tree(work_tree.branch)
739
extra_trees = [work_tree]
741
self.add_cleanup(tree.unlock)
746
if file_list is not None:
747
file_ids = tree.paths2ids(file_list, trees=extra_trees,
748
require_versioned=True)
749
# find_ids_across_trees may include some paths that don't
751
entries = sorted((tree.id2path(file_id), tree.inventory[file_id])
752
for file_id in file_ids if file_id in tree)
754
entries = tree.inventory.entries()
761
757
for path, entry in entries:
762
758
if kind and kind != entry.kind:
904
897
dest = osutils.pathjoin(dest_parent, dest_tail)
905
898
mutter("attempting to move %s => %s", src, dest)
906
899
tree.rename_one(src, dest, after=after)
907
self.outf.write("%s => %s\n" % (src, dest))
901
self.outf.write("%s => %s\n" % (src, dest))
910
904
class cmd_pull(Command):
911
905
"""Turn this branch into a mirror of another branch.
913
This command only works on branches that have not diverged. Branches are
914
considered diverged if the destination branch's most recent commit is one
915
that has not been merged (directly or indirectly) into the parent.
907
By default, this command only works on branches that have not diverged.
908
Branches are considered diverged if the destination branch's most recent
909
commit is one that has not been merged (directly or indirectly) into the
917
912
If branches have diverged, you can use 'bzr merge' to integrate the changes
918
913
from one into the other. Once one branch has merged, the other should
919
914
be able to pull it again.
921
If you want to forget your local changes and just update your branch to
922
match the remote one, use pull --overwrite.
916
If you want to replace your local changes and just want your branch to
917
match the remote one, use pull --overwrite. This will work even if the two
918
branches have diverged.
924
920
If there is no default location set, the first pull will set it. After
925
921
that, you can omit the location to use the default. To change the
1007
1003
if branch_from is not branch_to:
1008
1004
branch_from.lock_read()
1010
if revision is not None:
1011
revision_id = revision.as_revision_id(branch_from)
1013
branch_to.lock_write()
1015
if tree_to is not None:
1016
view_info = _get_view_info_for_change_reporter(tree_to)
1017
change_reporter = delta._ChangeReporter(
1018
unversioned_filter=tree_to.is_ignored,
1019
view_info=view_info)
1020
result = tree_to.pull(
1021
branch_from, overwrite, revision_id, change_reporter,
1022
possible_transports=possible_transports, local=local)
1024
result = branch_to.pull(
1025
branch_from, overwrite, revision_id, local=local)
1027
result.report(self.outf)
1028
if verbose and result.old_revid != result.new_revid:
1029
log.show_branch_change(
1030
branch_to, self.outf, result.old_revno,
1035
if branch_from is not branch_to:
1036
branch_from.unlock()
1005
self.add_cleanup(branch_from.unlock)
1006
if revision is not None:
1007
revision_id = revision.as_revision_id(branch_from)
1009
branch_to.lock_write()
1010
self.add_cleanup(branch_to.unlock)
1011
if tree_to is not None:
1012
view_info = _get_view_info_for_change_reporter(tree_to)
1013
change_reporter = delta._ChangeReporter(
1014
unversioned_filter=tree_to.is_ignored,
1015
view_info=view_info)
1016
result = tree_to.pull(
1017
branch_from, overwrite, revision_id, change_reporter,
1018
possible_transports=possible_transports, local=local)
1020
result = branch_to.pull(
1021
branch_from, overwrite, revision_id, local=local)
1023
result.report(self.outf)
1024
if verbose and result.old_revid != result.new_revid:
1025
log.show_branch_change(
1026
branch_to, self.outf, result.old_revno,
1039
1030
class cmd_push(Command):
1194
1185
' directory exists, but does not already'
1195
1186
' have a control directory. This flag will'
1196
1187
' allow branch to proceed.'),
1189
help="Bind new branch to from location."),
1198
1191
aliases = ['get', 'clone']
1200
1193
def run(self, from_location, to_location=None, revision=None,
1201
1194
hardlink=False, stacked=False, standalone=False, no_tree=False,
1202
use_existing_dir=False, switch=False):
1195
use_existing_dir=False, switch=False, bind=False):
1203
1196
from bzrlib import switch as _mod_switch
1204
1197
from bzrlib.tag import _merge_tags_if_possible
1205
1198
accelerator_tree, br_from = bzrdir.BzrDir.open_tree_or_branch(
1207
if (accelerator_tree is not None and
1208
accelerator_tree.supports_content_filtering()):
1209
accelerator_tree = None
1210
1200
revision = _get_one_revision('branch', revision)
1211
1201
br_from.lock_read()
1202
self.add_cleanup(br_from.unlock)
1203
if revision is not None:
1204
revision_id = revision.as_revision_id(br_from)
1206
# FIXME - wt.last_revision, fallback to branch, fall back to
1207
# None or perhaps NULL_REVISION to mean copy nothing
1209
revision_id = br_from.last_revision()
1210
if to_location is None:
1211
to_location = urlutils.derive_to_location(from_location)
1212
to_transport = transport.get_transport(to_location)
1213
if revision is not None:
1214
revision_id = revision.as_revision_id(br_from)
1214
to_transport.mkdir('.')
1215
except errors.FileExists:
1216
if not use_existing_dir:
1217
raise errors.BzrCommandError('Target directory "%s" '
1218
'already exists.' % to_location)
1216
# FIXME - wt.last_revision, fallback to branch, fall back to
1217
# None or perhaps NULL_REVISION to mean copy nothing
1219
revision_id = br_from.last_revision()
1220
if to_location is None:
1221
to_location = urlutils.derive_to_location(from_location)
1222
to_transport = transport.get_transport(to_location)
1224
to_transport.mkdir('.')
1225
except errors.FileExists:
1226
if not use_existing_dir:
1227
raise errors.BzrCommandError('Target directory "%s" '
1228
'already exists.' % to_location)
1221
bzrdir.BzrDir.open_from_transport(to_transport)
1222
except errors.NotBranchError:
1231
bzrdir.BzrDir.open_from_transport(to_transport)
1232
except errors.NotBranchError:
1235
raise errors.AlreadyBranchError(to_location)
1236
except errors.NoSuchFile:
1237
raise errors.BzrCommandError('Parent of "%s" does not exist.'
1240
# preserve whatever source format we have.
1241
dir = br_from.bzrdir.sprout(to_transport.base, revision_id,
1242
possible_transports=[to_transport],
1243
accelerator_tree=accelerator_tree,
1244
hardlink=hardlink, stacked=stacked,
1245
force_new_repo=standalone,
1246
create_tree_if_local=not no_tree,
1247
source_branch=br_from)
1248
branch = dir.open_branch()
1249
except errors.NoSuchRevision:
1250
to_transport.delete_tree('.')
1251
msg = "The branch %s has no revision %s." % (from_location,
1253
raise errors.BzrCommandError(msg)
1254
_merge_tags_if_possible(br_from, branch)
1255
# If the source branch is stacked, the new branch may
1256
# be stacked whether we asked for that explicitly or not.
1257
# We therefore need a try/except here and not just 'if stacked:'
1259
note('Created new stacked branch referring to %s.' %
1260
branch.get_stacked_on_url())
1261
except (errors.NotStacked, errors.UnstackableBranchFormat,
1262
errors.UnstackableRepositoryFormat), e:
1263
note('Branched %d revision(s).' % branch.revno())
1265
# Switch to the new branch
1266
wt, _ = WorkingTree.open_containing('.')
1267
_mod_switch.switch(wt.bzrdir, branch)
1268
note('Switched to branch: %s',
1269
urlutils.unescape_for_display(branch.base, 'utf-8'))
1225
raise errors.AlreadyBranchError(to_location)
1226
except errors.NoSuchFile:
1227
raise errors.BzrCommandError('Parent of "%s" does not exist.'
1230
# preserve whatever source format we have.
1231
dir = br_from.bzrdir.sprout(to_transport.base, revision_id,
1232
possible_transports=[to_transport],
1233
accelerator_tree=accelerator_tree,
1234
hardlink=hardlink, stacked=stacked,
1235
force_new_repo=standalone,
1236
create_tree_if_local=not no_tree,
1237
source_branch=br_from)
1238
branch = dir.open_branch()
1239
except errors.NoSuchRevision:
1240
to_transport.delete_tree('.')
1241
msg = "The branch %s has no revision %s." % (from_location,
1243
raise errors.BzrCommandError(msg)
1244
_merge_tags_if_possible(br_from, branch)
1245
# If the source branch is stacked, the new branch may
1246
# be stacked whether we asked for that explicitly or not.
1247
# We therefore need a try/except here and not just 'if stacked:'
1249
note('Created new stacked branch referring to %s.' %
1250
branch.get_stacked_on_url())
1251
except (errors.NotStacked, errors.UnstackableBranchFormat,
1252
errors.UnstackableRepositoryFormat), e:
1253
note('Branched %d revision(s).' % branch.revno())
1255
# Bind to the parent
1256
parent_branch = Branch.open(from_location)
1257
branch.bind(parent_branch)
1258
note('New branch bound to %s' % from_location)
1260
# Switch to the new branch
1261
wt, _ = WorkingTree.open_containing('.')
1262
_mod_switch.switch(wt.bzrdir, branch)
1263
note('Switched to branch: %s',
1264
urlutils.unescape_for_display(branch.base, 'utf-8'))
1274
1267
class cmd_checkout(Command):
1353
1346
def run(self, dir=u'.'):
1354
1347
tree = WorkingTree.open_containing(dir)[0]
1355
1348
tree.lock_read()
1357
new_inv = tree.inventory
1358
old_tree = tree.basis_tree()
1359
old_tree.lock_read()
1361
old_inv = old_tree.inventory
1363
iterator = tree.iter_changes(old_tree, include_unchanged=True)
1364
for f, paths, c, v, p, n, k, e in iterator:
1365
if paths[0] == paths[1]:
1369
renames.append(paths)
1371
for old_name, new_name in renames:
1372
self.outf.write("%s => %s\n" % (old_name, new_name))
1349
self.add_cleanup(tree.unlock)
1350
new_inv = tree.inventory
1351
old_tree = tree.basis_tree()
1352
old_tree.lock_read()
1353
self.add_cleanup(old_tree.unlock)
1354
old_inv = old_tree.inventory
1356
iterator = tree.iter_changes(old_tree, include_unchanged=True)
1357
for f, paths, c, v, p, n, k, e in iterator:
1358
if paths[0] == paths[1]:
1362
renames.append(paths)
1364
for old_name, new_name in renames:
1365
self.outf.write("%s => %s\n" % (old_name, new_name))
1379
1368
class cmd_update(Command):
1386
1375
If you want to discard your local changes, you can just do a
1387
1376
'bzr revert' instead of 'bzr commit' after the update.
1378
If the tree's branch is bound to a master branch, it will also update
1379
the branch from the master.
1390
1382
_see_also = ['pull', 'working-trees', 'status-flags']
1391
1383
takes_args = ['dir?']
1384
takes_options = ['revision']
1392
1385
aliases = ['up']
1394
def run(self, dir='.'):
1387
def run(self, dir='.', revision=None):
1388
if revision is not None and len(revision) != 1:
1389
raise errors.BzrCommandError(
1390
"bzr update --revision takes exactly one revision")
1395
1391
tree = WorkingTree.open_containing(dir)[0]
1392
branch = tree.branch
1396
1393
possible_transports = []
1397
master = tree.branch.get_master_branch(
1394
master = branch.get_master_branch(
1398
1395
possible_transports=possible_transports)
1399
1396
if master is not None:
1400
1397
tree.lock_write()
1398
branch_location = master.base
1402
1400
tree.lock_tree_write()
1401
branch_location = tree.branch.base
1402
self.add_cleanup(tree.unlock)
1403
# get rid of the final '/' and be ready for display
1404
branch_location = urlutils.unescape_for_display(branch_location[:-1],
1406
existing_pending_merges = tree.get_parent_ids()[1:]
1410
# may need to fetch data into a heavyweight checkout
1411
# XXX: this may take some time, maybe we should display a
1413
old_tip = branch.update(possible_transports)
1414
if revision is not None:
1415
revision_id = revision[0].as_revision_id(branch)
1417
revision_id = branch.last_revision()
1418
if revision_id == _mod_revision.ensure_null(tree.last_revision()):
1419
revno = branch.revision_id_to_revno(revision_id)
1420
note("Tree is up to date at revision %d of branch %s" %
1421
(revno, branch_location))
1423
view_info = _get_view_info_for_change_reporter(tree)
1424
change_reporter = delta._ChangeReporter(
1425
unversioned_filter=tree.is_ignored,
1426
view_info=view_info)
1404
existing_pending_merges = tree.get_parent_ids()[1:]
1405
last_rev = _mod_revision.ensure_null(tree.last_revision())
1406
if last_rev == _mod_revision.ensure_null(
1407
tree.branch.last_revision()):
1408
# may be up to date, check master too.
1409
if master is None or last_rev == _mod_revision.ensure_null(
1410
master.last_revision()):
1411
revno = tree.branch.revision_id_to_revno(last_rev)
1412
note("Tree is up to date at revision %d." % (revno,))
1414
view_info = _get_view_info_for_change_reporter(tree)
1415
1428
conflicts = tree.update(
1416
delta._ChangeReporter(unversioned_filter=tree.is_ignored,
1417
view_info=view_info), possible_transports=possible_transports)
1418
revno = tree.branch.revision_id_to_revno(
1419
_mod_revision.ensure_null(tree.last_revision()))
1420
note('Updated to revision %d.' % (revno,))
1421
if tree.get_parent_ids()[1:] != existing_pending_merges:
1422
note('Your local commits will now show as pending merges with '
1423
"'bzr status', and can be committed with 'bzr commit'.")
1430
possible_transports=possible_transports,
1431
revision=revision_id,
1433
except errors.NoSuchRevision, e:
1434
raise errors.BzrCommandError(
1435
"branch has no revision %s\n"
1436
"bzr update --revision only works"
1437
" for a revision in the branch history"
1439
revno = tree.branch.revision_id_to_revno(
1440
_mod_revision.ensure_null(tree.last_revision()))
1441
note('Updated to revision %d of branch %s' %
1442
(revno, branch_location))
1443
if tree.get_parent_ids()[1:] != existing_pending_merges:
1444
note('Your local commits will now show as pending merges with '
1445
"'bzr status', and can be committed with 'bzr commit'.")
1432
1452
class cmd_info(Command):
1503
1523
file_list = [f for f in file_list]
1505
1525
tree.lock_write()
1507
# Heuristics should probably all move into tree.remove_smart or
1510
added = tree.changes_from(tree.basis_tree(),
1511
specific_files=file_list).added
1512
file_list = sorted([f[0] for f in added], reverse=True)
1513
if len(file_list) == 0:
1514
raise errors.BzrCommandError('No matching files.')
1515
elif file_list is None:
1516
# missing files show up in iter_changes(basis) as
1517
# versioned-with-no-kind.
1519
for change in tree.iter_changes(tree.basis_tree()):
1520
# Find paths in the working tree that have no kind:
1521
if change[1][1] is not None and change[6][1] is None:
1522
missing.append(change[1][1])
1523
file_list = sorted(missing, reverse=True)
1524
file_deletion_strategy = 'keep'
1525
tree.remove(file_list, verbose=verbose, to_file=self.outf,
1526
keep_files=file_deletion_strategy=='keep',
1527
force=file_deletion_strategy=='force')
1526
self.add_cleanup(tree.unlock)
1527
# Heuristics should probably all move into tree.remove_smart or
1530
added = tree.changes_from(tree.basis_tree(),
1531
specific_files=file_list).added
1532
file_list = sorted([f[0] for f in added], reverse=True)
1533
if len(file_list) == 0:
1534
raise errors.BzrCommandError('No matching files.')
1535
elif file_list is None:
1536
# missing files show up in iter_changes(basis) as
1537
# versioned-with-no-kind.
1539
for change in tree.iter_changes(tree.basis_tree()):
1540
# Find paths in the working tree that have no kind:
1541
if change[1][1] is not None and change[6][1] is None:
1542
missing.append(change[1][1])
1543
file_list = sorted(missing, reverse=True)
1544
file_deletion_strategy = 'keep'
1545
tree.remove(file_list, verbose=verbose, to_file=self.outf,
1546
keep_files=file_deletion_strategy=='keep',
1547
force=file_deletion_strategy=='force')
1532
1550
class cmd_file_id(Command):
1754
1772
class cmd_init_repository(Command):
1755
"""Create a shared repository to hold branches.
1773
"""Create a shared repository for branches to share storage space.
1757
1775
New branches created under the repository directory will store their
1758
revisions in the repository, not in the branch directory.
1776
revisions in the repository, not in the branch directory. For branches
1777
with shared history, this reduces the amount of storage needed and
1778
speeds up the creation of new branches.
1760
If the --no-trees option is used then the branches in the repository
1761
will not have working trees by default.
1780
If the --no-trees option is given then the branches in the repository
1781
will not have working trees by default. They will still exist as
1782
directories on disk, but they will not have separate copies of the
1783
files at a certain revision. This can be useful for repositories that
1784
store branches which are interacted with through checkouts or remote
1785
branches, such as on a server.
1764
Create a shared repositories holding just branches::
1788
Create a shared repository holding just branches::
1766
1790
bzr init-repo --no-trees repo
1767
1791
bzr init repo/trunk
2281
2308
filter_by_dir = False
2285
# find the file ids to log and check for directory filtering
2286
b, file_info_list, rev1, rev2 = _get_info_for_log_files(
2287
revision, file_list)
2288
for relpath, file_id, kind in file_info_list:
2290
raise errors.BzrCommandError(
2291
"Path unknown at end or start of revision range: %s" %
2293
# If the relpath is the top of the tree, we log everything
2298
file_ids.append(file_id)
2299
filter_by_dir = filter_by_dir or (
2300
kind in ['directory', 'tree-reference'])
2303
# FIXME ? log the current subdir only RBC 20060203
2304
if revision is not None \
2305
and len(revision) > 0 and revision[0].get_branch():
2306
location = revision[0].get_branch()
2310
# find the file ids to log and check for directory filtering
2311
b, file_info_list, rev1, rev2 = _get_info_for_log_files(
2312
revision, file_list)
2313
self.add_cleanup(b.unlock)
2314
for relpath, file_id, kind in file_info_list:
2316
raise errors.BzrCommandError(
2317
"Path unknown at end or start of revision range: %s" %
2319
# If the relpath is the top of the tree, we log everything
2309
dir, relpath = bzrdir.BzrDir.open_containing(location)
2310
b = dir.open_branch()
2312
rev1, rev2 = _get_revision_range(revision, b, self.name())
2314
# Decide on the type of delta & diff filtering to use
2315
# TODO: add an --all-files option to make this configurable & consistent
2323
diff_type = 'partial'
2327
# Build the log formatter
2328
if log_format is None:
2329
log_format = log.log_formatter_registry.get_default(b)
2330
lf = log_format(show_ids=show_ids, to_file=self.outf,
2331
show_timezone=timezone,
2332
delta_format=get_verbosity_level(),
2334
show_advice=levels is None)
2336
# Choose the algorithm for doing the logging. It's annoying
2337
# having multiple code paths like this but necessary until
2338
# the underlying repository format is faster at generating
2339
# deltas or can provide everything we need from the indices.
2340
# The default algorithm - match-using-deltas - works for
2341
# multiple files and directories and is faster for small
2342
# amounts of history (200 revisions say). However, it's too
2343
# slow for logging a single file in a repository with deep
2344
# history, i.e. > 10K revisions. In the spirit of "do no
2345
# evil when adding features", we continue to use the
2346
# original algorithm - per-file-graph - for the "single
2347
# file that isn't a directory without showing a delta" case.
2348
partial_history = revision and b.repository._format.supports_chks
2349
match_using_deltas = (len(file_ids) != 1 or filter_by_dir
2350
or delta_type or partial_history)
2352
# Build the LogRequest and execute it
2353
if len(file_ids) == 0:
2355
rqst = make_log_request_dict(
2356
direction=direction, specific_fileids=file_ids,
2357
start_revision=rev1, end_revision=rev2, limit=limit,
2358
message_search=message, delta_type=delta_type,
2359
diff_type=diff_type, _match_using_deltas=match_using_deltas)
2360
Logger(b, rqst).show(lf)
2324
file_ids.append(file_id)
2325
filter_by_dir = filter_by_dir or (
2326
kind in ['directory', 'tree-reference'])
2329
# FIXME ? log the current subdir only RBC 20060203
2330
if revision is not None \
2331
and len(revision) > 0 and revision[0].get_branch():
2332
location = revision[0].get_branch()
2335
dir, relpath = bzrdir.BzrDir.open_containing(location)
2336
b = dir.open_branch()
2338
self.add_cleanup(b.unlock)
2339
rev1, rev2 = _get_revision_range(revision, b, self.name())
2341
# Decide on the type of delta & diff filtering to use
2342
# TODO: add an --all-files option to make this configurable & consistent
2350
diff_type = 'partial'
2354
# Build the log formatter
2355
if log_format is None:
2356
log_format = log.log_formatter_registry.get_default(b)
2357
# Make a non-encoding output to include the diffs - bug 328007
2358
unencoded_output = ui.ui_factory.make_output_stream(encoding_type='exact')
2359
lf = log_format(show_ids=show_ids, to_file=self.outf,
2360
to_exact_file=unencoded_output,
2361
show_timezone=timezone,
2362
delta_format=get_verbosity_level(),
2364
show_advice=levels is None)
2366
# Choose the algorithm for doing the logging. It's annoying
2367
# having multiple code paths like this but necessary until
2368
# the underlying repository format is faster at generating
2369
# deltas or can provide everything we need from the indices.
2370
# The default algorithm - match-using-deltas - works for
2371
# multiple files and directories and is faster for small
2372
# amounts of history (200 revisions say). However, it's too
2373
# slow for logging a single file in a repository with deep
2374
# history, i.e. > 10K revisions. In the spirit of "do no
2375
# evil when adding features", we continue to use the
2376
# original algorithm - per-file-graph - for the "single
2377
# file that isn't a directory without showing a delta" case.
2378
partial_history = revision and b.repository._format.supports_chks
2379
match_using_deltas = (len(file_ids) != 1 or filter_by_dir
2380
or delta_type or partial_history)
2382
# Build the LogRequest and execute it
2383
if len(file_ids) == 0:
2385
rqst = make_log_request_dict(
2386
direction=direction, specific_fileids=file_ids,
2387
start_revision=rev1, end_revision=rev2, limit=limit,
2388
message_search=message, delta_type=delta_type,
2389
diff_type=diff_type, _match_using_deltas=match_using_deltas)
2390
Logger(b, rqst).show(lf)
2366
2393
def _get_revision_range(revisionspec_list, branch, command_name):
2511
2536
note("Ignoring files outside view. View is %s" % view_str)
2513
2538
tree.lock_read()
2515
for fp, fc, fkind, fid, entry in tree.list_files(include_root=False,
2516
from_dir=relpath, recursive=recursive):
2517
# Apply additional masking
2518
if not all and not selection[fc]:
2520
if kind is not None and fkind != kind:
2525
fullpath = osutils.pathjoin(relpath, fp)
2528
views.check_path_in_view(tree, fullpath)
2529
except errors.FileOutsideView:
2539
self.add_cleanup(tree.unlock)
2540
for fp, fc, fkind, fid, entry in tree.list_files(include_root=False,
2541
from_dir=relpath, recursive=recursive):
2542
# Apply additional masking
2543
if not all and not selection[fc]:
2545
if kind is not None and fkind != kind:
2550
fullpath = osutils.pathjoin(relpath, fp)
2553
views.check_path_in_view(tree, fullpath)
2554
except errors.FileOutsideView:
2534
fp = osutils.pathjoin(prefix, fp)
2535
kindch = entry.kind_character()
2536
outstring = fp + kindch
2537
ui.ui_factory.clear_term()
2539
outstring = '%-8s %s' % (fc, outstring)
2540
if show_ids and fid is not None:
2541
outstring = "%-50s %s" % (outstring, fid)
2559
fp = osutils.pathjoin(prefix, fp)
2560
kindch = entry.kind_character()
2561
outstring = fp + kindch
2562
ui.ui_factory.clear_term()
2564
outstring = '%-8s %s' % (fc, outstring)
2565
if show_ids and fid is not None:
2566
outstring = "%-50s %s" % (outstring, fid)
2567
self.outf.write(outstring + '\n')
2569
self.outf.write(fp + '\0')
2572
self.outf.write(fid)
2573
self.outf.write('\0')
2581
self.outf.write('%-50s %s\n' % (outstring, my_id))
2542
2583
self.outf.write(outstring + '\n')
2544
self.outf.write(fp + '\0')
2547
self.outf.write(fid)
2548
self.outf.write('\0')
2556
self.outf.write('%-50s %s\n' % (outstring, my_id))
2558
self.outf.write(outstring + '\n')
2563
2586
class cmd_unknowns(Command):
3478
3552
verbose = not is_quiet()
3479
3553
# TODO: should possibly lock the history file...
3480
3554
benchfile = open(".perf_history", "at", buffering=1)
3555
self.add_cleanup(benchfile.close)
3482
3557
test_suite_factory = None
3483
3558
benchfile = None
3485
selftest_kwargs = {"verbose": verbose,
3487
"stop_on_failure": one,
3488
"transport": transport,
3489
"test_suite_factory": test_suite_factory,
3490
"lsprof_timed": lsprof_timed,
3491
"lsprof_tests": lsprof_tests,
3492
"bench_history": benchfile,
3493
"matching_tests_first": first,
3494
"list_only": list_only,
3495
"random_seed": randomize,
3496
"exclude_pattern": exclude,
3498
"load_list": load_list,
3499
"debug_flags": debugflag,
3500
"starting_with": starting_with
3502
selftest_kwargs.update(self.additional_selftest_args)
3503
result = selftest(**selftest_kwargs)
3505
if benchfile is not None:
3559
selftest_kwargs = {"verbose": verbose,
3561
"stop_on_failure": one,
3562
"transport": transport,
3563
"test_suite_factory": test_suite_factory,
3564
"lsprof_timed": lsprof_timed,
3565
"lsprof_tests": lsprof_tests,
3566
"bench_history": benchfile,
3567
"matching_tests_first": first,
3568
"list_only": list_only,
3569
"random_seed": randomize,
3570
"exclude_pattern": exclude,
3572
"load_list": load_list,
3573
"debug_flags": debugflag,
3574
"starting_with": starting_with
3576
selftest_kwargs.update(self.additional_selftest_args)
3577
result = selftest(**selftest_kwargs)
3507
3578
return int(not result)
3684
3763
view_info = _get_view_info_for_change_reporter(tree)
3685
3764
change_reporter = delta._ChangeReporter(
3686
3765
unversioned_filter=tree.is_ignored, view_info=view_info)
3689
pb = ui.ui_factory.nested_progress_bar()
3690
cleanups.append(pb.finished)
3692
cleanups.append(tree.unlock)
3693
if location is not None:
3695
mergeable = bundle.read_mergeable_from_url(location,
3696
possible_transports=possible_transports)
3697
except errors.NotABundle:
3701
raise errors.BzrCommandError('Cannot use --uncommitted'
3702
' with bundles or merge directives.')
3704
if revision is not None:
3705
raise errors.BzrCommandError(
3706
'Cannot use -r with merge directives or bundles')
3707
merger, verified = _mod_merge.Merger.from_mergeable(tree,
3710
if merger is None and uncommitted:
3711
if revision is not None and len(revision) > 0:
3712
raise errors.BzrCommandError('Cannot use --uncommitted and'
3713
' --revision at the same time.')
3714
merger = self.get_merger_from_uncommitted(tree, location, pb,
3716
allow_pending = False
3719
merger, allow_pending = self._get_merger_from_branch(tree,
3720
location, revision, remember, possible_transports, pb)
3722
merger.merge_type = merge_type
3723
merger.reprocess = reprocess
3724
merger.show_base = show_base
3725
self.sanity_check_merger(merger)
3726
if (merger.base_rev_id == merger.other_rev_id and
3727
merger.other_rev_id is not None):
3728
note('Nothing to do.')
3766
pb = ui.ui_factory.nested_progress_bar()
3767
self.add_cleanup(pb.finished)
3769
self.add_cleanup(tree.unlock)
3770
if location is not None:
3772
mergeable = bundle.read_mergeable_from_url(location,
3773
possible_transports=possible_transports)
3774
except errors.NotABundle:
3778
raise errors.BzrCommandError('Cannot use --uncommitted'
3779
' with bundles or merge directives.')
3781
if revision is not None:
3782
raise errors.BzrCommandError(
3783
'Cannot use -r with merge directives or bundles')
3784
merger, verified = _mod_merge.Merger.from_mergeable(tree,
3787
if merger is None and uncommitted:
3788
if revision is not None and len(revision) > 0:
3789
raise errors.BzrCommandError('Cannot use --uncommitted and'
3790
' --revision at the same time.')
3791
merger = self.get_merger_from_uncommitted(tree, location, None)
3792
allow_pending = False
3795
merger, allow_pending = self._get_merger_from_branch(tree,
3796
location, revision, remember, possible_transports, None)
3798
merger.merge_type = merge_type
3799
merger.reprocess = reprocess
3800
merger.show_base = show_base
3801
self.sanity_check_merger(merger)
3802
if (merger.base_rev_id == merger.other_rev_id and
3803
merger.other_rev_id is not None):
3804
note('Nothing to do.')
3807
if merger.interesting_files is not None:
3808
raise errors.BzrCommandError('Cannot pull individual files')
3809
if (merger.base_rev_id == tree.last_revision()):
3810
result = tree.pull(merger.other_branch, False,
3811
merger.other_rev_id)
3812
result.report(self.outf)
3731
if merger.interesting_files is not None:
3732
raise errors.BzrCommandError('Cannot pull individual files')
3733
if (merger.base_rev_id == tree.last_revision()):
3734
result = tree.pull(merger.other_branch, False,
3735
merger.other_rev_id)
3736
result.report(self.outf)
3738
if merger.this_basis is None:
3739
raise errors.BzrCommandError(
3740
"This branch has no commits."
3741
" (perhaps you would prefer 'bzr pull')")
3743
return self._do_preview(merger, cleanups)
3745
return self._do_interactive(merger, cleanups)
3747
return self._do_merge(merger, change_reporter, allow_pending,
3750
for cleanup in reversed(cleanups):
3814
if merger.this_basis is None:
3815
raise errors.BzrCommandError(
3816
"This branch has no commits."
3817
" (perhaps you would prefer 'bzr pull')")
3819
return self._do_preview(merger)
3821
return self._do_interactive(merger)
3823
return self._do_merge(merger, change_reporter, allow_pending,
3753
def _get_preview(self, merger, cleanups):
3826
def _get_preview(self, merger):
3754
3827
tree_merger = merger.make_merger()
3755
3828
tt = tree_merger.make_preview_transform()
3756
cleanups.append(tt.finalize)
3829
self.add_cleanup(tt.finalize)
3757
3830
result_tree = tt.get_preview_tree()
3758
3831
return result_tree
3760
def _do_preview(self, merger, cleanups):
3833
def _do_preview(self, merger):
3761
3834
from bzrlib.diff import show_diff_trees
3762
result_tree = self._get_preview(merger, cleanups)
3835
result_tree = self._get_preview(merger)
3763
3836
show_diff_trees(merger.this_tree, result_tree, self.outf,
3764
3837
old_label='', new_label='')
3954
4028
merge_type = _mod_merge.Merge3Merger
3955
4029
tree, file_list = tree_files(file_list)
3956
4030
tree.lock_write()
3958
parents = tree.get_parent_ids()
3959
if len(parents) != 2:
3960
raise errors.BzrCommandError("Sorry, remerge only works after normal"
3961
" merges. Not cherrypicking or"
3963
repository = tree.branch.repository
3964
interesting_ids = None
3966
conflicts = tree.conflicts()
3967
if file_list is not None:
3968
interesting_ids = set()
3969
for filename in file_list:
3970
file_id = tree.path2id(filename)
3972
raise errors.NotVersionedError(filename)
3973
interesting_ids.add(file_id)
3974
if tree.kind(file_id) != "directory":
4031
self.add_cleanup(tree.unlock)
4032
parents = tree.get_parent_ids()
4033
if len(parents) != 2:
4034
raise errors.BzrCommandError("Sorry, remerge only works after normal"
4035
" merges. Not cherrypicking or"
4037
repository = tree.branch.repository
4038
interesting_ids = None
4040
conflicts = tree.conflicts()
4041
if file_list is not None:
4042
interesting_ids = set()
4043
for filename in file_list:
4044
file_id = tree.path2id(filename)
4046
raise errors.NotVersionedError(filename)
4047
interesting_ids.add(file_id)
4048
if tree.kind(file_id) != "directory":
3977
for name, ie in tree.inventory.iter_entries(file_id):
3978
interesting_ids.add(ie.file_id)
3979
new_conflicts = conflicts.select_conflicts(tree, file_list)[0]
3981
# Remerge only supports resolving contents conflicts
3982
allowed_conflicts = ('text conflict', 'contents conflict')
3983
restore_files = [c.path for c in conflicts
3984
if c.typestring in allowed_conflicts]
3985
_mod_merge.transform_tree(tree, tree.basis_tree(), interesting_ids)
3986
tree.set_conflicts(ConflictList(new_conflicts))
3987
if file_list is not None:
3988
restore_files = file_list
3989
for filename in restore_files:
3991
restore(tree.abspath(filename))
3992
except errors.NotConflicted:
3994
# Disable pending merges, because the file texts we are remerging
3995
# have not had those merges performed. If we use the wrong parents
3996
# list, we imply that the working tree text has seen and rejected
3997
# all the changes from the other tree, when in fact those changes
3998
# have not yet been seen.
3999
pb = ui.ui_factory.nested_progress_bar()
4000
tree.set_parent_ids(parents[:1])
4051
for name, ie in tree.inventory.iter_entries(file_id):
4052
interesting_ids.add(ie.file_id)
4053
new_conflicts = conflicts.select_conflicts(tree, file_list)[0]
4055
# Remerge only supports resolving contents conflicts
4056
allowed_conflicts = ('text conflict', 'contents conflict')
4057
restore_files = [c.path for c in conflicts
4058
if c.typestring in allowed_conflicts]
4059
_mod_merge.transform_tree(tree, tree.basis_tree(), interesting_ids)
4060
tree.set_conflicts(ConflictList(new_conflicts))
4061
if file_list is not None:
4062
restore_files = file_list
4063
for filename in restore_files:
4002
merger = _mod_merge.Merger.from_revision_ids(pb,
4004
merger.interesting_ids = interesting_ids
4005
merger.merge_type = merge_type
4006
merger.show_base = show_base
4007
merger.reprocess = reprocess
4008
conflicts = merger.do_merge()
4010
tree.set_parent_ids(parents)
4065
restore(tree.abspath(filename))
4066
except errors.NotConflicted:
4068
# Disable pending merges, because the file texts we are remerging
4069
# have not had those merges performed. If we use the wrong parents
4070
# list, we imply that the working tree text has seen and rejected
4071
# all the changes from the other tree, when in fact those changes
4072
# have not yet been seen.
4073
tree.set_parent_ids(parents[:1])
4075
merger = _mod_merge.Merger.from_revision_ids(None, tree, parents[1])
4076
merger.interesting_ids = interesting_ids
4077
merger.merge_type = merge_type
4078
merger.show_base = show_base
4079
merger.reprocess = reprocess
4080
conflicts = merger.do_merge()
4082
tree.set_parent_ids(parents)
4014
4083
if conflicts > 0:
4038
4107
name. If you name a directory, all the contents of that directory will be
4041
Any files that have been newly added since that revision will be deleted,
4042
with a backup kept if appropriate. Directories containing unknown files
4043
will not be deleted.
4110
If you have newly added files since the target revision, they will be
4111
removed. If the files to be removed have been changed, backups will be
4112
created as above. Directories containing unknown files will not be
4045
The working tree contains a list of pending merged revisions, which will
4046
be included as parents in the next commit. Normally, revert clears that
4047
list as well as reverting the files. If any files are specified, revert
4048
leaves the pending merge list alone and reverts only the files. Use "bzr
4049
revert ." in the tree root to revert all files but keep the merge record,
4050
and "bzr revert --forget-merges" to clear the pending merge list without
4115
The working tree contains a list of revisions that have been merged but
4116
not yet committed. These revisions will be included as additional parents
4117
of the next commit. Normally, using revert clears that list as well as
4118
reverting the files. If any files are specified, revert leaves the list
4119
of uncommitted merges alone and reverts only the files. Use ``bzr revert
4120
.`` in the tree root to revert all files but keep the recorded merges,
4121
and ``bzr revert --forget-merges`` to clear the pending merge list without
4051
4122
reverting any files.
4124
Using "bzr revert --forget-merges", it is possible to apply all of the
4125
changes from a branch in a single revision. To do this, perform the merge
4126
as desired. Then doing revert with the "--forget-merges" option will keep
4127
the content of the tree as it was, but it will clear the list of pending
4128
merges. The next commit will then contain all of the changes that are
4129
present in the other branch, but without any other parent revisions.
4130
Because this technique forgets where these changes originated, it may
4131
cause additional conflicts on later merges involving the same source and
4054
4135
_see_also = ['cat', 'export']
4223
4302
if remote_branch.base == local_branch.base:
4224
4303
remote_branch = local_branch
4305
local_branch.lock_read()
4306
self.add_cleanup(local_branch.unlock)
4226
4307
local_revid_range = _revision_range_to_revid_range(
4227
4308
_get_revision_range(my_revision, local_branch,
4311
remote_branch.lock_read()
4312
self.add_cleanup(remote_branch.unlock)
4230
4313
remote_revid_range = _revision_range_to_revid_range(
4231
4314
_get_revision_range(revision,
4232
4315
remote_branch, self.name()))
4234
local_branch.lock_read()
4236
remote_branch.lock_read()
4238
local_extra, remote_extra = find_unmerged(
4239
local_branch, remote_branch, restrict,
4240
backward=not reverse,
4241
include_merges=include_merges,
4242
local_revid_range=local_revid_range,
4243
remote_revid_range=remote_revid_range)
4245
if log_format is None:
4246
registry = log.log_formatter_registry
4247
log_format = registry.get_default(local_branch)
4248
lf = log_format(to_file=self.outf,
4250
show_timezone='original')
4253
if local_extra and not theirs_only:
4254
message("You have %d extra revision(s):\n" %
4256
for revision in iter_log_revisions(local_extra,
4257
local_branch.repository,
4259
lf.log_revision(revision)
4260
printed_local = True
4263
printed_local = False
4265
if remote_extra and not mine_only:
4266
if printed_local is True:
4268
message("You are missing %d revision(s):\n" %
4270
for revision in iter_log_revisions(remote_extra,
4271
remote_branch.repository,
4273
lf.log_revision(revision)
4276
if mine_only and not local_extra:
4277
# We checked local, and found nothing extra
4278
message('This branch is up to date.\n')
4279
elif theirs_only and not remote_extra:
4280
# We checked remote, and found nothing extra
4281
message('Other branch is up to date.\n')
4282
elif not (mine_only or theirs_only or local_extra or
4284
# We checked both branches, and neither one had extra
4286
message("Branches are up to date.\n")
4288
remote_branch.unlock()
4290
local_branch.unlock()
4317
local_extra, remote_extra = find_unmerged(
4318
local_branch, remote_branch, restrict,
4319
backward=not reverse,
4320
include_merges=include_merges,
4321
local_revid_range=local_revid_range,
4322
remote_revid_range=remote_revid_range)
4324
if log_format is None:
4325
registry = log.log_formatter_registry
4326
log_format = registry.get_default(local_branch)
4327
lf = log_format(to_file=self.outf,
4329
show_timezone='original')
4332
if local_extra and not theirs_only:
4333
message("You have %d extra revision(s):\n" %
4335
for revision in iter_log_revisions(local_extra,
4336
local_branch.repository,
4338
lf.log_revision(revision)
4339
printed_local = True
4342
printed_local = False
4344
if remote_extra and not mine_only:
4345
if printed_local is True:
4347
message("You are missing %d revision(s):\n" %
4349
for revision in iter_log_revisions(remote_extra,
4350
remote_branch.repository,
4352
lf.log_revision(revision)
4355
if mine_only and not local_extra:
4356
# We checked local, and found nothing extra
4357
message('This branch is up to date.\n')
4358
elif theirs_only and not remote_extra:
4359
# We checked remote, and found nothing extra
4360
message('Other branch is up to date.\n')
4361
elif not (mine_only or theirs_only or local_extra or
4363
# We checked both branches, and neither one had extra
4365
message("Branches are up to date.\n")
4291
4367
if not status_code and parent is None and other_branch is not None:
4292
4368
local_branch.lock_write()
4294
# handle race conditions - a parent might be set while we run.
4295
if local_branch.get_parent() is None:
4296
local_branch.set_parent(remote_branch.base)
4298
local_branch.unlock()
4369
self.add_cleanup(local_branch.unlock)
4370
# handle race conditions - a parent might be set while we run.
4371
if local_branch.get_parent() is None:
4372
local_branch.set_parent(remote_branch.base)
4299
4373
return status_code
4423
4495
bzrdir.BzrDir.open_containing_tree_or_branch(filename)
4424
4496
if wt is not None:
4498
self.add_cleanup(wt.unlock)
4427
4500
branch.lock_read()
4429
tree = _get_one_revision_tree('annotate', revision, branch=branch)
4431
file_id = wt.path2id(relpath)
4433
file_id = tree.path2id(relpath)
4435
raise errors.NotVersionedError(filename)
4436
file_version = tree.inventory[file_id].revision
4437
if wt is not None and revision is None:
4438
# If there is a tree and we're not annotating historical
4439
# versions, annotate the working tree's content.
4440
annotate_file_tree(wt, file_id, self.outf, long, all,
4443
annotate_file(branch, file_version, file_id, long, all, self.outf,
4501
self.add_cleanup(branch.unlock)
4502
tree = _get_one_revision_tree('annotate', revision, branch=branch)
4504
self.add_cleanup(tree.unlock)
4506
file_id = wt.path2id(relpath)
4508
file_id = tree.path2id(relpath)
4510
raise errors.NotVersionedError(filename)
4511
file_version = tree.inventory[file_id].revision
4512
if wt is not None and revision is None:
4513
# If there is a tree and we're not annotating historical
4514
# versions, annotate the working tree's content.
4515
annotate_file_tree(wt, file_id, self.outf, long, all,
4518
annotate_file(branch, file_version, file_id, long, all, self.outf,
4452
4522
class cmd_re_sign(Command):
4968
5039
directly from the merge directive, without retrieving data from a
4971
If --no-bundle is specified, then public_branch is needed (and must be
4972
up-to-date), so that the receiver can perform the merge using the
4973
public_branch. The public_branch is always included if known, so that
4974
people can check it later.
4976
The submit branch defaults to the parent, but can be overridden. Both
4977
submit branch and public branch will be remembered if supplied.
4979
If a public_branch is known for the submit_branch, that public submit
4980
branch is used in the merge instructions. This means that a local mirror
4981
can be used as your actual submit branch, once you have set public_branch
5042
`bzr send` creates a compact data set that, when applied using bzr
5043
merge, has the same effect as merging from the source branch.
5045
By default the merge directive is self-contained and can be applied to any
5046
branch containing submit_branch in its ancestory without needing access to
5049
If --no-bundle is specified, then Bazaar doesn't send the contents of the
5050
revisions, but only a structured request to merge from the
5051
public_location. In that case the public_branch is needed and it must be
5052
up-to-date and accessible to the recipient. The public_branch is always
5053
included if known, so that people can check it later.
5055
The submit branch defaults to the parent of the source branch, but can be
5056
overridden. Both submit branch and public branch will be remembered in
5057
branch.conf the first time they are used for a particular branch. The
5058
source branch defaults to that containing the working directory, but can
5059
be changed using --from.
5061
In order to calculate those changes, bzr must analyse the submit branch.
5062
Therefore it is most efficient for the submit branch to be a local mirror.
5063
If a public location is known for the submit_branch, that location is used
5064
in the merge directive.
5066
The default behaviour is to send the merge directive by mail, unless -o is
5067
given, in which case it is sent to a file.
4984
5069
Mail is sent using your preferred mail program. This should be transparent
4985
5070
on Windows (it uses MAPI). On Linux, it requires the xdg-email utility.
5170
5259
branch, relpath = Branch.open_containing(directory)
5171
5260
branch.lock_write()
5174
branch.tags.delete_tag(tag_name)
5175
self.outf.write('Deleted tag %s.\n' % tag_name)
5261
self.add_cleanup(branch.unlock)
5263
branch.tags.delete_tag(tag_name)
5264
self.outf.write('Deleted tag %s.\n' % tag_name)
5267
if len(revision) != 1:
5268
raise errors.BzrCommandError(
5269
"Tags can only be placed on a single revision, "
5271
revision_id = revision[0].as_revision_id(branch)
5178
if len(revision) != 1:
5179
raise errors.BzrCommandError(
5180
"Tags can only be placed on a single revision, "
5182
revision_id = revision[0].as_revision_id(branch)
5184
revision_id = branch.last_revision()
5185
if (not force) and branch.tags.has_tag(tag_name):
5186
raise errors.TagAlreadyExists(tag_name)
5187
branch.tags.set_tag(tag_name, revision_id)
5188
self.outf.write('Created tag %s.\n' % tag_name)
5273
revision_id = branch.last_revision()
5274
if (not force) and branch.tags.has_tag(tag_name):
5275
raise errors.TagAlreadyExists(tag_name)
5276
branch.tags.set_tag(tag_name, revision_id)
5277
self.outf.write('Created tag %s.\n' % tag_name)
5193
5280
class cmd_tags(Command):
5228
5315
branch.lock_read()
5231
graph = branch.repository.get_graph()
5232
rev1, rev2 = _get_revision_range(revision, branch, self.name())
5233
revid1, revid2 = rev1.rev_id, rev2.rev_id
5234
# only show revisions between revid1 and revid2 (inclusive)
5235
tags = [(tag, revid) for tag, revid in tags if
5236
graph.is_between(revid, revid1, revid2)]
5239
elif sort == 'time':
5241
for tag, revid in tags:
5243
revobj = branch.repository.get_revision(revid)
5244
except errors.NoSuchRevision:
5245
timestamp = sys.maxint # place them at the end
5247
timestamp = revobj.timestamp
5248
timestamps[revid] = timestamp
5249
tags.sort(key=lambda x: timestamps[x[1]])
5251
# [ (tag, revid), ... ] -> [ (tag, dotted_revno), ... ]
5252
for index, (tag, revid) in enumerate(tags):
5254
revno = branch.revision_id_to_dotted_revno(revid)
5255
if isinstance(revno, tuple):
5256
revno = '.'.join(map(str, revno))
5257
except errors.NoSuchRevision:
5258
# Bad tag data/merges can lead to tagged revisions
5259
# which are not in this branch. Fail gracefully ...
5261
tags[index] = (tag, revno)
5316
self.add_cleanup(branch.unlock)
5318
graph = branch.repository.get_graph()
5319
rev1, rev2 = _get_revision_range(revision, branch, self.name())
5320
revid1, revid2 = rev1.rev_id, rev2.rev_id
5321
# only show revisions between revid1 and revid2 (inclusive)
5322
tags = [(tag, revid) for tag, revid in tags if
5323
graph.is_between(revid, revid1, revid2)]
5326
elif sort == 'time':
5328
for tag, revid in tags:
5330
revobj = branch.repository.get_revision(revid)
5331
except errors.NoSuchRevision:
5332
timestamp = sys.maxint # place them at the end
5334
timestamp = revobj.timestamp
5335
timestamps[revid] = timestamp
5336
tags.sort(key=lambda x: timestamps[x[1]])
5338
# [ (tag, revid), ... ] -> [ (tag, dotted_revno), ... ]
5339
for index, (tag, revid) in enumerate(tags):
5341
revno = branch.revision_id_to_dotted_revno(revid)
5342
if isinstance(revno, tuple):
5343
revno = '.'.join(map(str, revno))
5344
except errors.NoSuchRevision:
5345
# Bad tag data/merges can lead to tagged revisions
5346
# which are not in this branch. Fail gracefully ...
5348
tags[index] = (tag, revno)
5264
5350
for tag, revspec in tags:
5265
5351
self.outf.write('%-20s %s\n' % (tag, revspec))