Patchwork D8203: logtoprocess: avoid traceback when running long commands

login
register
mail settings
Submitter phabricator
Date March 3, 2020, 6:49 p.m.
Message ID <d31a4ff1adc03e1a0d880c53c2a8c63c@localhost.localdomain>
Download mbox | patch
Permalink /patch/45435/
State Not Applicable
Headers show

Comments

phabricator - March 3, 2020, 6:49 p.m.
Closed by commit rHG69392460f7b1: logtoprocess: avoid traceback when running long commands (authored by valentin.gatienbaron).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8203?vs=20415&id=20433

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D8203/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D8203

AFFECTED FILES
  hgext/logtoprocess.py

CHANGE DETAILS




To: valentin.gatienbaron, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/hgext/logtoprocess.py b/hgext/logtoprocess.py
--- a/hgext/logtoprocess.py
+++ b/hgext/logtoprocess.py
@@ -59,6 +59,13 @@ 
 
     def log(self, ui, event, msg, opts):
         script = self._scripts[event]
+        maxmsg = 100000
+        if len(msg) > maxmsg:
+            # Each env var has a 128KiB limit on linux. msg can be long, in
+            # particular for command event, where it's the full command line.
+            # Prefer truncating the message than raising "Argument list too
+            # long" error.
+            msg = msg[:maxmsg] + b' (truncated)'
         env = {
             b'EVENT': event,
             b'HGPID': os.getpid(),