38
38
from bzrlib.workingtree import WorkingTree
41
def tree_files(file_list, default_branch='.'):
41
def tree_files(file_list, default_branch=u'.'):
43
43
return internal_tree_files(file_list, default_branch)
44
44
except FileInWrongBranch, e:
45
45
raise BzrCommandError("%s is not in the same branch as %s" %
46
46
(e.path, file_list[0]))
48
def internal_tree_files(file_list, default_branch='.'):
48
def internal_tree_files(file_list, default_branch=u'.'):
50
50
Return a branch and list of branch-relative paths.
51
51
If supplied file_list is empty or None, the branch default will be used,
142
142
raise BzrCommandError('You can only supply one of revision_id or --revision')
143
143
if revision_id is None and revision is None:
144
144
raise BzrCommandError('You must supply either --revision or a revision_id')
145
b = WorkingTree.open_containing('.')[0].branch
145
b = WorkingTree.open_containing(u'.')[0].branch
146
146
if revision_id is not None:
147
147
sys.stdout.write(b.get_revision_xml(revision_id))
148
148
elif revision is not None:
263
263
def run(self, revision=None, show_ids=False, kind=None):
264
264
if kind and kind not in ['file', 'directory', 'symlink']:
265
265
raise BzrCommandError('invalid kind specified')
266
tree = WorkingTree.open_containing('.')[0]
266
tree = WorkingTree.open_containing(u'.')[0]
267
267
if revision is None:
268
268
inv = tree.read_working_inventory()
375
375
from shutil import rmtree
377
377
# FIXME: too much stuff is in the command class
378
tree_to = WorkingTree.open_containing('.')[0]
378
tree_to = WorkingTree.open_containing(u'.')[0]
379
379
stored_loc = tree_to.branch.get_parent()
380
380
if location is None:
381
381
if stored_loc is None:
396
396
if br_to.get_parent() is None or remember:
397
397
br_to.set_parent(location)
398
note('%d revision(s) pulled.', count)
398
note('%d revision(s) pulled.' % (count,))
400
401
new_rh = tree_to.branch.revision_history()
401
402
if old_rh != new_rh:
441
442
from shutil import rmtree
442
443
from bzrlib.transport import get_transport
444
tree_from = WorkingTree.open_containing('.')[0]
445
tree_from = WorkingTree.open_containing(u'.')[0]
445
446
br_from = tree_from.branch
446
447
stored_loc = tree_from.branch.get_push_location()
447
448
if location is None:
486
487
if br_from.get_push_location() is None or remember:
487
488
br_from.set_push_location(location)
488
489
note('%d revision(s) pushed.' % (count,))
490
492
new_rh = br_to.revision_history()
491
493
if old_rh != new_rh:
785
787
# if the directories are very large...)
787
789
def run(self, show_ids=False):
788
tree = WorkingTree.open_containing('.')[0]
790
tree = WorkingTree.open_containing(u'.')[0]
789
791
old = tree.branch.basis_tree()
790
792
for path, ie in old.inventory.iter_entries():
791
793
if not tree.has_id(ie.file_id):
803
805
from bzrlib.delta import compare_trees
805
tree = WorkingTree.open_containing('.')[0]
807
tree = WorkingTree.open_containing(u'.')[0]
806
808
td = compare_trees(tree.branch.basis_tree(), tree)
808
810
for path, id, kind, text_modified, meta_modified in td.modified:
991
993
selection = {'I':ignored, '?':unknown, 'V':versioned}
993
tree, relpath = WorkingTree.open_containing('.')
995
tree, relpath = WorkingTree.open_containing(u'.')
998
1000
if revision is not None:
1050
1052
from bzrlib.atomicfile import AtomicFile
1053
tree, relpath = WorkingTree.open_containing('.')
1055
tree, relpath = WorkingTree.open_containing(u'.')
1054
1056
ifn = tree.abspath('.bzrignore')
1056
1058
if os.path.exists(ifn):
1090
1092
See also: bzr ignore"""
1091
1093
@display_command
1093
tree = WorkingTree.open_containing('.')[0]
1095
tree = WorkingTree.open_containing(u'.')[0]
1094
1096
for path, file_class, kind, file_id, entry in tree.list_files():
1095
1097
if file_class != 'I':
1115
1117
except ValueError:
1116
1118
raise BzrCommandError("not a valid revision-number: %r" % revno)
1118
print WorkingTree.open_containing('.')[0].branch.get_rev_id(revno)
1120
print WorkingTree.open_containing(u'.')[0].branch.get_rev_id(revno)
1121
1123
class cmd_export(Command):
1145
1147
def run(self, dest, revision=None, format=None, root=None):
1147
1149
from bzrlib.export import export
1148
tree = WorkingTree.open_containing('.')[0]
1150
tree = WorkingTree.open_containing(u'.')[0]
1149
1151
b = tree.branch
1150
1152
if revision is None:
1151
1153
# should be tree.last_revision FIXME
1232
1234
unchanged=False, strict=False):
1233
1235
from bzrlib.errors import (PointlessCommit, ConflictsInTree,
1234
1236
StrictCommitFailed)
1235
from bzrlib.msgeditor import edit_commit_message
1237
from bzrlib.msgeditor import edit_commit_message, \
1238
make_commit_message_template
1236
1239
from bzrlib.status import show_status
1237
from cStringIO import StringIO
1240
from tempfile import TemporaryFile
1243
# TODO: Need a blackbox test for invoking the external editor; may be
1244
# slightly problematic to run this cross-platform.
1246
# TODO: do more checks that the commit will succeed before
1247
# spending the user's valuable time typing a commit message.
1249
# TODO: if the commit *does* happen to fail, then save the commit
1250
# message to a temporary file where it can be recovered
1239
1251
tree, selected_list = tree_files(selected_list)
1240
1252
if message is None and not file:
1241
catcher = StringIO()
1242
show_status(tree.branch, specific_files=selected_list,
1244
message = edit_commit_message(catcher.getvalue())
1253
template = make_commit_message_template(tree, selected_list)
1254
message = edit_commit_message(template)
1246
1255
if message is None:
1247
1256
raise BzrCommandError("please specify a commit message"
1248
1257
" with either --message or --file")
1271
1280
raise BzrCommandError("Commit refused because there are unknown "
1272
1281
"files in the working tree.")
1273
1282
note('Committed revision %d.' % (tree.branch.revno(),))
1276
1285
class cmd_check(Command):
1277
1286
"""Validate consistency of branch history.
1335
1344
@display_command
1336
1345
def run(self, email=False):
1338
b = WorkingTree.open_containing('.')[0].branch
1347
b = WorkingTree.open_containing(u'.')[0].branch
1339
1348
config = bzrlib.config.BranchConfig(b)
1340
1349
except NotBranchError:
1341
1350
config = bzrlib.config.GlobalConfig()
1354
1363
takes_args = ['nickname?']
1355
1364
def run(self, nickname=None):
1356
branch = Branch.open_containing('.')[0]
1365
branch = Branch.open_containing(u'.')[0]
1357
1366
if nickname is None:
1358
1367
self.printme(branch)
1730
1739
if verbose and is_quiet():
1731
1740
raise BzrCommandError('Cannot pass both quiet and verbose')
1733
tree = WorkingTree.open_containing('.')[0]
1742
tree = WorkingTree.open_containing(u'.')[0]
1734
1743
parent = tree.branch.get_parent()
1735
1744
if remote is None:
1736
1745
if parent is None:
1773
1782
takes_options = ['revision', 'long']
1774
1783
takes_args = ['branch?']
1775
1784
@display_command
1776
def run(self, branch='.', revision=None, long=False):
1785
def run(self, branch=u'.', revision=None, long=False):
1777
1786
from bzrlib.testament import Testament
1778
1787
b = WorkingTree.open_containing(branch)[0].branch
1840
1849
raise BzrCommandError('You can only supply one of revision_id or --revision')
1841
1850
if revision_id is None and revision is None:
1842
1851
raise BzrCommandError('You must supply either --revision or a revision_id')
1843
b = WorkingTree.open_containing('.')[0].branch
1852
b = WorkingTree.open_containing(u'.')[0].branch
1844
1853
gpg_strategy = gpg.GPGStrategy(config.BranchConfig(b))
1845
1854
if revision_id is not None:
1846
1855
b.sign_revision(revision_id, gpg_strategy)