diff --git a/hg b/hg --- a/hg +++ b/hg @@ -8,16 +8,7 @@ # This software may be used and distributed according to the terms # of the GNU General Public License, incorporated herein by reference. -# the psyco compiler makes commits a bit faster -# and makes changegroup merge about 20 times slower! -# try: -# import psyco -# psyco.full() -# except: -# pass - -import sys from mercurial import commands -sys.exit(commands.dispatch(sys.argv[1:])) +commands.run() diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -1,4 +1,11 @@ -import os, re, traceback, sys, signal, time, mdiff +# commands.py - command processing for mercurial +# +# Copyright 2005 Matt Mackall +# +# This software may be used and distributed according to the terms +# of the GNU General Public License, incorporated herein by reference. + +import os, re, sys, signal, time, mdiff from mercurial import fancyopts, ui, hg class UnknownCommand(Exception): pass @@ -522,6 +529,9 @@ class SignalInterrupt(Exception): pass def catchterm(*args): raise SignalInterrupt +def run(): + sys.exit(dispatch(sys.argv[1:])) + def dispatch(args): options = {} opts = [('v', 'verbose', None, 'verbose'), @@ -562,6 +572,7 @@ def dispatch(args): except KeyboardInterrupt: u.warn("interrupted!\n") except TypeError, inst: + import traceback # was this an argument error? tb = traceback.extract_tb(sys.exc_info()[2]) if len(tb) > 2: # no diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -5,9 +5,8 @@ # This software may be used and distributed according to the terms # of the GNU General Public License, incorporated herein by reference. -import sys, struct, sha, socket, os, time, re, urllib2, tempfile -import urllib -from mercurial import byterange, lock +import sys, struct, os +from mercurial import lock from mercurial.transaction import * from mercurial.revlog import * from difflib import SequenceMatcher @@ -139,6 +138,7 @@ class changelog(revlog): def add(self, manifest, list, desc, transaction, p1=None, p2=None, user=None, date=None): + import socket, time user = (user or os.environ.get("HGUSER") or os.environ.get("EMAIL") or @@ -315,6 +315,7 @@ class localrepository: self.dirstate = dirstate(self.opener, ui, self.root) def ignore(self, f): + import re if self.ignorelist is None: self.ignorelist = [] try: @@ -966,6 +967,8 @@ class localrepository: def merge3(self, fn, my, other): """perform a 3-way merge in the working directory""" + + import tempfile def temp(prefix, node): pre = "%s~%s." % (os.path.basename(fn), prefix) @@ -1177,10 +1180,14 @@ class remoterepository: def repository(ui, path=None, create=0): if path and path[:7] == "http://": + import urllib, urllib2 return remoterepository(ui, path) if path and path[:5] == "hg://": + import urllib, urllib2 return remoterepository(ui, path.replace("hg://", "http://")) if path and path[:11] == "old-http://": + import urllib, urllib2 + from mercurial import byterange return localrepository(ui, path.replace("old-http://", "http://")) else: return localrepository(ui, path, create) diff --git a/mercurial/mdiff.py b/mercurial/mdiff.py --- a/mercurial/mdiff.py +++ b/mercurial/mdiff.py @@ -5,7 +5,7 @@ # This software may be used and distributed according to the terms # of the GNU General Public License, incorporated herein by reference. -import difflib, struct, mmap +import difflib, struct from mercurial.mpatch import * def unidiff(a, ad, b, bd, fn): diff --git a/mercurial/ui.py b/mercurial/ui.py --- a/mercurial/ui.py +++ b/mercurial/ui.py @@ -5,7 +5,7 @@ # This software may be used and distributed according to the terms # of the GNU General Public License, incorporated herein by reference. -import os, tempfile, sys, re +import os, sys, re class ui: def __init__(self, verbose=False, debug=False, quiet=False, @@ -37,6 +37,7 @@ class ui: def debug(self, *msg): if self.debugflag: self.write(*msg) def edit(self, text): + import tempfile (fd, name) = tempfile.mkstemp("hg") f = os.fdopen(fd, "w") f.write(text)