Chromium Code Reviews| Index: tools/svn.py |
| =================================================================== |
| --- tools/svn.py (revision 8147) |
| +++ tools/svn.py (working copy) |
| @@ -18,6 +18,13 @@ |
| STATUS_MODIFIED = 0x04 |
| STATUS_NOT_UNDER_SVN_CONTROL = 0x08 |
| + |
| +if os.name == 'nt': |
| + SVN = 'svn.bat' |
|
epoger
2013/03/14 17:48:32
I think this is fine... although I think it worked
borenet
2013/03/14 18:25:18
Actually, my experience with this is that that is
|
| +else: |
| + SVN = 'svn' |
| + |
| + |
| class Svn: |
| def __init__(self, directory): |
| @@ -50,7 +57,7 @@ |
| @param path path (within self._directory) where the local copy will be |
| written |
| """ |
| - return self._RunCommand(['svn', 'checkout', url, path]) |
| + return self._RunCommand([SVN, 'checkout', url, path]) |
| def ListSubdirs(self, url): |
| """Returns a list of all subdirectories (not files) within a given SVN |
| @@ -59,7 +66,7 @@ |
| @param url remote directory to list subdirectories of |
| """ |
| subdirs = [] |
| - filenames = self._RunCommand(['svn', 'ls', url]).split('\n') |
| + filenames = self._RunCommand([SVN, 'ls', url]).split('\n') |
| for filename in filenames: |
| if filename.endswith('/'): |
| subdirs.append(filename.strip('/')) |
| @@ -93,7 +100,7 @@ |
| if status & STATUS_NOT_UNDER_SVN_CONTROL: |
| status_types_string += '\?' |
| status_regex_string = '^[%s].....\s+(.+)$' % status_types_string |
| - stdout = self._RunCommand(['svn', 'status']) |
| + stdout = self._RunCommand([SVN, 'status']) |
| status_regex = re.compile(status_regex_string, re.MULTILINE) |
| files = status_regex.findall(stdout) |
| return files |
| @@ -103,7 +110,7 @@ |
| @param filenames files to add to SVN control |
| """ |
| - self._RunCommand(['svn', 'add'] + filenames) |
| + self._RunCommand([SVN, 'add'] + filenames) |
| def SetProperty(self, filenames, property_name, property_value): |
| """Sets a svn property for these files. |
| @@ -114,7 +121,7 @@ |
| """ |
| if filenames: |
| self._RunCommand( |
| - ['svn', 'propset', property_name, property_value] + filenames) |
| + [SVN, 'propset', property_name, property_value] + filenames) |
| def SetPropertyByFilenamePattern(self, filename_pattern, |
| property_name, property_value): |
| @@ -137,5 +144,20 @@ |
| version you wish to obtain |
| @param dest_path destination to which to write the base content |
| """ |
| - self._RunCommand(['svn', 'export', '--revision', 'BASE', |
| + self._RunCommand([SVN, 'export', '--revision', 'BASE', |
| file_within_repo, dest_path]) |
| + |
| + @staticmethod |
| + def Cat(svn_url): |
|
epoger
2013/03/14 17:48:32
Maybe move this outside of the Svn class declarati
borenet
2013/03/14 18:25:18
Done.
|
| + """Returns the contents of the file at the given svn_url. |
| + |
| + @param svn_url URL of the file to read |
| + """ |
| + proc = subprocess.Popen([SVN, 'cat', svn_url], |
| + stdout=subprocess.PIPE, |
| + stderr=subprocess.STDOUT) |
| + exitcode = proc.wait() |
| + if not exitcode == 0: |
| + raise Exception('Could not retrieve %s. Verify that the URL is valid ' |
| + 'and check your connection.' % svn_url) |
| + return proc.communicate()[0] |