/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Robert Collins
  • Date: 2008-08-08 05:25:58 UTC
  • mto: This revision was merged to the branch mainline in revision 3618.
  • Revision ID: robertc@robertcollins.net-20080808052558-b3xkprmd19buq12s
Teach export how to export a subdirectory. (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
2010
2010
         zip                          .zip
2011
2011
      =================       =========================
2012
2012
    """
2013
 
    takes_args = ['dest', 'branch?']
 
2013
    takes_args = ['dest', 'branch_or_subdir?']
2014
2014
    takes_options = [
2015
2015
        Option('format',
2016
2016
               help="Type of file to export to.",
2020
2020
               type=str,
2021
2021
               help="Name of the root directory inside the exported file."),
2022
2022
        ]
2023
 
    def run(self, dest, branch=None, revision=None, format=None, root=None):
 
2023
    def run(self, dest, branch_or_subdir=None, revision=None, format=None,
 
2024
        root=None):
2024
2025
        from bzrlib.export import export
2025
2026
 
2026
 
        if branch is None:
 
2027
        if branch_or_subdir is None:
2027
2028
            tree = WorkingTree.open_containing(u'.')[0]
2028
2029
            b = tree.branch
 
2030
            subdir = None
2029
2031
        else:
2030
 
            b = Branch.open(branch)
 
2032
            b, subdir = Branch.open_containing(branch_or_subdir)
2031
2033
            
2032
2034
        if revision is None:
2033
2035
            # should be tree.last_revision  FIXME
2038
2040
            rev_id = revision[0].as_revision_id(b)
2039
2041
        t = b.repository.revision_tree(rev_id)
2040
2042
        try:
2041
 
            export(t, dest, format, root)
 
2043
            export(t, dest, format, root, subdir)
2042
2044
        except errors.NoSuchExportFormat, e:
2043
2045
            raise errors.BzrCommandError('Unsupported export format: %s' % e.format)
2044
2046