Commits

Steve Losh committed 27a0efe

Moar, but there is a leak somewhere.

  • Participants
  • Parent commits 154deea

Comments (0)

Files changed (5)

File README.markdown

 
 * Mercurial 1.7.2
 * Diesel (`pip install -e git://github.com/jamwt/diesel.git#egg=diesel`)
+* A non-shitty version of netcat (`brew install netcat` on OS X,
+  `PACKAGE_MANAGER install netcat-traditional` on Ubuntu)
 
 License
 -------
-#!/usr/bin/env zsh
+#!/usr/bin/env bash
 
 DIR="`pwd`"
 CMD=""
 
-for ARG in $*
+for ARG in "$@"
 do
-    CMD="$CMD\n$ARG"
+    CMD="$CMD"$'\n'"$ARG"
 done
 
-PAYLOAD="$DIR\n$CMD\nHGDAEMONARGSDONE\n"
+PAYLOAD="$DIR"$'\n'"$CMD"$'\n'"HGDAEMONARGSDONE"$'\n'
 
 echo "$PAYLOAD" | netcat localhost 8029
 
 import sys
 from cStringIO import StringIO
 
+# MERCURIAL DISPATCH MIMICING -----------------------------------------------------
+
 libdir = '@LIBDIR@'
 
 if libdir != '@' 'LIBDIR' '@':
 
 import mercurial.util
 import mercurial.dispatch
+from mercurial import commands
 
 for fp in (sys.stdin, sys.stdout, sys.stderr):
     mercurial.util.set_binary(fp)
 
 
+# FIX MERCURIAL'S BROKEN ALIAS ADDING ---------------------------------------------
+
+def _patched_addaliases(ui, cmdtable):
+    # aliases are processed after extensions have been loaded, so they
+    # may use extension commands. Aliases can also use other alias definitions,
+    # but only if they have been defined prior to the current definition.
+    for alias, definition in ui.configitems('alias'):
+        aliasdef = mercurial.dispatch.cmdalias(alias, definition, cmdtable)
+        if not aliasdef.cmd in cmdtable:
+            cmdtable[aliasdef.cmd] = (aliasdef, aliasdef.opts, aliasdef.help)
+        if aliasdef.norepo:
+            commands.norepo += ' %s' % alias
+mercurial.dispatch.addaliases = _patched_addaliases
+
+
+# REAL HGD CODE STARTS HERE -------------------------------------------------------
 
 def _run(cwd, cmd):
     sys.stdout = out = StringIO()
+    sys.stderr = out
+
     mercurial.dispatch.dispatch(['--cwd', cwd, '--color', 'always'] + cmd)
+
     sys.stdout = sys.__stdout__
+    sys.stderr = sys.__stderr__
+
     return out.getvalue()
 
 def handle_command(remote_addr):
-#!/usr/bin/env zsh
+#!/usr/bin/env bash
 
 echo "DAEMON"
 
-for i in {1..300}
+for i in {1..100}
 do
     ./hd status > /dev/null
 done
-#!/usr/bin/env zsh
+#!/usr/bin/env bash
 
 echo "NORMAL"
 for i in {1..100}