Show More
@@ -179,17 +179,16 b' def _newchgui(srcui, csystem, attachio):' | |||||
179 | else: |
|
179 | else: | |
180 | self._csystem = csystem |
|
180 | self._csystem = csystem | |
181 |
|
181 | |||
182 |
def system(self, cmd, environ |
|
182 | def _runsystem(self, cmd, environ, cwd, onerr, errprefix, out): | |
183 | errprefix=None): |
|
|||
184 | # fallback to the original system method if the output needs to be |
|
183 | # fallback to the original system method if the output needs to be | |
185 | # captured (to self._buffers), or the output stream is not stdout |
|
184 | # captured (to self._buffers), or the output stream is not stdout | |
186 | # (e.g. stderr, cStringIO), because the chg client is not aware of |
|
185 | # (e.g. stderr, cStringIO), because the chg client is not aware of | |
187 | # these situations and will behave differently (write to stdout). |
|
186 | # these situations and will behave differently (write to stdout). | |
188 |
if ( |
|
187 | if (out is not self.fout | |
189 | or not util.safehasattr(self.fout, 'fileno') |
|
188 | or not util.safehasattr(self.fout, 'fileno') | |
190 | or self.fout.fileno() != util.stdout.fileno()): |
|
189 | or self.fout.fileno() != util.stdout.fileno()): | |
191 |
return |
|
190 | return util.system(cmd, environ=environ, cwd=cwd, onerr=onerr, | |
192 |
|
|
191 | errprefix=errprefix, out=out) | |
193 | self.flush() |
|
192 | self.flush() | |
194 | rc = self._csystem(cmd, util.shellenviron(environ), cwd) |
|
193 | rc = self._csystem(cmd, util.shellenviron(environ), cwd) | |
195 | if rc and onerr: |
|
194 | if rc and onerr: |
@@ -1288,6 +1288,12 b' class ui(object):' | |||||
1288 | if any(s[1] for s in self._bufferstates): |
|
1288 | if any(s[1] for s in self._bufferstates): | |
1289 | out = self |
|
1289 | out = self | |
1290 | with self.timeblockedsection(blockedtag): |
|
1290 | with self.timeblockedsection(blockedtag): | |
|
1291 | return self._runsystem(cmd, environ=environ, cwd=cwd, onerr=onerr, | |||
|
1292 | errprefix=errprefix, out=out) | |||
|
1293 | ||||
|
1294 | def _runsystem(self, cmd, environ, cwd, onerr, errprefix, out): | |||
|
1295 | """actually execute the given shell command (can be overridden by | |||
|
1296 | extensions like chg)""" | |||
1291 |
|
|
1297 | return util.system(cmd, environ=environ, cwd=cwd, onerr=onerr, | |
1292 |
|
|
1298 | errprefix=errprefix, out=out) | |
1293 |
|
1299 |
@@ -32,6 +32,46 b' long socket path' | |||||
32 |
|
32 | |||
33 | $ cd .. |
|
33 | $ cd .. | |
34 |
|
34 | |||
|
35 | editor | |||
|
36 | ------ | |||
|
37 | ||||
|
38 | $ cat >> pushbuffer.py <<EOF | |||
|
39 | > def reposetup(ui, repo): | |||
|
40 | > repo.ui.pushbuffer(subproc=True) | |||
|
41 | > EOF | |||
|
42 | ||||
|
43 | $ chg init editor | |||
|
44 | $ cd editor | |||
|
45 | ||||
|
46 | by default, system() should be redirected to the client: | |||
|
47 | ||||
|
48 | $ touch foo | |||
|
49 | $ CHGDEBUG= HGEDITOR=cat chg ci -Am channeled --edit 2>&1 \ | |||
|
50 | > | egrep "HG:|run 'cat" | |||
|
51 | chg: debug: run 'cat "*"' at '$TESTTMP/editor' (glob) | |||
|
52 | HG: Enter commit message. Lines beginning with 'HG:' are removed. | |||
|
53 | HG: Leave message empty to abort commit. | |||
|
54 | HG: -- | |||
|
55 | HG: user: test | |||
|
56 | HG: branch 'default' | |||
|
57 | HG: added foo | |||
|
58 | ||||
|
59 | but no redirection should be made if output is captured: | |||
|
60 | ||||
|
61 | $ touch bar | |||
|
62 | $ CHGDEBUG= HGEDITOR=cat chg ci -Am bufferred --edit \ | |||
|
63 | > --config extensions.pushbuffer="$TESTTMP/pushbuffer.py" 2>&1 \ | |||
|
64 | > | egrep "HG:|run 'cat" | |||
|
65 | [1] | |||
|
66 | ||||
|
67 | check that commit commands succeeded: | |||
|
68 | ||||
|
69 | $ hg log -T '{rev}:{desc}\n' | |||
|
70 | 1:bufferred | |||
|
71 | 0:channeled | |||
|
72 | ||||
|
73 | $ cd .. | |||
|
74 | ||||
35 | pager |
|
75 | pager | |
36 | ----- |
|
76 | ----- | |
37 |
|
77 |
General Comments 0
You need to be logged in to leave comments.
Login now