mercurial/ui.py
changeset 31954 e518192d6bac
parent 31778 ac69675fff1c
child 31956 c13ff31818b0
--- a/mercurial/ui.py	Thu Apr 13 14:48:18 2017 -0400
+++ b/mercurial/ui.py	Thu Apr 13 08:27:19 2017 -0700
@@ -854,13 +854,18 @@
         if not pagercmd:
             return
 
+        pagerenv = {}
+        for name, value in rcutil.defaultpagerenv().items():
+            if name not in encoding.environ:
+                pagerenv[name] = value
+
         self.debug('starting pager for command %r\n' % command)
         self.flush()
 
         wasformatted = self.formatted()
         if util.safehasattr(signal, "SIGPIPE"):
             signal.signal(signal.SIGPIPE, _catchterm)
-        if self._runpager(pagercmd):
+        if self._runpager(pagercmd, pagerenv):
             self.pageractive = True
             # Preserve the formatted-ness of the UI. This is important
             # because we mess with stdout, which might confuse
@@ -879,7 +884,7 @@
             # warning about a missing pager command.
             self.disablepager()
 
-    def _runpager(self, command):
+    def _runpager(self, command, env=None):
         """Actually start the pager and set up file descriptors.
 
         This is separate in part so that extensions (like chg) can
@@ -912,7 +917,8 @@
             pager = subprocess.Popen(
                 command, shell=shell, bufsize=-1,
                 close_fds=util.closefds, stdin=subprocess.PIPE,
-                stdout=util.stdout, stderr=util.stderr)
+                stdout=util.stdout, stderr=util.stderr,
+                env=util.shellenviron(env))
         except OSError as e:
             if e.errno == errno.ENOENT and not shell:
                 self.warn(_("missing pager command '%s', skipping pager\n")