758
755
takes_args = ['dir+']
762
help='No error if existing, make parent directories as needed.',
766
756
encoding_type = 'replace'
769
def add_file_with_parents(cls, wt, relpath):
770
if wt.path2id(relpath) is not None:
772
cls.add_file_with_parents(wt, osutils.dirname(relpath))
776
def add_file_single(cls, wt, relpath):
779
def run(self, dir_list, parents=False):
781
add_file = self.add_file_with_parents
783
add_file = self.add_file_single
785
wt, relpath = WorkingTree.open_containing(dir)
790
if e.errno != errno.EEXIST:
758
def run(self, dir_list):
760
wt, dd = WorkingTree.open_containing(d)
761
base = os.path.dirname(dd)
762
id = wt.path2id(base)
767
self.outf.write(gettext('added %s\n') % d)
794
add_file(wt, relpath)
796
self.outf.write(gettext('added %s\n') % dir)
769
raise errors.NotVersionedError(path=base)
799
772
class cmd_relpath(Command):
1251
1224
if location is None:
1252
1225
stored_loc = br_from.get_push_location()
1253
1226
if stored_loc is None:
1254
parent_loc = br_from.get_parent()
1256
raise errors.BzrCommandError(gettext(
1257
"No push location known or specified. To push to the "
1258
"parent branch (at %s), use 'bzr push :parent'." %
1259
urlutils.unescape_for_display(parent_loc,
1260
self.outf.encoding)))
1262
raise errors.BzrCommandError(gettext(
1263
"No push location known or specified."))
1227
raise errors.BzrCommandError(gettext(
1228
"No push location known or specified."))
1265
1230
display_url = urlutils.unescape_for_display(stored_loc,
1266
1231
self.outf.encoding)
1443
1408
self.outf.encoding).rstrip("/"))
1445
1410
dir = controldir.ControlDir.open_containing(location)[0]
1447
active_branch = dir.open_branch(name=None)
1448
except errors.NotBranchError:
1449
active_branch = None
1450
branches = dir.get_branches()
1452
for name, branch in branches.iteritems():
1455
active = (active_branch is not None and
1456
active_branch.base == branch.base)
1457
names[name] = active
1458
# Only mention the current branch explicitly if it's not
1459
# one of the colocated branches
1460
if not any(names.values()) and active_branch is not None:
1461
self.outf.write("* %s\n" % gettext("(default)"))
1462
for name in sorted(names.keys()):
1463
active = names[name]
1411
for branch in dir.list_branches():
1412
if branch.name is None:
1413
self.outf.write(gettext(" (default)\n"))
1468
self.outf.write("%s %s\n" % (
1469
prefix, name.encode(self.outf.encoding)))
1415
self.outf.write(" %s\n" % branch.name.encode(
1416
self.outf.encoding))
1472
1419
class cmd_checkout(Command):
3201
3148
Option('per-file-timestamps',
3202
3149
help='Set modification time of files to that of the last '
3203
3150
'revision in which it was changed.'),
3204
Option('uncommitted',
3205
help='Export the working tree contents rather than that of the '
3208
3152
def run(self, dest, branch_or_subdir=None, revision=None, format=None,
3209
root=None, filters=False, per_file_timestamps=False, uncommitted=False,
3153
root=None, filters=False, per_file_timestamps=False, directory=u'.'):
3211
3154
from bzrlib.export import export
3213
3156
if branch_or_subdir is None:
3214
branch_or_subdir = directory
3216
(tree, b, subdir) = controldir.ControlDir.open_containing_tree_or_branch(
3218
if tree is not None:
3219
self.add_cleanup(tree.lock_read().unlock)
3223
raise errors.BzrCommandError(
3224
gettext("--uncommitted requires a working tree"))
3157
tree = WorkingTree.open_containing(directory)[0]
3227
export_tree = _get_one_revision_tree('export', revision, branch=b, tree=tree)
3161
b, subdir = Branch.open_containing(branch_or_subdir)
3164
rev_tree = _get_one_revision_tree('export', revision, branch=b, tree=tree)
3229
export(export_tree, dest, format, root, subdir, filtered=filters,
3166
export(rev_tree, dest, format, root, subdir, filtered=filters,
3230
3167
per_file_timestamps=per_file_timestamps)
3231
3168
except errors.NoSuchExportFormat, e:
3232
raise errors.BzrCommandError(
3233
gettext('Unsupported export format: %s') % e.format)
3169
raise errors.BzrCommandError(gettext('Unsupported export format: %s') % e.format)
3236
3172
class cmd_cat(Command):
3739
3675
if directory is None:
3740
3676
# use branch if we're inside one; otherwise global config
3742
c = Branch.open_containing(u'.')[0].get_config_stack()
3678
c = Branch.open_containing(u'.')[0].get_config()
3743
3679
except errors.NotBranchError:
3744
c = _mod_config.GlobalStack()
3680
c = _mod_config.GlobalConfig()
3746
c = Branch.open(directory).get_config_stack()
3747
identity = c.get('email')
3682
c = Branch.open(directory).get_config()
3749
self.outf.write(_mod_config.extract_email_address(identity)
3684
self.outf.write(c.user_email() + '\n')
3752
self.outf.write(identity + '\n')
3686
self.outf.write(c.username() + '\n')
3766
3700
# use global config unless --branch given
3768
3702
if directory is None:
3769
c = Branch.open_containing(u'.')[0].get_config_stack()
3703
c = Branch.open_containing(u'.')[0].get_config()
3771
c = Branch.open(directory).get_config_stack()
3705
c = Branch.open(directory).get_config()
3773
c = _mod_config.GlobalStack()
3774
c.set('email', name)
3707
c = _mod_config.GlobalConfig()
3708
c.set_user_option('email', name)
3777
3711
class cmd_nick(Command):
5086
5020
def _run(self, b, revision_id_list, revision):
5087
5021
import bzrlib.gpg as gpg
5088
gpg_strategy = gpg.GPGStrategy(b.get_config_stack())
5022
gpg_strategy = gpg.GPGStrategy(b.get_config())
5089
5023
if revision_id_list is not None:
5090
5024
b.repository.start_write_group()
6605
6539
takes_options = [Option('plugin',
6606
6540
help='Export help text from named command '\
6607
6541
'(defaults to all built in commands).',
6609
Option('include-duplicates',
6610
help='Output multiple copies of the same msgid '
6611
'string if it appears more than once.'),
6614
def run(self, plugin=None, include_duplicates=False):
6544
def run(self, plugin=None):
6615
6545
from bzrlib.export_pot import export_pot
6616
export_pot(self.outf, plugin, include_duplicates)
6546
export_pot(self.outf, plugin)
6619
6549
def _register_lazy_builtins():