scripts/app_image.py
author Todd Larsen <tlarsen@google.com>
Fri, 06 Jun 2008 03:25:08 +0000
changeset 45 66c450a53786
child 48 39e1c8a54b37
permissions -rw-r--r--
Module for new_branch.py and related scripts to manipulate Google App Engine "image" directories. Patch by: Todd Larsen TO BE REVIEWED Review issue: 282 Review URL: http://codereviews.googleopensourceprograms.com/282
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
45
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     1
#!/usr/bin/python2.5
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     2
#
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     3
# Copyright 2008 the Melange authors.
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     4
#
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     5
# Licensed under the Apache License, Version 2.0 (the "License");
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     6
# you may not use this file except in compliance with the License.
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     7
# You may obtain a copy of the License at
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     8
#
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     9
#   http://www.apache.org/licenses/LICENSE-2.0
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    10
#
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    11
# Unless required by applicable law or agreed to in writing, software
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    12
# distributed under the License is distributed on an "AS IS" BASIS,
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    14
# See the License for the specific language governing permissions and
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    15
# limitations under the License.
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    16
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    17
"""Functions used by multiple scripts to form Google App Engine images.
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    18
"""
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    19
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    20
__authors__ = [
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    21
  # alphabetical order by last name, please
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    22
  '"Todd Larsen" <tlarsen@google.com>',
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    23
]
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    24
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    25
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    26
from trunk.scripts import svn_helper
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    27
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    28
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    29
def getRepoAppPath(repo, app):
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    30
  """Returns path to specified Melange app in the supplied svn repository.
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    31
  """
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    32
  return '%strunk/apps/%s' % (repo, app)
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    33
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    34
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    35
def getRepoThirdPartyPath(repo):
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    36
  """Returns path to third-party packages in the supplied svn repository.
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    37
  """
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    38
  return '%sthirdparty/' % repo
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    39
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    40
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    41
def getThirdPartyPackageNames(pkg_path, **kwargs):
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    42
  """Returns a list of third-party packages in the supplied URL.
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    43
  """
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    44
  return [pkg for pkg in svn_helper.lsDirs(pkg_path, **kwargs)
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    45
            if not pkg.startswith('_')]
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    46
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    47
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    48
def getRepoFrameworksPath(repo):
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    49
  """Returns path to Melange framework packages in the supplied svn repository.
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    50
  """
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    51
  return '%strunk/' % repo
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    52
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    53
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    54
def getFrameworksNames():
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    55
  """Returns a list of Melange framework packages (currently a static list).
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    56
  """
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    57
  return ['soc/']
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    58
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    59
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    60
def formDefaultAppBranchPath(branch, user, src, dest):
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    61
  """Returns a relative path to a to-be-created App Image branch.
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    62
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    63
  Args:
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    64
    branch: explicit branch name, if it was specified (or None, '', etc.
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    65
      instead, if it was not)
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    66
    user: subdirectory of /users/ representing a particular contributor
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    67
    src: sub-directory name of the specific Melange application to branch
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    68
    dest: alternate destination sub-directory name of the Melange application
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    69
      in its new, branched location, if it was specified (or None, '', etc.
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    70
      instead, if it was not)
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    71
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    72
  Returns:
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    73
    * branch if it was specified ("non-False"), or
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    74
    * users/user/dest if dest was specified, or
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    75
    * users/user/src otherwise
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    76
  """
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    77
  if not branch:
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    78
    if dest:
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    79
      branch = 'users/%s%s' % (user, dest)
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    80
    else:
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    81
      branch = 'users/%s%s' % (user, src)
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    82
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    83
  return branch
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    84
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    85
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    86
def branchFromSrcApp(app, repo, dest, verbose=1, **svn_kwargs):
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    87
  """Branch one Melange app in /trunk/apps/ to form basis of App Engine image.
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    88
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    89
  Args:
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    90
    app: Melange application name in /trunk/apps/
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    91
    repo: svn repository root URL
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    92
    dest: working copy destination path of the image branch
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    93
    verbose: print status if greater than 0; default is 1
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    94
    **svn_kwargs: keyword arguments passed on to svn_helper.branchDir()
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    95
  """
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    96
  repo_app = getRepoAppPath(repo, app)
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    97
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    98
  if verbose > 0:
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    99
    print 'Branching %s from:\n %s\nto:\n %s\n' % (app, repo_app, dest)
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   100
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   101
  svn_helper.branchDir(repo_app, dest, **svn_kwargs)
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   102
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   103
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   104
def branchFromThirdParty(repo, dest, verbose=1, **svn_kwargs):
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   105
  """Branch all subdirectories in /thirdparty/ into a new App Engine image.
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   106
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   107
  Subdirectories (except for those with names beginning with underscores) in
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   108
  /thirdparty/ represent third-party packages that are to be placed in each
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   109
  Google App Engine "image" branch.  Files in the root of /thirdparty/ (that
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   110
  is, not in a package) and, as previously mentioned, subdrectories beginning
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   111
  with underscores, are *not* branched.
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   112
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   113
  Args:
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   114
    repo: svn repository root URL
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   115
    dest: working copy destination path of the image branch
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   116
    verbose: print status if greater than 0; default is 1
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   117
    **svn_kwargs: keyword arguments passed on to svn_helper.branchItems()
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   118
  """
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   119
  pkg_dir = getRepoThirdPartyPath(repo)
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   120
  packages = getThirdPartyPackageNames(pkg_dir)
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   121
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   122
  if verbose > 0:
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   123
    print 'Branching third-party packages:\n %s\nfrom:\n %s\ninto:\n %s\n' % (
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   124
        '  '.join(packages), pkg_dir, dest)
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   125
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   126
  svn_helper.branchItems(pkg_dir, dest, packages, **svn_kwargs)
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   127
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   128
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   129
def branchFromFramework(repo, dest, verbose=1, **svn_kwargs):
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   130
  """Branch the SoC framework into a new App Engine image branch.
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   131
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   132
  The SoC framework current consists of only the contents of /trunk/soc/.
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   133
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   134
  Args:
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   135
    repo: svn repository root URL
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   136
    dest: working copy destination path of the image branch
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   137
    verbose: print status if greater than 0; default is 1
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   138
    **svn_kwargs: keyword arguments passed on to svn_helper.branchItems()
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   139
  """
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   140
  framework_dir = getRepoFrameworksPath(repo)
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   141
  packages = getFrameworksNames()
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   142
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   143
  if verbose > 0:
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   144
    print 'Branching framework components:\n %s\nfrom:\n %s\ninto:\n %s\n' % (
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   145
      '  '.join(packages), framework_dir, dest)
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   146
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   147
  svn_helper.branchItems(framework_dir, dest, packages, **svn_kwargs)
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   148
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   149
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   150
def exportFromSrcApp(app, repo, dest, verbose=1, **svn_kwargs):
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   151
  """Export one Melange app in /trunk/apps/ to form basis of App Engine image.
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   152
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   153
  Args:
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   154
    app: Melange application name in /trunk/apps/
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   155
    repo: svn repository root URL
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   156
    dest: local filesystem destination path of the exported image
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   157
    verbose: print status if greater than 0; default is 1
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   158
    **svn_kwargs: keyword arguments passed on to svn_helper.exportDir()
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   159
  """
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   160
  repo_app = getRepoAppPath(repo, app)
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   161
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   162
  if verbose > 0:
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   163
    print 'Exporting %s from:\n %s\nto:\n %s\n' % (app, repo_app, dest)
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   164
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   165
  svn_helper.exportDir(repo_app, dest, **svn_kwargs)
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   166
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   167
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   168
def exportFromThirdParty(repo, dest, verbose=1, **svn_kwargs):
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   169
  """Export all subdirectories in /thirdparty/ into a new App Engine image.
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   170
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   171
  Subdirectories (except for those with names beginning with underscores) in
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   172
  /thirdparty/ represent third-party packages that are to be placed in each
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   173
  Google App Engine "image".  Files in the root of /thirdparty/ (that is,
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   174
  not in a package) and, as previously mentioned, subdirectories beginning
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   175
  with underscores, are *not* exported.
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   176
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   177
  Args:
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   178
    repo: svn repository root URL
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   179
    dest: local filesystem destination path of the exported image
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   180
    verbose: print status if greater than 0; default is 1
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   181
    **svn_kwargs: keyword arguments passed on to svn_helper.exportItems()
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   182
  """
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   183
  pkg_dir = getRepoThirdPartyPath(repo)
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   184
  packages = getThirdPartyPackageNames(pkg_dir)
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   185
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   186
  if verbose > 0:
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   187
    print 'Exporting third-party packages:\n %s\nfrom:\n %s\ninto:\n  %s\n' % (
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   188
        '  '.join(packages), pkg_dir, dest)
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   189
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   190
  svn_helper.exportItems(pkg_dir, dest, packages, **svn_kwargs)
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   191
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   192
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   193
def exportFromFramework(repo, dest, verbose=1, **svn_kwargs):
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   194
  """Export the SoC framework into a new App Engine image.
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   195
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   196
  The SoC framework current consists of only the contents of /trunk/soc/.
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   197
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   198
  Args:
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   199
    repo: svn repository root URL
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   200
    dest: local filesystem destination path of the exported image
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   201
    verbose: print status if greater than 0; default is 1
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   202
    **svn_kwargs: keyword arguments passed on to svn_helper.exportItems()
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   203
  """
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   204
  framework_dir = getRepoFrameworksPath(repo)
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   205
  packages = getFrameworksNames()
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   206
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   207
  if verbose > 0:
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   208
    print 'Exporting framework components:\n %s\nfrom:\n %s\ninto:\n %s\n' % (
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   209
        '  '.join(packages), framework_dir, dest)
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   210
66c450a53786 Module for new_branch.py and related scripts to manipulate Google App Engine
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   211
  svn_helper.exportItems(framework_dir, dest, packages, **svn_kwargs)