scripts/new_branch.py
author Todd Larsen <tlarsen@google.com>
Fri, 06 Jun 2008 04:30:49 +0000
changeset 47 a237c3c5763e
child 51 9f288fee8a82
permissions -rwxr-xr-x
Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch. Patch by: Todd Larsen TO BE REVIEWED Review issue: 341 Review URL: http://codereviews.googleopensourceprograms.com/341
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
47
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     1
#!/usr/bin/python2.5
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     2
#
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     3
# Copyright 2008 the Melange authors.
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     4
#
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     5
# Licensed under the Apache License, Version 2.0 (the "License");
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     6
# you may not use this file except in compliance with the License.
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     7
# You may obtain a copy of the License at
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     8
#
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     9
#   http://www.apache.org/licenses/LICENSE-2.0
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    10
#
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    11
# Unless required by applicable law or agreed to in writing, software
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    12
# distributed under the License is distributed on an "AS IS" BASIS,
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    14
# See the License for the specific language governing permissions and
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    15
# limitations under the License.
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    16
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    17
"""Script to make a Google App Engine "image" branch of a Melange application.
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    18
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    19
For details:
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    20
  trunk/scripts/new_branch.py --help
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    21
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    22
Default values for flags can be specified in valid Python syntax in the
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    23
~/.soc_scripts_settings file.  See settings.py for details.
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    24
"""
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    25
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    26
__authors__ = [
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    27
  # alphabetical order by last name, please
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    28
  '"Todd Larsen" <tlarsen@google.com>',
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    29
]
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    30
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    31
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    32
import sys
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    33
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    34
import pysvn
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    35
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    36
from trunk.scripts import app_image
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    37
from trunk.scripts import settings
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    38
from trunk.scripts import svn_helper
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    39
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    40
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    41
def buildOptionList(defaults):
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    42
  """Returns a list of command-line settings.Options for this script.
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    43
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    44
  Args:
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    45
    defaults: dict of possible pre-loaded default values (may be empty)
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    46
  """
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    47
  help_user = defaults.get('user', '<user>')
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    48
  user_help_msg = (
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    49
      'user name, used for default /users/%s/ branch' % help_user)
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    50
  dest_help_msg = (
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    51
      'if supplied, new name of branched app, users/%s/<dest>' % help_user)
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    52
  branch_help_msg = (
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    53
      'destination branch, defaults to <wc>/users/%s/<src|dest>' % help_user)
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    54
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    55
  def_repo = defaults.get('repo')
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    56
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    57
  if def_repo:
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    58
    repo_help_msg = 'SVN repository; default is %s' % def_repo
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    59
  else:
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    60
    repo_help_msg = 'SVN repository; REQUIRED if default unavailable'
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    61
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    62
  def_wc = defaults.get('wc')
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    63
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    64
  if def_wc:
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    65
    wc_help_msg = 'working copy directory; default is %s' % def_wc
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    66
  else:
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    67
    wc_help_msg = 'working copy directory; REQUIRED if default unavailable'
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    68
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    69
  return [
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    70
      settings.Option(
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    71
          '-R', '--repo', action='store', dest='repo',
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    72
          default=def_repo, help=repo_help_msg),
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    73
      settings.Option(
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    74
          '-w', '--wc', action='store', dest='wc',
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    75
          default=def_wc, help=wc_help_msg),
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    76
      settings.Option(
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    77
          '-s', '--src', action='store', dest='src', required=True,
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    78
          help='(REQUIRED) name of source app in /trunk/apps/ to branch'),
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    79
      settings.Option(
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    80
          '-d', '--dest', action='store', dest='dest', help=dest_help_msg),
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    81
      settings.Option(
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    82
          '-u', '--user', action='store', dest='user',
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    83
          default=defaults.get('user'), help=user_help_msg),
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    84
      settings.Option(
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    85
          '-b', '--branch', action='store', dest='branch',
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    86
          help=branch_help_msg),
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    87
      settings.Option(
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    88
          '-r', '--rev', type='int', action='store', dest='rev',
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    89
          default=None, help='optional revision number on which to branch'),
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    90
  ]
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    91
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    92
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    93
def main(args):
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    94
  # attempt to read the common trunk/scripts settings file
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    95
  defaults = settings.readPythonSettingsOrDie(
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    96
      parser=settings.OptionParser(option_list=buildOptionList({})))
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    97
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    98
  # create the command-line options parser
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    99
  parser = settings.makeOptionParserOrDie(
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   100
      option_list=buildOptionList(defaults))
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   101
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   102
  # parse the command-line options
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   103
  options, args = settings.parseOptionsOrDie(parser, args)
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   104
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   105
  # ensure that various paths end with the / separator
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   106
  src, dest, user, repo, wc = svn_helper.formatDirPaths(
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   107
      options.src, options.dest, options.user, options.repo, options.wc)
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   108
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   109
  settings.checkCommonSvnOptionsOrDie(options, parser)
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   110
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   111
  branch = app_image.formDefaultAppBranchPath(options.branch, user, src, dest)
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   112
  branch_path = svn_helper.getExpandedWorkingCopyPath(branch, wc_root=wc)
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   113
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   114
  # setup a callback used by pysvn if it needs a log message (it actually
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   115
  # should not be needed, since nothing is being committed, but exceptions
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   116
  # were being raised by pysvn without it)
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   117
  def callbackGetLogMessage():
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   118
    return True, 'trunk/apps/%s application branched to %s' % (src, branch)
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   119
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   120
  client = svn_helper.getPySvnClient()
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   121
  client.callback_get_log_message = callbackGetLogMessage
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   122
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   123
  # validate choice of "image" branch location
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   124
  if not options.branch:
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   125
    users = svn_helper.lsDirs(repo + 'users/')
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   126
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   127
    if user not in users:
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   128
      return settings.printErrorsAndUsage(
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   129
          ['%susers/%s not found; existing users are:' % (repo, user),
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   130
           ' '.join(users)], parser)
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   131
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   132
  if svn_helper.exists(branch_path):
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   133
    return settings.printErrorsAndUsage(
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   134
        ['%s already exists;' % branch_path,
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   135
         'use merge_branch.py to update instead'],
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   136
        parser)
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   137
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   138
  # branch trunk/apps/<src> first, so parent destination directory will exist
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   139
  app_image.branchFromSrcApp(src, repo, branch_path, rev=options.rev)
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   140
  app_image.branchFromThirdParty(repo, branch_path, rev=options.rev)
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   141
  app_image.branchFromFramework(repo, branch_path, rev=options.rev)
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   142
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   143
  return 0
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   144
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   145
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   146
if __name__ == '__main__':
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   147
  sys.exit(main(sys.argv))