Mercurial > hg
changeset 4689:54a2b94a372c
merge with main
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Sat, 23 Jun 2007 21:11:28 +0200 |
parents | 39001f4b7d99 (diff) 8f91264f154a (current diff) |
children | ecea4de3104e |
files | |
diffstat | 7 files changed, 51 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/hgk Sat Jun 23 14:02:41 2007 -0500 +++ b/contrib/hgk Sat Jun 23 21:11:28 2007 +0200 @@ -43,7 +43,7 @@ } if [catch { set parse_args [concat --default HEAD $revargs] - set parse_temp [eval exec hg debug-rev-parse $parse_args] + set parse_temp [eval exec {$env(HG)} debug-rev-parse $parse_args] regsub -all "\r\n" $parse_temp "\n" parse_temp set parsed_args [split $parse_temp "\n"] } err] { @@ -57,7 +57,7 @@ set parsed_args [concat -n $limit $parsed_args] } if [catch { - set commfd [open "|hg debug-rev-list --header --topo-order --parents $parsed_args" r] + set commfd [open "|{$env(HG)} debug-rev-list --header --topo-order --parents $parsed_args" r] } err] { puts stderr "Error executing hg debug-rev-list: $err" exit 1 @@ -179,7 +179,8 @@ } proc readcommit {id} { - if [catch {set contents [exec hg debug-cat-file commit $id]}] return + global env + if [catch {set contents [exec $env(HG) debug-cat-file commit $id]}] return parsecommit $id $contents 0 {} } @@ -258,9 +259,9 @@ } proc readrefs {} { - global tagids idtags headids idheads tagcontents + global tagids idtags headids idheads tagcontents env - set tags [exec hg tags] + set tags [exec $env(HG) tags] regsub -all "\r\n" $tags "\n" tags set lines [split $tags "\n"] foreach f $lines { @@ -1713,6 +1714,7 @@ global findprocpid findprocfile global finddidsel ctext lineid findinprogress global findinsertpos + global env if {$numcommits == 0} return @@ -1732,7 +1734,7 @@ } if {[catch { - set f [open [list | hg debug-diff-tree --stdin -s -r -S$findstring \ + set f [open [list | $env(HG) debug-diff-tree --stdin -s -r -S$findstring \ << $inputids] r] } err]} { error_popup "Error starting search process: $err" @@ -1804,6 +1806,7 @@ global findinprogress findstartline findinsertpos global treediffs fdiffids fdiffsneeded fdiffpos global findmergefiles + global env if {$numcommits == 0} return @@ -1835,7 +1838,7 @@ # start off a git-diff-tree process if needed if {$diffsneeded ne {}} { if {[catch { - set df [open [list | hg debug-diff-tree -r --stdin << $diffsneeded] r] + set df [open [list | $env(HG) debug-diff-tree -r --stdin << $diffsneeded] r] } err ]} { error_popup "Error starting search process: $err" return @@ -2252,13 +2255,14 @@ } proc findgca {ids} { + global env set gca {} foreach id $ids { if {$gca eq {}} { set gca $id } else { if {[catch { - set gca [exec hg debug-merge-base $gca $id] + set gca [exec $env(HG) debug-merge-base $gca $id] } err]} { return {} } @@ -2332,6 +2336,7 @@ global cflist diffmergeid mergefilelist parents global diffopts diffinhunk currentfile currenthunk filelines global diffblocked groupfilelast mergefds groupfilenum grouphunks + global env set files $mergefilelist($diffmergeid) foreach f $files { @@ -2346,7 +2351,7 @@ catch {unset grouphunks} set groupfilelast -1 foreach p $parents($diffmergeid) { - set cmd [list | hg debug-diff-tree -p $p $diffmergeid] + set cmd [list | $env(HG) debug-diff-tree -p $p $diffmergeid] set cmd [concat $cmd $mergefilelist($diffmergeid)] if {[catch {set f [open $cmd r]} err]} { error_popup "Error getting diffs: $err" @@ -2785,12 +2790,12 @@ } proc gettreediffs {ids} { - global treediff parents treepending + global treediff parents treepending env set treepending $ids set treediff {} set id [lindex $ids 0] set p [lindex $ids 1] - if [catch {set gdtf [open "|hg debug-diff-tree -r $p $id" r]}] return + if [catch {set gdtf [open "|{$env(HG)} debug-diff-tree -r $p $id" r]}] return fconfigure $gdtf -blocking 0 fileevent $gdtf readable [list gettreediffline $gdtf $ids] } @@ -2826,7 +2831,7 @@ set id [lindex $ids 0] set p [lindex $ids 1] set env(GIT_DIFF_OPTS) $diffopts - set cmd [list | hg debug-diff-tree -r -p -C $p $id] + set cmd [list | $env(HG) debug-diff-tree -r -p -C $p $id] if {[catch {set bdf [open $cmd r]} err]} { puts "error getting diffs: $err" return @@ -3409,12 +3414,12 @@ } proc mkpatchgo {} { - global patchtop + global patchtop env set oldid [$patchtop.fromsha1 get] set newid [$patchtop.tosha1 get] set fname [$patchtop.fname get] - if {[catch {exec hg debug-diff-tree -p $oldid $newid >$fname &} err]} { + if {[catch {exec $env(HG) debug-diff-tree -p $oldid $newid >$fname &} err]} { error_popup "Error creating patch: $err" } catch {destroy $patchtop} @@ -3473,7 +3478,7 @@ return } if {[catch { - set out [exec hg tag -r $id $tag] + set out [exec $env(HG) tag -r $id $tag] } err]} { error_popup "Error creating tag: $err" return @@ -3549,7 +3554,7 @@ set id [$wrcomtop.sha1 get] set cmd "echo $id | [$wrcomtop.cmd get]" set fname [$wrcomtop.fname get] - if {[catch {exec sh -c $cmd >$fname &} err]} { + if {[catch {exec sh -c $cmd > $fname &} err]} { error_popup "Error writing commit: $err" } catch {destroy $wrcomtop} @@ -3635,7 +3640,7 @@ set datemode 0 set boldnames 0 set diffopts "-U 5 -p" -set wrcomcmd "hg debug-diff-tree --stdin -p --pretty" +set wrcomcmd "\"\$HG\" debug-diff-tree --stdin -p --pretty" set mainfont {Helvetica 9} set textfont {Courier 9}
--- a/hgeditor Sat Jun 23 14:02:41 2007 -0500 +++ b/hgeditor Sat Jun 23 21:11:28 2007 +0200 @@ -35,7 +35,7 @@ ( grep '^HG: changed' "$1" | cut -b 13- | while read changed; do - hg diff "$changed" >> "$HGTMP/diff" + "$HG" diff "$changed" >> "$HGTMP/diff" done )
--- a/hgext/hgk.py Sat Jun 23 14:02:41 2007 -0500 +++ b/hgext/hgk.py Sat Jun 23 21:11:28 2007 +0200 @@ -272,7 +272,7 @@ optstr = ' '.join(['--%s %s' % (k, v) for k, v in opts.iteritems() if v]) cmd = ui.config("hgk", "path", "hgk") + " %s %s" % (optstr, " ".join(etc)) ui.debug("running %s\n" % cmd) - os.system(cmd) + util.system(cmd) cmdtable = { "^view": (view,
--- a/mercurial/cmdutil.py Sat Jun 23 14:02:41 2007 -0500 +++ b/mercurial/cmdutil.py Sat Jun 23 21:11:28 2007 +0200 @@ -20,7 +20,7 @@ class ParseError(Exception): """Exception raised on errors in parsing the command line.""" -def runcatch(ui, args): +def runcatch(ui, args, argv0=None): def catchterm(*args): raise util.SignalInterrupt @@ -34,7 +34,7 @@ if '--debugger' in args: pdb.set_trace() try: - return dispatch(ui, args) + return dispatch(ui, args, argv0=argv0) finally: ui.flush() except: @@ -255,7 +255,10 @@ return args[args.index(opt) + 1] return None -def dispatch(ui, args): +def dispatch(ui, args, argv0=None): + # remember how to call 'hg' before changing the working dir + util.set_hgexecutable(argv0) + # check for cwd first cwd = earlygetopt(['--cwd'], args) if cwd:
--- a/mercurial/commands.py Sat Jun 23 14:02:41 2007 -0500 +++ b/mercurial/commands.py Sat Jun 23 21:11:28 2007 +0200 @@ -3090,13 +3090,13 @@ " debugindex debugindexdot debugdate debuginstall") optionalrepo = ("paths serve showconfig") -def dispatch(args): +def dispatch(args, argv0=None): try: u = ui.ui(traceback='--traceback' in args) except util.Abort, inst: sys.stderr.write(_("abort: %s\n") % inst) return -1 - return cmdutil.runcatch(u, args) + return cmdutil.runcatch(u, args, argv0=argv0) def run(): - sys.exit(dispatch(sys.argv[1:])) + sys.exit(dispatch(sys.argv[1:], argv0=sys.argv[0]))
--- a/mercurial/help.py Sat Jun 23 14:02:41 2007 -0500 +++ b/mercurial/help.py Sat Jun 23 21:11:28 2007 +0200 @@ -37,6 +37,11 @@ 'environment|env|Environment Variables': r''' +HG:: + Path to the 'hg' executable, automatically passed when running hooks + or external tools. Falls back to 'hg' if unset and the value can't be + autodetected, e.g. when Mercurial is run as a Python module. + HGEDITOR:: This is the name of the editor to use when committing. Defaults to the value of EDITOR.
--- a/mercurial/util.py Sat Jun 23 14:02:41 2007 -0500 +++ b/mercurial/util.py Sat Jun 23 21:11:28 2007 +0200 @@ -537,6 +537,17 @@ return (roots, match, (inc or exc or anypats) and True) +_hgexecutable = None + +def set_hgexecutable(path): + """remember location of the 'hg' executable if easily possible + + path might be None or empty if hg was loaded as a module, + fall back to 'hg' in this case. + """ + global _hgexecutable + _hgexecutable = path and os.path.abspath(path) or 'hg' + def system(cmd, environ={}, cwd=None, onerr=None, errprefix=None): '''enhanced shell command execution. run with environment maybe modified, maybe in different dir. @@ -562,6 +573,8 @@ try: for k, v in environ.iteritems(): os.environ[k] = py2shell(v) + if 'HG' not in os.environ: + os.environ['HG'] = _hgexecutable if cwd is not None and oldcwd != cwd: os.chdir(cwd) rc = os.system(cmd)