scripts/new_branch.py
author Todd Larsen <tlarsen@google.com>
Tue, 10 Jun 2008 16:19:59 +0000
changeset 51 9f288fee8a82
parent 47 a237c3c5763e
permissions -rwxr-xr-x
Changes to address comments by Sverre about the previous commit. Patch by: Todd Larsen Review by: Sverre Rabbelier 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
51
9f288fee8a82 Changes to address comments by Sverre about the previous commit.
Todd Larsen <tlarsen@google.com>
parents: 47
diff changeset
    41
def buildOptionList(defaults={}):
47
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:
51
9f288fee8a82 Changes to address comments by Sverre about the previous commit.
Todd Larsen <tlarsen@google.com>
parents: 47
diff changeset
    45
    defaults: dict of possible pre-loaded default values; default is empty
9f288fee8a82 Changes to address comments by Sverre about the previous commit.
Todd Larsen <tlarsen@google.com>
parents: 47
diff changeset
    46
      dict (which is safe because it is not altered)
47
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    47
  """
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    48
  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
    49
  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
    50
      '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
    51
  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
    52
      '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
    53
  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
    54
      '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
    55
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    56
  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
    57
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    58
  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
    59
    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
    60
  else:
51
9f288fee8a82 Changes to address comments by Sverre about the previous commit.
Todd Larsen <tlarsen@google.com>
parents: 47
diff changeset
    61
    repo_help_msg = 'SVN repository; REQUIRED if a default is missing'
47
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    62
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    63
  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
    64
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    65
  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
    66
    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
    67
  else:
51
9f288fee8a82 Changes to address comments by Sverre about the previous commit.
Todd Larsen <tlarsen@google.com>
parents: 47
diff changeset
    68
    wc_help_msg = 'working copy directory; REQUIRED if a default is missing'
47
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    69
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    70
  return [
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    71
      settings.Option(
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    72
          '-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
    73
          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
    74
      settings.Option(
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    75
          '-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
    76
          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
    77
      settings.Option(
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    78
          '-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
    79
          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
    80
      settings.Option(
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    81
          '-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
    82
      settings.Option(
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    83
          '-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
    84
          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
    85
      settings.Option(
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    86
          '-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
    87
          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
    88
      settings.Option(
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    89
          '-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
    90
          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
    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
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    94
def main(args):
51
9f288fee8a82 Changes to address comments by Sverre about the previous commit.
Todd Larsen <tlarsen@google.com>
parents: 47
diff changeset
    95
  # create parser just for usage info before settings file is read successfully
9f288fee8a82 Changes to address comments by Sverre about the previous commit.
Todd Larsen <tlarsen@google.com>
parents: 47
diff changeset
    96
  usage_parser = settings.OptionParser(option_list=buildOptionList())
9f288fee8a82 Changes to address comments by Sverre about the previous commit.
Todd Larsen <tlarsen@google.com>
parents: 47
diff changeset
    97
47
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    98
  # attempt to read the common trunk/scripts settings file
51
9f288fee8a82 Changes to address comments by Sverre about the previous commit.
Todd Larsen <tlarsen@google.com>
parents: 47
diff changeset
    99
  defaults = settings.readPythonSettingsOrDie(parser=usage_parser)
47
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   100
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   101
  # 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
   102
  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
   103
      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
   104
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   105
  # 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
   106
  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
   107
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   108
  # 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
   109
  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
   110
      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
   111
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   112
  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
   113
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   114
  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
   115
  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
   116
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   117
  # 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
   118
  # 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
   119
  # 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
   120
  def callbackGetLogMessage():
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   121
    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
   122
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   123
  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
   124
  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
   125
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   126
  # 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
   127
  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
   128
    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
   129
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   130
    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
   131
      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
   132
          ['%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
   133
           ' '.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
   134
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   135
  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
   136
    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
   137
        ['%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
   138
         '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
   139
        parser)
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   140
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   141
  # 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
   142
  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
   143
  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
   144
  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
   145
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   146
  return 0
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   147
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   148
a237c3c5763e Script to 'svn cp' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ into a branch.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   149
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
   150
  sys.exit(main(sys.argv))