scripts/release/subversion.py
author Sverre Rabbelier <sverre@rabbelier.nl>
Mon, 07 Sep 2009 20:26:39 +0200
changeset 2871 e440e94a874b
parent 1888 ef350db7f753
permissions -rw-r--r--
revert wrong head
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
1888
ef350db7f753 Style fixes for release modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1849
diff changeset
    31
1849
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    32
import error
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    33
import util
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
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    36
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
    37
  """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
    38
1888
ef350db7f753 Style fixes for release modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1849
diff changeset
    39
  Note that while the underlying 'svn export' only requires a URL, 
ef350db7f753 Style fixes for release modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1849
diff changeset
    40
  we require that both a URL and a revision be specified, to fully
1849
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    41
  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
    42
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    43
  Args:
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
    44
    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
    45
    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
    46
    dest_path: The destination directory for the export. Note that
1888
ef350db7f753 Style fixes for release modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1849
diff changeset
    47
      this is an absolute path, NOT a working copy relative path.
1849
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
      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
   134
      (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
   135
      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
   136
      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
   137
      path.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   138
    """
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   139
    assert self.exists()
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   140
    unknown = []
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   141
    missing = []
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   142
    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
   143
      if not line.strip():
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   144
        continue
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   145
      if line[0] == '?':
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   146
        unknown.append(line[7:])
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   147
      elif line[0] == '!':
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   148
        missing.append(line[7:])
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   149
    return unknown, missing
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   150
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   151
  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
   152
    """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
   153
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   154
    Args:
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   155
      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
   156
      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
   157
    """
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   158
    assert not self.exists()
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   159
    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
   160
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   161
  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
   162
    """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
   163
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   164
    Args:
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   165
      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
   166
      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
   167
    """
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   168
    assert self.exists()
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   169
    if depth is None:
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   170
      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
   171
    else:
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   172
      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
   173
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   174
  def revert(self, path=''):
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   175
    """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
   176
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   177
    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
   178
    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
   179
    does not know about.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   180
    """
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   181
    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
   182
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   183
    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
   184
    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
   185
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   186
    if unknown:
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   187
      # 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
   188
      # 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
   189
      for p in unknown:
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   190
        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
   191
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   192
      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
   193
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   194
  def ls(self, dir=''):
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   195
    """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
   196
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   197
    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
   198
    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
   199
    local path.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   200
    """
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   201
    assert self.exists()
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   202
    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
   203
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   204
  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
   205
    """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
   206
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   207
    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
   208
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   209
    Args:
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   210
      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
   211
      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
   212
    """
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   213
    assert self.exists()
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   214
    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
   215
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   216
  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
   217
    """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
   218
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   219
    Args:
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   220
      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
   221
      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
   222
    """
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   223
    assert self.exists()
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   224
    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
   225
            capture=True)
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   226
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   227
  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
   228
    """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
   229
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   230
    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
   231
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   232
    Args:
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   233
      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
   234
      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
   235
      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
   236
    """
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   237
    assert self.exists()
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   238
    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
   239
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   240
  def add(self, paths):
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   241
    """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
   242
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   243
    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
   244
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   245
    Args:
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   246
      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
   247
    """
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   248
    assert self.exists()
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   249
    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
   250
    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
   251
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   252
  def remove(self, paths):
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   253
    """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
   254
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   255
    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
   256
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   257
    Args:
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   258
      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
   259
    """
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   260
    assert self.exists()
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   261
    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
   262
    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
   263
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   264
  def status(self, path=''):
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   265
    """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
   266
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   267
    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
   268
    the path.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   269
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   270
    Args:
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   271
      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
   272
    """
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   273
    assert self.exists()
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   274
    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
   275
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   276
  def addRemove(self, path=''):
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   277
    """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
   278
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   279
    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
   280
    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
   281
    (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
   282
    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
   283
    format.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   284
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   285
    Args:
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   286
      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
   287
        added/removed.
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   288
    """
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   289
    assert self.exists()
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   290
    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
   291
    if unknown:
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   292
      self.add(unknown)
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   293
    if missing:
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   294
      self.remove(missing)
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   295
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   296
  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
   297
    """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
   298
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   299
    Args:
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   300
      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
   301
      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
   302
    """
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   303
    assert self.exists()
f8728d5e2e07 Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff changeset
   304
    util.run(['svn', 'commit', '-m', message, self.path(path)])