fix some bugs in cvs-commit and improve util.communicate()
--HG-- branch : pmacs2
This commit is contained in:
parent
6d3eab1a47
commit
5a72e293c7
|
@ -16,24 +16,26 @@ class CvsCommit(Method):
|
||||||
w.set_error("Buffer has no corresponding file")
|
w.set_error("Buffer has no corresponding file")
|
||||||
return
|
return
|
||||||
|
|
||||||
cwd = os.getcwd() + os.path.sep
|
cwd = os.getcwd() + os.path.sep
|
||||||
path = w.buffer.path
|
path = w.buffer.path
|
||||||
if path.startswith(cwd):
|
if path.startswith(cwd):
|
||||||
path = path[len(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)
|
status, out, err = util.communicate(cmd)
|
||||||
|
|
||||||
if status == 0:
|
if status != 0:
|
||||||
for line in out.split('\n'):
|
|
||||||
m = self.regex.match(line)
|
|
||||||
if m:
|
|
||||||
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.set_error("Problems with CVS commit: %d" % status)
|
||||||
w.application.data_buffer("*Commit*", data, switch_to=True)
|
w.application.data_buffer("*Commit*", err, switch_to=True)
|
||||||
|
return
|
||||||
|
|
||||||
|
for line in out.split('\n'):
|
||||||
|
m = self.regex.match(line)
|
||||||
|
if not m:
|
||||||
|
continue
|
||||||
|
w.set_error("Committed [%s -> %s]" % (m.group(2), m.group(1)))
|
||||||
|
return
|
||||||
|
w.set_error("Up-to-date")
|
||||||
|
|
||||||
class CvsStatus(Method):
|
class CvsStatus(Method):
|
||||||
regex1 = re.compile('^File: (.+?) *\tStatus: (.*?)$')
|
regex1 = re.compile('^File: (.+?) *\tStatus: (.*?)$')
|
||||||
|
@ -52,7 +54,8 @@ class CvsStatus(Method):
|
||||||
if path.startswith(cwd):
|
if path.startswith(cwd):
|
||||||
path = path[len(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)
|
status, out, err = util.communicate(cmd)
|
||||||
|
|
||||||
if status != 0:
|
if status != 0:
|
||||||
|
@ -114,7 +117,8 @@ class CvsLog(Method):
|
||||||
if path.startswith(cwd):
|
if path.startswith(cwd):
|
||||||
path = path[len(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)
|
status, out, err = util.communicate(cmd)
|
||||||
w.application.data_buffer("*Log*", out, switch_to=True)
|
w.application.data_buffer("*Log*", out, switch_to=True)
|
||||||
w.set_error("cvs log exited with %d" % status)
|
w.set_error("cvs log exited with %d" % status)
|
||||||
|
@ -131,7 +135,8 @@ class CvsDiff(Method):
|
||||||
if path.startswith(cwd):
|
if path.startswith(cwd):
|
||||||
path = path[len(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)
|
status, out, err = util.communicate(cmd)
|
||||||
|
|
||||||
if status == 0:
|
if status == 0:
|
||||||
|
@ -159,7 +164,8 @@ class CvsDiff2(Method):
|
||||||
if path.startswith(cwd):
|
if path.startswith(cwd):
|
||||||
path = path[len(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)
|
status, out, err = util.communicate(cmd)
|
||||||
|
|
||||||
if status == 0:
|
if status == 0:
|
||||||
|
@ -192,7 +198,8 @@ class CvsDiff3(Method):
|
||||||
if path.startswith(cwd):
|
if path.startswith(cwd):
|
||||||
path = path[len(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)
|
status, out, err = util.communicate(cmd)
|
||||||
|
|
||||||
if status == 0:
|
if status == 0:
|
||||||
|
@ -221,7 +228,7 @@ class CvsBlame(Method):
|
||||||
return
|
return
|
||||||
|
|
||||||
cmd = self._get_cmd(w, **vargs)
|
cmd = self._get_cmd(w, **vargs)
|
||||||
status, out, err = util.communicate(cmd, stderr=True, shell=False)
|
status, out, err = util.communicate(cmd)
|
||||||
|
|
||||||
linetokens = []
|
linetokens = []
|
||||||
max_rev = 0
|
max_rev = 0
|
||||||
|
@ -298,7 +305,7 @@ class CvsRevView(Method):
|
||||||
cmd = self._get_cmd(w, **vargs)
|
cmd = self._get_cmd(w, **vargs)
|
||||||
name = self._get_name(w, **vargs)
|
name = self._get_name(w, **vargs)
|
||||||
mname = w.mode.name.lower()
|
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)
|
w.application.data_buffer(name, out, switch_to=True, modename=mname)
|
||||||
|
|
||||||
|
|
2
util.py
2
util.py
|
@ -144,7 +144,7 @@ def decode(s):
|
||||||
pass
|
pass
|
||||||
return s.decode('ascii', 'replace')
|
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:
|
if stderr:
|
||||||
pipe = Popen(cmd, stdout=PIPE, stderr=PIPE, shell=shell)
|
pipe = Popen(cmd, stdout=PIPE, stderr=PIPE, shell=shell)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue