2 # -*- coding: utf-8 -*-
4 # Copyright 2004-2007 Zuza Software Foundation
6 # This file is part of translate.
8 # translate is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
13 # translate is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with translate; if not, write to the Free Software
20 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 from translate
.storage
.versioncontrol
import run_command
24 from translate
.storage
.versioncontrol
import GenericRevisionControlSystem
26 class svn(GenericRevisionControlSystem
):
27 """Class to manage items under revision control of Subversion."""
32 def update(self
, revision
=None):
33 """update the working copy - remove local modifications if necessary"""
34 # revert the local copy (remove local changes)
35 command
= ["svn", "revert", self
.location_abs
]
36 exitcode
, output_revert
, error
= run_command(command
)
39 raise IOError("[SVN] Subversion error running '%s': %s" \
41 # update the working copy to the given revision
42 command
= ["svn", "update"]
43 if not revision
is None:
44 command
.extend(["-r", revision
])
45 # the filename is the last argument
46 command
.append(self
.location_abs
)
47 exitcode
, output_update
, error
= run_command(command
)
49 raise IOError("[SVN] Subversion error running '%s': %s" \
51 return output_revert
+ output_update
53 def commit(self
, message
=None):
54 """commit the file and return the given message if present"""
55 command
= ["svn", "-q", "--non-interactive", "commit"]
57 command
.extend(["-m", message
])
58 # the location is the last argument
59 command
.append(self
.location_abs
)
60 exitcode
, output
, error
= run_command(command
)
62 raise IOError("[SVN] Error running SVN command '%s': %s" % (command
, error
))
65 def getcleanfile(self
, revision
=None):
66 """return the content of the 'head' revision of the file"""
67 command
= ["svn", "cat"]
68 if not revision
is None:
69 command
.extend(["-r", revision
])
70 # the filename is the last argument
71 command
.append(self
.location_abs
)
72 exitcode
, output
, error
= run_command(command
)
74 raise IOError("[SVN] Subversion error running '%s': %s" % (command
, error
))