~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-08-11 03:39:25 UTC
  • mfrom: (3613.2.2 export)
  • Revision ID: pqm@pqm.ubuntu.com-20080811033925-rwcu69eiq0zg0buv
(robertc) Teach export to export subdirectories as well as entire
        branches. (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
2018
2018
         zip                          .zip
2019
2019
      =================       =========================
2020
2020
    """
2021
 
    takes_args = ['dest', 'branch?']
 
2021
    takes_args = ['dest', 'branch_or_subdir?']
2022
2022
    takes_options = [
2023
2023
        Option('format',
2024
2024
               help="Type of file to export to.",
2028
2028
               type=str,
2029
2029
               help="Name of the root directory inside the exported file."),
2030
2030
        ]
2031
 
    def run(self, dest, branch=None, revision=None, format=None, root=None):
 
2031
    def run(self, dest, branch_or_subdir=None, revision=None, format=None,
 
2032
        root=None):
2032
2033
        from bzrlib.export import export
2033
2034
 
2034
 
        if branch is None:
 
2035
        if branch_or_subdir is None:
2035
2036
            tree = WorkingTree.open_containing(u'.')[0]
2036
2037
            b = tree.branch
 
2038
            subdir = None
2037
2039
        else:
2038
 
            b = Branch.open(branch)
 
2040
            b, subdir = Branch.open_containing(branch_or_subdir)
2039
2041
            
2040
2042
        if revision is None:
2041
2043
            # should be tree.last_revision  FIXME
2046
2048
            rev_id = revision[0].as_revision_id(b)
2047
2049
        t = b.repository.revision_tree(rev_id)
2048
2050
        try:
2049
 
            export(t, dest, format, root)
 
2051
            export(t, dest, format, root, subdir)
2050
2052
        except errors.NoSuchExportFormat, e:
2051
2053
            raise errors.BzrCommandError('Unsupported export format: %s' % e.format)
2052
2054