scripts/release/subversion.py
author Lennard de Rijk <ljvderijk@gmail.com>
Sun, 15 Mar 2009 14:53:00 +0000
changeset 1868 6847be02943a
parent 1849 f8728d5e2e07
child 1888 ef350db7f753
permissions -rw-r--r--
Updated the accepted organization email for GSoC 2009. Left a TODO to use a proper template. Issue 200 addresses a possible solution. Patch by: Lennard de Rijk Reviewed by: to-be-reviewed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1849
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
     1
# Copyright 2009 the Melange authors.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
     2
#
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
     3
# Licensed under the Apache License, Version 2.0 (the "License");
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
     4
# you may not use this file except in compliance with the License.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
     5
# You may obtain a copy of the License at
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
     6
#
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
     7
#   http://www.apache.org/licenses/LICENSE-2.0
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
     8
#
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
     9
# Unless required by applicable law or agreed to in writing, software
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    10
# distributed under the License is distributed on an "AS IS" BASIS,
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    12
# See the License for the specific language governing permissions and
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    13
# limitations under the License.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    14
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    15
"""Subversion commandline wrapper.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    16
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    17
This module provides access to a restricted subset of the Subversion
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    18
commandline tool. The main functionality offered is an object wrapping
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    19
a working copy, providing version control operations within that
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    20
working copy.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    21
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    22
A few standalone commands are also implemented to extract data from
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    23
arbitrary remote repositories.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    24
"""
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    25
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    26
__authors__ = [
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    27
    # alphabetical order by last name, please
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    28
    '"David Anderson" <dave@natulte.net>',
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    29
    ]
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    30
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    31
import error
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    32
import util
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    33
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    34
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    35
def export(url, revision, dest_path):
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    36
  """Export the contents of a repository to a local path.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    37
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    38
  Note that while the underlying 'svn export' only requires a URL, we
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    39
  require that both a URL and a revision be specified, to fully
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    40
  qualify the data to export.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    41
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    42
  Args:
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    43
    url: The repository URL to export.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    44
    revision: The revision to export.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    45
    dest_path: The destination directory for the export. Note that
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    46
               this is an absolute path, NOT a working copy relative
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    47
               path.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    48
    """
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    49
  assert os.path.isabs(dest_path)
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    50
  if os.path.exists(dest_path):
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    51
    raise error.ObstructionError('Cannot export to obstructed path %s' %
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    52
                                 dest_path)
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    53
  util.run(['svn', 'export', '-r', str(revision), url, dest_path])
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    54
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    55
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    56
def find_tag_rev(url):
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    57
  """Return the revision at which a remote tag was created.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    58
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    59
  Since tags are immutable by convention, usually the HEAD of a tag
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    60
  should be the tag creation revision. However, mistakes can happen,
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    61
  so this function will walk the history of the given tag URL,
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    62
  stopping on the first revision that was created by copy.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    63
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    64
  This detection is not foolproof. For example: it will be fooled by a
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    65
  tag that was created, deleted, and recreated by copy at a different
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    66
  revision. It is not clear what the desired behavior in these edge
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    67
  cases are, and no attempt is made to handle them. You should request
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    68
  user confirmation before using the result of this function.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    69
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    70
  Args:
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    71
    url: The repository URL of the tag to examine.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    72
  """
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    73
  try:
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    74
    output = util.run(['svn', 'log', '-q', '--stop-on-copy', url],
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    75
                      capture=True)
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    76
  except util.SubprocessFailed:
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    77
    raise error.ExpectationFailed('No tag at URL ' + url)
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    78
  first_rev_line = output[-2]
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    79
  first_rev = int(first_rev_line.split()[0][1:])
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    80
  return first_rev
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    81
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    82
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    83
def diff(url, revision):
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    84
  """Retrieve a revision from a remote repository as a unified diff.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    85
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    86
  Args:
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    87
    url: The repository URL on which to perform the diff.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    88
    revision: The revision to extract at the given url.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    89
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    90
  Returns:
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    91
    A string containing the changes extracted from the remote
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    92
    repository, in unified diff format suitable for application using
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    93
    'patch'.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    94
  """
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    95
  try:
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    96
    return util.run(['svn', 'diff', '-c', str(revision), url],
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    97
                    capture=True, split_capture=False)
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    98
  except util.SubprocessFailed:
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    99
    raise error.ExpectationFailed('Could not get diff for r%d '
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   100
                                  'from remote repository' % revision)
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   101
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   102
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   103
class WorkingCopy(util.Paths):
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   104
  """Wrapper for operations on a Subversion working copy.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   105
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   106
  An instance of this class is bound to a specific working copy
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   107
  directory, and provides an API to perform various Subversion
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   108
  operations on this working copy.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   109
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   110
  Some methods take a 'depth' argument. Depth in Subversion is a
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   111
  feature that allows the creation of arbitrarily shallow or deep
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   112
  working copies on a per-directory basis. Possible values are
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   113
  'none' (no files or directories), 'files' (only files in .),
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   114
  'immediates' (files and directories in ., directories checked out
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   115
  at depth 'none') or 'infinity' (a normal working copy with
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   116
  everything).
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   117
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   118
  Note that this wrapper also doubles as a Paths object, offering an
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   119
  easy way to get or check the existence of paths in the working
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   120
  copy.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   121
  """
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   122
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   123
  def __init__(self, wc_dir):
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   124
    util.Paths.__init__(self, wc_dir)
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   125
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   126
  def _unknownAndMissing(self, path):
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   127
    """Returns lists of unknown and missing files in the working copy.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   128
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   129
    Args:
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   130
      path: The working copy path to scan.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   131
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   132
    Returns:
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   133
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   134
      Two lists. The first is a list of all unknown paths
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   135
      (subversion has no knowledge of them), the second is a list
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   136
      of missing paths (subversion knows about them, but can't
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   137
      find them). Paths in either list are relative to the input
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   138
      path.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   139
    """
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   140
    assert self.exists()
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   141
    unknown = []
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   142
    missing = []
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   143
    for line in self.status(path):
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   144
      if not line.strip():
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   145
        continue
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   146
      if line[0] == '?':
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   147
        unknown.append(line[7:])
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   148
      elif line[0] == '!':
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   149
        missing.append(line[7:])
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   150
    return unknown, missing
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   151
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   152
  def checkout(self, url, depth='infinity'):
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   153
    """Check out a working copy from the given URL.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   154
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   155
    Args:
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   156
      url: The Subversion repository URL to check out.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   157
      depth: The depth of the working copy root.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   158
    """
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   159
    assert not self.exists()
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   160
    util.run(['svn', 'checkout', '--depth=' + depth, url, self.path()])
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   161
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   162
  def update(self, path='', depth=None):
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   163
    """Update a working copy path, optionally changing depth.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   164
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   165
    Args:
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   166
      path: The working copy path to update.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   167
      depth: If set, change the depth of the path before updating.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   168
    """
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   169
    assert self.exists()
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   170
    if depth is None:
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   171
      util.run(['svn', 'update', self.path(path)])
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   172
    else:
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   173
      util.run(['svn', 'update', '--set-depth=' + depth, self.path(path)])
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   174
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   175
  def revert(self, path=''):
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   176
    """Recursively revert a working copy path.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   177
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   178
    Note that this command is more zealous than the 'svn revert'
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   179
    command, as it will also delete any files which subversion
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   180
    does not know about.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   181
    """
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   182
    util.run(['svn', 'revert', '-R', self.path(path)])
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   183
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   184
    unknown, missing = self._unknownAndMissing(path)
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   185
    unknown = [os.path.join(self.path(path), p) for p in unknown]
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   186
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   187
    if unknown:
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   188
      # rm -rf makes me uneasy. Verify that all paths to be deleted
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   189
      # are within the release working copy.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   190
      for p in unknown:
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   191
        assert p.startswith(self.path())
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   192
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   193
      util.run(['rm', '-rf', '--'] + unknown)
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   194
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   195
  def ls(self, dir=''):
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   196
    """List the contents of a working copy directory.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   197
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   198
    Note that this returns the contents of the directory as seen
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   199
    by the server, not constrained by the depth settings of the
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   200
    local path.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   201
    """
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   202
    assert self.exists()
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   203
    return util.run(['svn', 'ls', self.path(dir)], capture=True)
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   204
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   205
  def copy(self, src, dest):
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   206
    """Copy a working copy path.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   207
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   208
    The copy is only scheduled for commit, not committed.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   209
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   210
    Args:
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   211
      src: The source working copy path.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   212
      dst: The destination working copy path.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   213
    """
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   214
    assert self.exists()
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   215
    util.run(['svn', 'cp', self.path(src), self.path(dest)])
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   216
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   217
  def propget(self, prop_name, path):
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   218
    """Get the value of a property on a working copy path.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   219
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   220
    Args:
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   221
      prop_name: The property name, eg. 'svn:externals'.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   222
      path: The working copy path on which the property is set.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   223
    """
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   224
    assert self.exists()
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   225
    return util.run(['svn', 'propget', prop_name, self.path(path)],
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   226
            capture=True)
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   227
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   228
  def propset(self, prop_name, prop_value, path):
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   229
    """Set the value of a property on a working copy path.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   230
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   231
    The property change is only scheduled for commit, not committed.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   232
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   233
    Args:
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   234
      prop_name: The property name, eg. 'svn:externals'.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   235
      prop_value: The value that should be set.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   236
      path: The working copy path on which to set the property.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   237
    """
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   238
    assert self.exists()
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   239
    util.run(['svn', 'propset', prop_name, prop_value, self.path(path)])
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   240
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   241
  def add(self, paths):
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   242
    """Schedule working copy paths for addition.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   243
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   244
    The paths are only scheduled for addition, not committed.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   245
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   246
    Args:
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   247
      paths: The list of working copy paths to add.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   248
    """
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   249
    assert self.exists()
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   250
    paths = [self.path(p) for p in paths]
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   251
    util.run(['svn', 'add'] + paths)
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   252
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   253
  def remove(self, paths):
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   254
    """Schedule working copy paths for deletion.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   255
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   256
    The paths are only scheduled for deletion, not committed.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   257
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   258
    Args:
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   259
      paths: The list of working copy paths to delete.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   260
    """
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   261
    assert self.exists()
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   262
    paths = [self.path(p) for p in paths]
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   263
    util.run(['svn', 'rm'] + paths)
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   264
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   265
  def status(self, path=''):
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   266
    """Return the status of a working copy path.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   267
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   268
    The status returned is the verbatim output of 'svn status' on
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   269
    the path.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   270
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   271
    Args:
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   272
      path: The path to examine.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   273
    """
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   274
    assert self.exists()
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   275
    return util.run(['svn', 'status', self.path(path)], capture=True)
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   276
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   277
  def addRemove(self, path=''):
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   278
    """Perform an "addremove" operation a working copy path.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   279
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   280
    An "addremove" runs 'svn status' and schedules all the unknown
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   281
    paths (listed as '?') for addition, and all the missing paths
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   282
    (listed as '!') for deletion. Its main use is to synchronize
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   283
    working copy state after applying a patch in unified diff
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   284
    format.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   285
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   286
    Args:
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   287
      path: The path under which unknown/missing files should be
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   288
        added/removed.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   289
    """
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   290
    assert self.exists()
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   291
    unknown, missing = self._unknownAndMissing(path)
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   292
    if unknown:
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   293
      self.add(unknown)
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   294
    if missing:
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   295
      self.remove(missing)
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   296
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   297
  def commit(self, message, path=''):
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   298
    """Commit scheduled changes to the source repository.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   299
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   300
    Args:
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   301
      message: The commit message to use.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   302
      path: The path to commit.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   303
    """
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   304
    assert self.exists()
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   305
    util.run(['svn', 'commit', '-m', message, self.path(path)])