fix some bugs in cvs-commit and improve util.communicate()

--HG--
branch : pmacs2
This commit is contained in:
Erik Osheim 2009-11-10 16:30:35 -05:00
parent 6d3eab1a47
commit 5a72e293c7
2 changed files with 26 additions and 19 deletions

View File

@ -21,19 +21,21 @@ class CvsCommit(Method):
if path.startswith(cwd):
path = path[len(cwd):]
cmd = "cvs ci -m %r %r" % (vargs['msg'], path)
cmd = ["cvs", "ci", "-m", vargs['msg'], path]
status, out, err = util.communicate(cmd)
if status == 0:
if status != 0:
w.set_error("Problems with CVS commit: %d" % status)
w.application.data_buffer("*Commit*", err, switch_to=True)
return
for line in out.split('\n'):
m = self.regex.match(line)
if m:
if not m:
continue
w.set_error("Committed [%s -> %s]" % (m.group(2), m.group(1)))
return
w.set_error("Up-to-date")
else:
w.set_error("Problems with CVS commit: %d" % status)
w.application.data_buffer("*Commit*", data, switch_to=True)
class CvsStatus(Method):
regex1 = re.compile('^File: (.+?) *\tStatus: (.*?)$')
@ -52,7 +54,8 @@ class CvsStatus(Method):
if path.startswith(cwd):
path = path[len(cwd):]
cmd = "cvs status %r" % path
#cmd = "cvs status %r" % path
cmd = ['cvs', 'status', path]
status, out, err = util.communicate(cmd)
if status != 0:
@ -114,7 +117,8 @@ class CvsLog(Method):
if path.startswith(cwd):
path = path[len(cwd):]
cmd = "cvs log %r" % path
#cmd = "cvs log %r" % path
cmd = ['cvs', 'log', path]
status, out, err = util.communicate(cmd)
w.application.data_buffer("*Log*", out, switch_to=True)
w.set_error("cvs log exited with %d" % status)
@ -131,7 +135,8 @@ class CvsDiff(Method):
if path.startswith(cwd):
path = path[len(cwd):]
cmd = "cvs diff -u %r" % path
#cmd = "cvs diff -u %r" % path
cmd = ['cvs', 'diff', '-u', path]
status, out, err = util.communicate(cmd)
if status == 0:
@ -159,7 +164,8 @@ class CvsDiff2(Method):
if path.startswith(cwd):
path = path[len(cwd):]
cmd = "cvs diff -r %s -u %r" % (rev, path)
#cmd = "cvs diff -r %s -u %r" % (rev, path)
cmd = ["cvs", "diff", "-r", rev, "-u", path]
status, out, err = util.communicate(cmd)
if status == 0:
@ -192,7 +198,8 @@ class CvsDiff3(Method):
if path.startswith(cwd):
path = path[len(cwd):]
cmd = "cvs diff -r %s -r %s -u %r" % (rev1, rev2, path)
#cmd = "cvs diff -r %s -r %s -u %r" % (rev1, rev2, path)
cmd = ["cvs", "diff", "-r", rev1, "-r", rev2, "-u", path]
status, out, err = util.communicate(cmd)
if status == 0:
@ -221,7 +228,7 @@ class CvsBlame(Method):
return
cmd = self._get_cmd(w, **vargs)
status, out, err = util.communicate(cmd, stderr=True, shell=False)
status, out, err = util.communicate(cmd)
linetokens = []
max_rev = 0
@ -298,7 +305,7 @@ class CvsRevView(Method):
cmd = self._get_cmd(w, **vargs)
name = self._get_name(w, **vargs)
mname = w.mode.name.lower()
status, out, err = util.communicate(cmd, stderr=True, shell=False)
status, out, err = util.communicate(cmd)
w.application.data_buffer(name, out, switch_to=True, modename=mname)

View File

@ -144,7 +144,7 @@ def decode(s):
pass
return s.decode('ascii', 'replace')
def communicate(cmd, stdin=None, stderr=False, shell=True):
def communicate(cmd, stdin=None, stderr=True, shell=False):
if stderr:
pipe = Popen(cmd, stdout=PIPE, stderr=PIPE, shell=shell)
else: