# HG changeset patch # User Thomas Arendsen Hein # Date 1123175209 -3600 # Node ID b65773f7db4161aaa7340ecd32d69e0dacac4d9a # Parent 232d0616a80ab7e21b97a74e910654e341b71df9 Handle broken pipe on pressing Ctrl-C with e.g. 'hg log|grep something'. diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -1400,7 +1400,14 @@ def dispatch(args): except SignalInterrupt: u.warn("killed!\n") except KeyboardInterrupt: - u.warn("interrupted!\n") + try: + u.warn("interrupted!\n") + except IOError, inst: + if inst.errno == errno.EPIPE: + if u.debugflag: + u.warn("\nbroken pipe\n") + else: + raise except IOError, inst: if hasattr(inst, "code"): u.warn("abort: %s\n" % inst)