From 73e924d847dd7b6f2db6d66bca1d389a1e2342f2 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Mon, 13 Aug 2012 09:53:04 +0200 Subject: [PATCH] hg: hook system_rcpath and user_rcpath instead of polluting enviroment by setting HGRCPATH --- rc/bin/hg | 16 ++++++++++++---- sys/src/cmd/hg/hg | 16 ++++++++++++---- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/rc/bin/hg b/rc/bin/hg index 9e2cdb0e9..255bdf7b2 100755 --- a/rc/bin/hg +++ b/rc/bin/hg @@ -17,14 +17,22 @@ except ImportError: sys.stderr.write("(check your install and PYTHONPATH)\n") sys.exit(-1) -# PLAN9 hack to keep hgrc in $home/lib -import os -os.environ['HGRCPATH']=os.environ['home']+'/lib/hgrc' - import sys import mercurial.util import mercurial.dispatch +if sys.platform == 'plan9': + def p9sys_rcpath(): + return ['/sys/lib/hgrc'] + + def p9usr_rcpath(): + import os + return [os.environ['home']+'/lib/hgrc'] + + import mercurial.posix + mercurial.posix.system_rcpath = p9sys_rcpath + mercurial.posix.user_rcpath = p9usr_rcpath + for fp in (sys.stdin, sys.stdout, sys.stderr): mercurial.util.set_binary(fp) diff --git a/sys/src/cmd/hg/hg b/sys/src/cmd/hg/hg index 9e2cdb0e9..255bdf7b2 100755 --- a/sys/src/cmd/hg/hg +++ b/sys/src/cmd/hg/hg @@ -17,14 +17,22 @@ except ImportError: sys.stderr.write("(check your install and PYTHONPATH)\n") sys.exit(-1) -# PLAN9 hack to keep hgrc in $home/lib -import os -os.environ['HGRCPATH']=os.environ['home']+'/lib/hgrc' - import sys import mercurial.util import mercurial.dispatch +if sys.platform == 'plan9': + def p9sys_rcpath(): + return ['/sys/lib/hgrc'] + + def p9usr_rcpath(): + import os + return [os.environ['home']+'/lib/hgrc'] + + import mercurial.posix + mercurial.posix.system_rcpath = p9sys_rcpath + mercurial.posix.user_rcpath = p9usr_rcpath + for fp in (sys.stdin, sys.stdout, sys.stderr): mercurial.util.set_binary(fp)