[PATCH 3 of 6] ui: invoke external process with HG_PENDING if transaction is active
FUJIWARA Katsunori
foozy at lares.dti.ne.jp
Wed Oct 14 12:35:18 CDT 2015
# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1444843899 -32400
# Thu Oct 15 02:31:39 2015 +0900
# Node ID 2b4f221f324532e3451c626c153e2b8353cd88bc
# Parent 795039426542deb61dd1ae0b75cebe02c0eebfe3
ui: invoke external process with HG_PENDING if transaction is active
This can centralize passing HG_PENDING to external process into
'ui.system()'.
diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -869,13 +869,26 @@
return t
- def system(self, cmd, environ=None, cwd=None, onerr=None, errprefix=None):
+ def system(self, cmd, environ=None, cwd=None, onerr=None, errprefix=None,
+ repo=None):
'''execute shell command with appropriate output stream. command
output will be redirected if fout is not stdout.
+
+ If 'repo' is specified, external command is executed with
+ 'HG_PENDING' environment variable according to current
+ transaction activity.
'''
out = self.fout
if any(s[1] for s in self._bufferstates):
out = self
+
+ if repo:
+ repo.dirstate.write(repo)
+ tr = repo.currenttransaction()
+ if tr and tr.writepending():
+ environ = environ.copy() # to avoid changing specified dict
+ environ['HG_PENDING'] = repo.root
+
return util.system(cmd, environ=environ, cwd=cwd, onerr=onerr,
errprefix=errprefix, out=out)
More information about the Mercurial-devel
mailing list