##// END OF EJS Templates
chg: refactor ui.system() to be partly overridden...
Yuya Nishihara -
r31107:fbce78c5 default
parent child Browse files
Show More
@@ -179,17 +179,16 b' def _newchgui(srcui, csystem, attachio):'
179 179 else:
180 180 self._csystem = csystem
181 181
182 def system(self, cmd, environ=None, cwd=None, onerr=None,
183 errprefix=None):
182 def _runsystem(self, cmd, environ, cwd, onerr, errprefix, out):
184 183 # fallback to the original system method if the output needs to be
185 184 # captured (to self._buffers), or the output stream is not stdout
186 185 # (e.g. stderr, cStringIO), because the chg client is not aware of
187 186 # these situations and will behave differently (write to stdout).
188 if (any(s[1] for s in self._bufferstates)
187 if (out is not self.fout
189 188 or not util.safehasattr(self.fout, 'fileno')
190 189 or self.fout.fileno() != util.stdout.fileno()):
191 return super(chgui, self).system(cmd, environ, cwd, onerr,
192 errprefix)
190 return util.system(cmd, environ=environ, cwd=cwd, onerr=onerr,
191 errprefix=errprefix, out=out)
193 192 self.flush()
194 193 rc = self._csystem(cmd, util.shellenviron(environ), cwd)
195 194 if rc and onerr:
@@ -1288,8 +1288,14 b' class ui(object):'
1288 1288 if any(s[1] for s in self._bufferstates):
1289 1289 out = self
1290 1290 with self.timeblockedsection(blockedtag):
1291 return util.system(cmd, environ=environ, cwd=cwd, onerr=onerr,
1292 errprefix=errprefix, out=out)
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)"""
1297 return util.system(cmd, environ=environ, cwd=cwd, onerr=onerr,
1298 errprefix=errprefix, out=out)
1293 1299
1294 1300 def traceback(self, exc=None, force=False):
1295 1301 '''print exception traceback if traceback printing enabled or forced.
@@ -32,6 +32,46 b' long socket path'
32 32
33 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 75 pager
36 76 -----
37 77
General Comments 0
You need to be logged in to leave comments. Login now