755
758
takes_args = ['dir+']
762
help='No error if existing, make parent directories as needed.',
756
766
encoding_type = 'replace'
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)
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:
769
raise errors.NotVersionedError(path=base)
794
add_file(wt, relpath)
796
self.outf.write(gettext('added %s\n') % dir)
772
799
class cmd_relpath(Command):
3148
3175
Option('per-file-timestamps',
3149
3176
help='Set modification time of files to that of the last '
3150
3177
'revision in which it was changed.'),
3178
Option('uncommitted',
3179
help='Export the working tree contents rather than that of the '
3152
3182
def run(self, dest, branch_or_subdir=None, revision=None, format=None,
3153
root=None, filters=False, per_file_timestamps=False, directory=u'.'):
3183
root=None, filters=False, per_file_timestamps=False, uncommitted=False,
3154
3185
from bzrlib.export import export
3156
3187
if branch_or_subdir is None:
3157
tree = WorkingTree.open_containing(directory)[0]
3188
branch_or_subdir = directory
3190
(tree, b, subdir) = controldir.ControlDir.open_containing_tree_or_branch(
3192
if tree is not None:
3193
self.add_cleanup(tree.lock_read().unlock)
3197
raise errors.BzrCommandError(
3198
gettext("--uncommitted requires a working tree"))
3161
b, subdir = Branch.open_containing(branch_or_subdir)
3164
rev_tree = _get_one_revision_tree('export', revision, branch=b, tree=tree)
3201
export_tree = _get_one_revision_tree('export', revision, branch=b, tree=tree)
3166
export(rev_tree, dest, format, root, subdir, filtered=filters,
3203
export(export_tree, dest, format, root, subdir, filtered=filters,
3167
3204
per_file_timestamps=per_file_timestamps)
3168
3205
except errors.NoSuchExportFormat, e:
3169
raise errors.BzrCommandError(gettext('Unsupported export format: %s') % e.format)
3206
raise errors.BzrCommandError(
3207
gettext('Unsupported export format: %s') % e.format)
3172
3210
class cmd_cat(Command):
3675
3713
if directory is None:
3676
3714
# use branch if we're inside one; otherwise global config
3678
c = Branch.open_containing(u'.')[0].get_config()
3716
c = Branch.open_containing(u'.')[0].get_config_stack()
3679
3717
except errors.NotBranchError:
3680
c = _mod_config.GlobalConfig()
3718
c = _mod_config.GlobalStack()
3682
c = Branch.open(directory).get_config()
3720
c = Branch.open(directory).get_config_stack()
3721
identity = c.get('email')
3684
self.outf.write(c.user_email() + '\n')
3723
self.outf.write(_mod_config.extract_email_address(identity)
3686
self.outf.write(c.username() + '\n')
3726
self.outf.write(identity + '\n')
3700
3740
# use global config unless --branch given
3702
3742
if directory is None:
3703
c = Branch.open_containing(u'.')[0].get_config()
3743
c = Branch.open_containing(u'.')[0].get_config_stack()
3705
c = Branch.open(directory).get_config()
3745
c = Branch.open(directory).get_config_stack()
3707
c = _mod_config.GlobalConfig()
3708
c.set_user_option('email', name)
3747
c = _mod_config.GlobalStack()
3748
c.set('email', name)
3711
3751
class cmd_nick(Command):
5020
5060
def _run(self, b, revision_id_list, revision):
5021
5061
import bzrlib.gpg as gpg
5022
gpg_strategy = gpg.GPGStrategy(b.get_config())
5062
gpg_strategy = gpg.GPGStrategy(b.get_config_stack())
5023
5063
if revision_id_list is not None:
5024
5064
b.repository.start_write_group()
6539
6579
takes_options = [Option('plugin',
6540
6580
help='Export help text from named command '\
6541
6581
'(defaults to all built in commands).',
6583
Option('include-duplicates',
6584
help='Output multiple copies of the same msgid '
6585
'string if it appears more than once.'),
6544
def run(self, plugin=None):
6588
def run(self, plugin=None, include_duplicates=False):
6545
6589
from bzrlib.export_pot import export_pot
6546
export_pot(self.outf, plugin)
6590
export_pot(self.outf, plugin, include_duplicates)
6549
6593
def _register_lazy_builtins():