--HG--
branch : pmacs2
This commit is contained in:
moculus 2008-03-16 23:27:16 +00:00
parent c1ff2c53be
commit abdfd2d502
1 changed files with 74 additions and 0 deletions

View File

@ -1104,6 +1104,80 @@ class FileDiff(Method):
else:
w.application.data_buffer("*Diff*", errdata, switch_to=True)
w.set_error("There was an error: %d exited with status %s" % (pid, status))
class SvnCommit(Method):
'''diff the current file with the version in SVN'''
args = [Argument("msg", type=type(""), prompt="Commit Message: ")]
regex = re.compile('^new revision: ([0-9.]+); previous revision: ([0-9.]+)$')
def _execute(self, w, **vargs):
if not hasattr(w.buffer, 'path'):
w.set_error("Buffer has no corresponding file")
return
cwd = os.getcwd() + os.path.sep
path = w.buffer.path
if path.startswith(cwd):
path = path[len(cwd):]
cmd = "svn ci -m %r %r" % (vargs['msg'], path)
(status, data) = commands.getstatusoutput(cmd)
status = status >> 8
lines = data.split('\n')
try:
if status == 0:
raise Exception
for line in lines:
m = self.regex.match(lines[-1])
if m:
w.set_error("Committed [%s -> %s]" % (m.group(2), m.group(1)))
return
w.set_error("Up-to-date")
except:
w.set_error("Problems with SVN commit: %d" % status)
w.application.data_buffer("*Commit*", data, switch_to=True)
class SvnStatus(Method):
column = {
' ': 'Unmodified',
'A': 'Added',
'C': 'Conflicted',
'D': 'Deleted',
'I': 'Ignored',
'M': 'Modified',
'R': 'Replaced',
'X': 'External',
'?': 'Unknown',
'!': 'Missing',
'~': 'Obstructed',
}
def _execute(self, w, **vargs):
if not hasattr(w.buffer, 'path'):
w.set_error("Buffer has no corresponding file")
return
cwd = os.getcwd() + os.path.sep
path = w.buffer.path
if path.startswith(cwd):
path = path[len(cwd):]
cmd = "svn status -v %r" % path
(status, data) = commands.getstatusoutput(cmd)
status = status >> 8
if status != 0:
w.set_error("Problems with 'svn status': %d" % status)
return
c = data[0]
status = self.column.get(c, 'Error (%s)' % c)
fields = data[6:].split()
try:
(rrev, lrev, lauthor, filename) = fields
except:
raise Exception, '%r %r' % (fields, data[6:])
w.set_error('%s %s %s/%s [%s]' % (filename, status, rrev, lrev, lauthor))
class SvnDiff(Method):
'''diff the current file with the version in SVN'''
def _execute(self, w, **vargs):