~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Jelmer Vernooij
  • Date: 2011-12-14 12:27:44 UTC
  • mfrom: (6364 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6365.
  • Revision ID: jelmer@samba.org-20111214122744-lenqb5sovj192j0u
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
from bzrlib.lazy_import import lazy_import
24
24
lazy_import(globals(), """
25
25
import cStringIO
 
26
import errno
26
27
import sys
27
28
import time
28
29
 
753
754
    """
754
755
 
755
756
    takes_args = ['dir+']
 
757
    takes_options = [
 
758
        Option(
 
759
            'parents',
 
760
            help='No error if existing, make parent directories as needed.',
 
761
            short_name='p'
 
762
            )
 
763
        ]
756
764
    encoding_type = 'replace'
757
765
 
758
 
    def run(self, dir_list):
759
 
        for d in dir_list:
760
 
            wt, dd = WorkingTree.open_containing(d)
761
 
            base = os.path.dirname(dd)
762
 
            id = wt.path2id(base)
763
 
            if id != None:
764
 
                os.mkdir(d)
765
 
                wt.add([dd])
766
 
                if not is_quiet():
767
 
                    self.outf.write(gettext('added %s\n') % d)
 
766
    @classmethod
 
767
    def add_file_with_parents(cls, wt, relpath):
 
768
        if wt.path2id(relpath) is not None:
 
769
            return
 
770
        cls.add_file_with_parents(wt, osutils.dirname(relpath))
 
771
        wt.add([relpath])
 
772
 
 
773
    @classmethod
 
774
    def add_file_single(cls, wt, relpath):
 
775
        wt.add([relpath])
 
776
 
 
777
    def run(self, dir_list, parents=False):
 
778
        if parents:
 
779
            add_file = self.add_file_with_parents
 
780
        else:
 
781
            add_file = self.add_file_single
 
782
        for dir in dir_list:
 
783
            wt, relpath = WorkingTree.open_containing(dir)
 
784
            if parents:
 
785
                try:
 
786
                    os.makedirs(dir)
 
787
                except OSError, e:
 
788
                    if e.errno != errno.EEXIST:
 
789
                        raise
768
790
            else:
769
 
                raise errors.NotVersionedError(path=base)
 
791
                os.mkdir(dir)
 
792
            add_file(wt, relpath)
 
793
            if not is_quiet():
 
794
                self.outf.write(gettext('added %s\n') % dir)
770
795
 
771
796
 
772
797
class cmd_relpath(Command):
6550
6575
    takes_options = [Option('plugin', 
6551
6576
                            help='Export help text from named command '\
6552
6577
                                 '(defaults to all built in commands).',
6553
 
                            type=str)]
 
6578
                            type=str),
 
6579
                     Option('include-duplicates',
 
6580
                            help='Output multiple copies of the same msgid '
 
6581
                                 'string if it appears more than once.'),
 
6582
                            ]
6554
6583
 
6555
 
    def run(self, plugin=None):
 
6584
    def run(self, plugin=None, include_duplicates=False):
6556
6585
        from bzrlib.export_pot import export_pot
6557
 
        export_pot(self.outf, plugin)
 
6586
        export_pot(self.outf, plugin, include_duplicates)
6558
6587
 
6559
6588
 
6560
6589
def _register_lazy_builtins():