Mercurial > hg
changeset 3895:79e5a6e7c451
Merge with main
author | Brendan Cully <brendan@kublai.com> |
---|---|
date | Thu, 14 Dec 2006 13:49:33 -0800 |
parents | d83b125b7d7e (current diff) abaee83ce0a6 (diff) |
children | 3b628b5da9e9 |
files | hgext/patchbomb.py mercurial/commands.py mercurial/demandload.py mercurial/hgweb/hgweb_mod.py mercurial/hgweb/hgwebdir_mod.py mercurial/packagescan.py setup.py tests/test-branch tests/test-branch.out |
diffstat | 54 files changed, 226 insertions(+), 706 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/churn.py Thu Dec 14 19:30:52 2006 +0100 +++ b/contrib/churn.py Thu Dec 14 13:49:33 2006 -0800 @@ -11,10 +11,9 @@ # # <alias email> <actual email> -from mercurial.demandload import * +import time, sys, signal, os from mercurial.i18n import gettext as _ -demandload(globals(), 'time sys signal os') -demandload(globals(), 'mercurial:hg,mdiff,fancyopts,cmdutil,ui,util,templater,node') +from mercurial import hg, mdiff, cmdutil, ui, util, templater, node def __gather(ui, repo, node1, node2): def dirtywork(f, mmap1, mmap2):
--- a/hg Thu Dec 14 19:30:52 2006 +0100 +++ b/hg Thu Dec 14 13:49:33 2006 -0800 @@ -7,6 +7,5 @@ # This software may be used and distributed according to the terms # of the GNU General Public License, incorporated herein by reference. -from mercurial import commands - -commands.run() +import mercurial.commands +mercurial.commands.run()
--- a/hgext/acl.py Thu Dec 14 19:30:52 2006 +0100 +++ b/hgext/acl.py Thu Dec 14 13:49:33 2006 -0800 @@ -45,10 +45,10 @@ # glob pattern = user4, user5 # ** = user6 -from mercurial.demandload import * from mercurial.i18n import gettext as _ from mercurial.node import * -demandload(globals(), 'getpass mercurial:util') +from mercurial import util +import getpass class checker(object): '''acl checker.'''
--- a/hgext/bugzilla.py Thu Dec 14 19:30:52 2006 +0100 +++ b/hgext/bugzilla.py Thu Dec 14 13:49:33 2006 -0800 @@ -52,10 +52,10 @@ # [usermap] # committer_email = bugzilla_user_name -from mercurial.demandload import * from mercurial.i18n import gettext as _ from mercurial.node import * -demandload(globals(), 'mercurial:cmdutil,templater,util os re time') +from mercurial import cmdutil, templater, util +import os, re, time MySQLdb = None @@ -268,7 +268,7 @@ mapfile = self.ui.config('bugzilla', 'style') tmpl = self.ui.config('bugzilla', 'template') t = cmdutil.changeset_templater(self.ui, self.repo, - False, None, mapfile, False) + False, mapfile, False) if not mapfile and not tmpl: tmpl = _('changeset {node|short} in repo {root} refers ' 'to bug {bug}.\ndetails:\n\t{desc|tabindent}')
--- a/hgext/extdiff.py Thu Dec 14 19:30:52 2006 +0100 +++ b/hgext/extdiff.py Thu Dec 14 13:49:33 2006 -0800 @@ -48,10 +48,10 @@ # needed files, so running the external diff program will actually be # pretty fast (at least faster than having to compare the entire tree). -from mercurial.demandload import demandload from mercurial.i18n import gettext as _ from mercurial.node import * -demandload(globals(), 'mercurial:cmdutil,util os shutil tempfile') +from mercurial import cmdutil, util +import os, shutil, tempfile def dodiff(ui, repo, diffcmd, diffopts, pats, opts): def snapshot_node(files, node):
--- a/hgext/fetch.py Thu Dec 14 19:30:52 2006 +0100 +++ b/hgext/fetch.py Thu Dec 14 13:49:33 2006 -0800 @@ -5,10 +5,9 @@ # This software may be used and distributed according to the terms # of the GNU General Public License, incorporated herein by reference. -from mercurial.demandload import * from mercurial.i18n import gettext as _ from mercurial.node import * -demandload(globals(), 'mercurial:commands,hg,node,util') +from mercurial import commands, hg, node, util def fetch(ui, repo, source='default', **opts): '''Pull changes from a remote repository, merge new changes if needed.
--- a/hgext/hbisect.py Thu Dec 14 19:30:52 2006 +0100 +++ b/hgext/hbisect.py Thu Dec 14 13:49:33 2006 -0800 @@ -7,8 +7,8 @@ # of the GNU General Public License, incorporated herein by reference. from mercurial.i18n import gettext as _ -from mercurial.demandload import demandload -demandload(globals(), "os sys sets mercurial:hg,util,commands,cmdutil") +from mercurial import hg, util, commands, cmdutil +import os, sys, sets versionstr = "0.0.3"
--- a/hgext/hgk.py Thu Dec 14 19:30:52 2006 +0100 +++ b/hgext/hgk.py Thu Dec 14 13:49:33 2006 -0800 @@ -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. -from mercurial.demandload import * -demandload(globals(), 'time sys signal os') -demandload(globals(), 'mercurial:hg,fancyopts,commands,ui,util,patch,revlog') +import time, sys, signal, os +from mercurial import hg, fancyopts, commands, ui, util, patch, revlog def difftree(ui, repo, node1=None, node2=None, *files, **opts): """diff trees from two commits"""
--- a/hgext/mq.py Thu Dec 14 19:30:52 2006 +0100 +++ b/hgext/mq.py Thu Dec 14 13:49:33 2006 -0800 @@ -29,11 +29,9 @@ refresh contents of top applied patch qrefresh ''' -from mercurial.demandload import * from mercurial.i18n import gettext as _ -from mercurial import commands -demandload(globals(), "os sys re struct traceback errno bz2") -demandload(globals(), "mercurial:cmdutil,hg,patch,revlog,util,changegroup") +from mercurial import commands, cmdutil, hg, patch, revlog, util, changegroup +import os, sys, re, struct, traceback, errno, bz2 commands.norepo += " qclone qversion"
--- a/hgext/notify.py Thu Dec 14 19:30:52 2006 +0100 +++ b/hgext/notify.py Thu Dec 14 13:49:33 2006 -0800 @@ -65,11 +65,10 @@ # if you like, you can put notify config file in repo that users can # push changes to, they can manage their own subscriptions. -from mercurial.demandload import * from mercurial.i18n import gettext as _ from mercurial.node import * -demandload(globals(), 'mercurial:patch,cmdutil,templater,util,mail') -demandload(globals(), 'email.Parser fnmatch socket time') +from mercurial import patch, cmdutil, templater, util, mail +import email.Parser, fnmatch, socket, time # template for single changeset can include email headers. single_template = ''' @@ -113,7 +112,7 @@ template = (self.ui.config('notify', hooktype) or self.ui.config('notify', 'template')) self.t = cmdutil.changeset_templater(self.ui, self.repo, - False, None, mapfile, False) + False, mapfile, False) if not mapfile and not template: template = deftemplates.get(hooktype) or single_template if template:
--- a/hgext/patchbomb.py Thu Dec 14 19:30:52 2006 +0100 +++ b/hgext/patchbomb.py Thu Dec 14 13:49:33 2006 -0800 @@ -63,10 +63,9 @@ # # That should be all. Now your patchbomb is on its way out. -from mercurial.demandload import * -demandload(globals(), '''email.MIMEMultipart email.MIMEText email.Utils - mercurial:cmdutil,commands,hg,mail,ui,patch - os errno popen2 socket sys tempfile time''') +import os, errno, popen2, socket, sys, tempfile, time +import email.MIMEMultipart, email.MIMEText, email.Utils +from mercurial import cmdutil, commands, hg, mail, ui, patch from mercurial.i18n import gettext as _ from mercurial.node import *
--- a/hgext/transplant.py Thu Dec 14 19:30:52 2006 +0100 +++ b/hgext/transplant.py Thu Dec 14 13:49:33 2006 -0800 @@ -5,11 +5,10 @@ # This software may be used and distributed according to the terms # of the GNU General Public License, incorporated herein by reference. -from mercurial.demandload import * from mercurial.i18n import gettext as _ -demandload(globals(), 'os tempfile') -demandload(globals(), 'mercurial:bundlerepo,cmdutil,commands,hg,merge,patch') -demandload(globals(), 'mercurial:revlog,util') +import os, tempfile +from mercurial import bundlerepo, cmdutil, commands, hg, merge, patch, revlog +from mercurial import util '''patch transplanting tool
--- a/mercurial/appendfile.py Thu Dec 14 19:30:52 2006 +0100 +++ b/mercurial/appendfile.py Thu Dec 14 13:49:33 2006 -0800 @@ -5,8 +5,7 @@ # This software may be used and distributed according to the terms # of the GNU General Public License, incorporated herein by reference. -from demandload import * -demandload(globals(), "cStringIO changelog errno manifest os tempfile util") +import cStringIO, changelog, errno, manifest, os, tempfile, util # writes to metadata files are ordered. reads: changelog, manifest, # normal files. writes: normal files, manifest, changelog.
--- a/mercurial/archival.py Thu Dec 14 19:30:52 2006 +0100 +++ b/mercurial/archival.py Thu Dec 14 13:49:33 2006 -0800 @@ -5,10 +5,9 @@ # This software may be used and distributed according to the terms of # the GNU General Public License, incorporated herein by reference. -from demandload import * from i18n import gettext as _ from node import * -demandload(globals(), 'cStringIO os stat tarfile time util zipfile') +import cStringIO, os, stat, tarfile, time, util, zipfile def tidyprefix(dest, prefix, suffixes): '''choose prefix to use for names in archive. make sure prefix is
--- a/mercurial/bundlerepo.py Thu Dec 14 19:30:52 2006 +0100 +++ b/mercurial/bundlerepo.py Thu Dec 14 13:49:33 2006 -0800 @@ -12,8 +12,7 @@ from node import * from i18n import gettext as _ -from demandload import demandload -demandload(globals(), "changegroup util os struct bz2 tempfile") +import changegroup, util, os, struct, bz2, tempfile import localrepo, changelog, manifest, filelog, revlog
--- a/mercurial/changegroup.py Thu Dec 14 19:30:52 2006 +0100 +++ b/mercurial/changegroup.py Thu Dec 14 13:49:33 2006 -0800 @@ -6,9 +6,9 @@ This software may be used and distributed according to the terms of the GNU General Public License, incorporated herein by reference. """ + from i18n import gettext as _ -from demandload import * -demandload(globals(), "struct os bz2 zlib util tempfile") +import struct, os, bz2, zlib, util, tempfile def getchunk(source): """get a chunk from a changegroup"""
--- a/mercurial/changelog.py Thu Dec 14 19:30:52 2006 +0100 +++ b/mercurial/changelog.py Thu Dec 14 13:49:33 2006 -0800 @@ -7,8 +7,7 @@ from revlog import * from i18n import gettext as _ -from demandload import demandload -demandload(globals(), "os time util") +import os, time, util def _string_escape(text): """
--- a/mercurial/cmdutil.py Thu Dec 14 19:30:52 2006 +0100 +++ b/mercurial/cmdutil.py Thu Dec 14 13:49:33 2006 -0800 @@ -5,11 +5,9 @@ # This software may be used and distributed according to the terms # of the GNU General Public License, incorporated herein by reference. -from demandload import demandload from node import * from i18n import gettext as _ -demandload(globals(), 'os sys') -demandload(globals(), 'mdiff util templater patch') +import os, sys, mdiff, util, templater, patch revrangesep = ':' @@ -199,12 +197,11 @@ class changeset_printer(object): '''show changeset information when templating not requested.''' - def __init__(self, ui, repo, patch, brinfo, buffered): + def __init__(self, ui, repo, patch, buffered): self.ui = ui self.repo = repo self.buffered = buffered self.patch = patch - self.brinfo = brinfo self.header = {} self.hunk = {} self.lastheader = None @@ -268,11 +265,6 @@ for parent in parents: self.ui.write(_("parent: %d:%s\n") % parent) - if self.brinfo: - br = self.repo.branchlookup([changenode]) - if br: - self.ui.write(_("branch: %s\n") % " ".join(br[changenode])) - if self.ui.debugflag: self.ui.write(_("manifest: %d:%s\n") % (self.repo.manifest.rev(changes[0]), hex(changes[0]))) @@ -320,8 +312,8 @@ class changeset_templater(changeset_printer): '''format changeset information.''' - def __init__(self, ui, repo, patch, brinfo, mapfile, buffered): - changeset_printer.__init__(self, ui, repo, patch, brinfo, buffered) + def __init__(self, ui, repo, patch, mapfile, buffered): + changeset_printer.__init__(self, ui, repo, patch, buffered) self.t = templater.templater(mapfile, templater.common_filters, cache={'parent': '{rev}:{node|short} ', 'manifest': '{rev}:{node|short}', @@ -407,12 +399,6 @@ if branch: branch = util.tolocal(branch) return showlist('branch', [branch], plural='branches', **args) - # add old style branches if requested - if self.brinfo: - br = self.repo.branchlookup([changenode]) - if changenode in br: - return showlist('branch', br[changenode], - plural='branches', **args) def showparents(**args): parents = [[('rev', log.rev(p)), ('node', hex(p))] @@ -526,11 +512,6 @@ if opts.get('patch'): patch = matchfn or util.always - br = None - if opts.get('branches'): - ui.warn(_("the --branches option is deprecated, " - "please use 'hg branches' instead\n")) - br = True tmpl = opts.get('template') mapfile = None if tmpl: @@ -552,12 +533,12 @@ or templater.templatepath(mapfile)) if mapname: mapfile = mapname try: - t = changeset_templater(ui, repo, patch, br, mapfile, buffered) + t = changeset_templater(ui, repo, patch, mapfile, buffered) except SyntaxError, inst: raise util.Abort(inst.args[0]) if tmpl: t.use_template(tmpl) return t - return changeset_printer(ui, repo, patch, br, buffered) + return changeset_printer(ui, repo, patch, buffered) def finddate(ui, repo, date): """Find the tipmost changeset that matches the given date spec"""
--- a/mercurial/commands.py Thu Dec 14 19:30:52 2006 +0100 +++ b/mercurial/commands.py Thu Dec 14 13:49:33 2006 -0800 @@ -5,14 +5,14 @@ # This software may be used and distributed according to the terms # of the GNU General Public License, incorporated herein by reference. -from demandload import demandload +import demandimport; demandimport.enable() from node import * from i18n import gettext as _ -demandload(globals(), "bisect os re sys signal imp urllib pdb shlex stat") -demandload(globals(), "fancyopts ui hg util lock revlog bundlerepo") -demandload(globals(), "difflib patch time help mdiff tempfile") -demandload(globals(), "traceback errno version atexit") -demandload(globals(), "archival changegroup cmdutil hgweb.server sshserver") +import bisect, os, re, sys, signal, imp, urllib, pdb, shlex, stat +import fancyopts, ui, hg, util, lock, revlog, bundlerepo +import difflib, patch, time, help, mdiff, tempfile +import traceback, errno, version, atexit +import archival, changegroup, cmdutil, hgweb.server, sshserver class UnknownCommand(Exception): """Exception raised if command is not in the command table.""" @@ -240,8 +240,7 @@ if op1 != node: if opts['merge']: ui.status(_('merging with changeset %s\n') % nice(op1)) - n = _lookup(repo, hex(op1)) - hg.merge(repo, n) + hg.merge(repo, hex(op1)) else: ui.status(_('the backout changeset is a new head - ' 'do not forget to merge\n')) @@ -1698,7 +1697,6 @@ if opts["date"]: df = util.matchdate(opts["date"]) - displayer = cmdutil.show_changeset(ui, repo, opts, True, matchfn) for st, rev, fns in changeiter: if st == 'add': @@ -1763,7 +1761,7 @@ ui.write("%3s " % (m.execf(f) and "755" or "644")) ui.write("%s\n" % f) -def merge(ui, repo, node=None, force=None, branch=None): +def merge(ui, repo, node=None, force=None): """Merge working directory with another revision Merge the contents of the current working directory and the @@ -1777,9 +1775,7 @@ revision to merge with must be provided. """ - if node or branch: - node = _lookup(repo, node, branch) - else: + if not node: heads = repo.heads() if len(heads) > 2: raise util.Abort(_('repo has %d heads - ' @@ -2478,7 +2474,7 @@ modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname) return postincoming(ui, repo, modheads, opts['update']) -def update(ui, repo, node=None, clean=False, branch=None, date=None): +def update(ui, repo, node=None, clean=False, date=None): """update or merge working directory Update the working directory to the specified revision. @@ -2498,36 +2494,11 @@ raise util.Abort(_("you can't specify a revision and a date")) node = cmdutil.finddate(ui, repo, date) - node = _lookup(repo, node, branch) if clean: return hg.clean(repo, node) else: return hg.update(repo, node) -def _lookup(repo, node, branch=None): - if branch: - repo.ui.warn(_("the --branch option is deprecated, " - "please use 'hg branch' instead\n")) - br = repo.branchlookup(branch=branch) - found = [] - for x in br: - if branch in br[x]: - found.append(x) - if len(found) > 1: - repo.ui.warn(_("Found multiple heads for %s\n") % branch) - for x in found: - cmdutil.show_changeset(ui, repo, {}).show(changenode=x) - raise util.Abort("") - if len(found) == 1: - node = found[0] - repo.ui.warn(_("Using head %s for branch %s\n") - % (short(node), branch)) - else: - raise util.Abort(_("branch %s not found") % branch) - else: - node = node and repo.lookup(node) or repo.changelog.tip() - return node - def verify(ui, repo): """verify the integrity of the repository @@ -2733,8 +2704,7 @@ _('hg grep [OPTION]... PATTERN [FILE]...')), "heads": (heads, - [('b', 'branches', None, _('show branches (DEPRECATED)')), - ('', 'style', '', _('display using template map file')), + [('', 'style', '', _('display using template map file')), ('r', 'rev', '', _('show only heads which are descendants of rev')), ('', 'template', '', _('display with template'))], _('hg heads [-r REV]')), @@ -2745,7 +2715,7 @@ [('p', 'strip', 1, _('directory strip option for patch. This has the same\n' 'meaning as the corresponding patch option')), - ('b', 'base', '', _('base path (DEPRECATED)')), + ('b', 'base', '', _('base path')), ('f', 'force', None, _('skip check for outstanding uncommitted changes'))] + commitopts, _('hg import [-p NUM] [-m MESSAGE] [-f] PATCH...')), @@ -2777,8 +2747,7 @@ _('hg locate [OPTION]... [PATTERN]...')), "^log|history": (log, - [('b', 'branches', None, _('show branches (DEPRECATED)')), - ('f', 'follow', None, + [('f', 'follow', None, _('follow changeset history, or file history across copies and renames')), ('', 'follow-first', None, _('only follow the first parent of merge changesets')), @@ -2799,8 +2768,7 @@ "manifest": (manifest, [], _('hg manifest [REV]')), "merge": (merge, - [('b', 'branch', '', _('merge with head of a specific branch (DEPRECATED)')), - ('f', 'force', None, _('force a merge with outstanding changes'))], + [('f', 'force', None, _('force a merge with outstanding changes'))], _('hg merge [-f] [REV]')), "outgoing|out": (outgoing, [('M', 'no-merges', None, _('do not show merges')), @@ -2815,8 +2783,7 @@ _('hg outgoing [-M] [-p] [-n] [-f] [-r REV]... [DEST]')), "^parents": (parents, - [('b', 'branches', None, _('show branches (DEPRECATED)')), - ('r', 'rev', '', _('show parents from the specified rev')), + [('r', 'rev', '', _('show parents from the specified rev')), ('', 'style', '', _('display using template map file')), ('', 'template', '', _('display with template'))], _('hg parents [-r REV] [FILE]')), @@ -2919,8 +2886,7 @@ "tags": (tags, [], _('hg tags')), "tip": (tip, - [('b', 'branches', None, _('show branches (DEPRECATED)')), - ('', 'style', '', _('display using template map file')), + [('', 'style', '', _('display using template map file')), ('p', 'patch', None, _('show patch')), ('', 'template', '', _('display with template'))], _('hg tip [-p]')), @@ -2931,9 +2897,7 @@ _('hg unbundle [-u] FILE')), "^update|up|checkout|co": (update, - [('b', 'branch', '', - _('checkout the head of a specific branch (DEPRECATED)')), - ('C', 'clean', None, _('overwrite locally modified files')), + [('C', 'clean', None, _('overwrite locally modified files')), ('d', 'date', '', _('tipmost revision matching date'))], _('hg update [-C] [-d DATE] [REV]')), "verify": (verify, [], _('hg verify')),
--- a/mercurial/context.py Thu Dec 14 19:30:52 2006 +0100 +++ b/mercurial/context.py Thu Dec 14 13:49:33 2006 -0800 @@ -7,8 +7,7 @@ from node import * from i18n import gettext as _ -from demandload import demandload -demandload(globals(), "ancestor bdiff repo revlog util os") +import ancestor, bdiff, repo, revlog, util, os class changectx(object): """A changecontext object makes access to data related to a particular
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mercurial/demandimport.py Thu Dec 14 13:49:33 2006 -0800 @@ -0,0 +1,104 @@ +# demandimport.py - global demand-loading of modules for Mercurial +# +# Copyright 2006 Matt Mackall <mpm@selenic.com> +# +# This software may be used and distributed according to the terms +# of the GNU General Public License, incorporated herein by reference. + +''' +demandimport - automatic demandloading of modules + +To enable this module, do: + + import demandimport; demandimport.enable() + +Imports of the following forms will be demand-loaded: + + import a, b.c + import a.b as c + from a import b,c # a will be loaded immediately + +These imports will not be delayed: + + from a import * + b = __import__(a) +''' + +_origimport = __import__ + +class _demandmod(object): + """module demand-loader and proxy""" + def __init__(self, name, globals, locals): + if '.' in name: + head, rest = name.split('.', 1) + after = [rest] + else: + head = name + after = [] + self.__dict__["_data"] = (head, globals, locals, after) + self.__dict__["_module"] = None + def _extend(self, name): + """add to the list of submodules to load""" + self._data[3].append(name) + def _load(self): + if not self._module: + head, globals, locals, after = self._data + mod = _origimport(head, globals, locals) + # load submodules + for x in after: + hx = x + if '.' in x: + hx = x.split('.')[0] + if not hasattr(mod, hx): + setattr(mod, hx, _demandmod(x, mod.__dict__, mod.__dict__)) + # are we in the locals dictionary still? + if locals and locals.get(head) == self: + locals[head] = mod + self.__dict__["_module"] = mod + def __repr__(self): + return "<unloaded module '%s'>" % self._data[0] + def __call__(self, *args, **kwargs): + raise TypeError("'unloaded module' object is not callable") + def __getattr__(self, attr): + self._load() + return getattr(self._module, attr) + def __setattr__(self, attr, val): + self._load() + setattr(self._module, attr, val) + +def _demandimport(name, globals=None, locals=None, fromlist=None): + if not locals or name in ignore or fromlist == ('*',): + # these cases we can't really delay + return _origimport(name, globals, locals, fromlist) + elif not fromlist: + # import a [as b] + if '.' in name: # a.b + base, rest = name.split('.', 1) + # if a is already demand-loaded, add b to its submodule list + if base in locals: + if isinstance(locals[base], _demandmod): + locals[base]._extend(rest) + return locals[base] + return _demandmod(name, globals, locals) + else: + # from a import b,c,d + mod = _origimport(name, globals, locals) + # recurse down the module chain + for comp in name.split('.')[1:]: + mod = getattr(mod, comp) + for x in fromlist: + # set requested submodules for demand load + if not(hasattr(mod, x)): + setattr(mod, x, _demandmod(x, mod.__dict__, mod.__dict__)) + return mod + +ignore = [] + +def enable(): + "enable global demand-loading of modules" + __builtins__["__import__"] = _demandimport + +def disable(): + "disable global demand-loading of modules" + __builtins__["__import__"] = _origimport +
--- a/mercurial/demandload.py Thu Dec 14 19:30:52 2006 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,135 +0,0 @@ -'''Demand load modules when used, not when imported.''' - -__author__ = '''Copyright 2006 Vadim Gelfer <vadim.gelfer@gmail.com>. -This software may be used and distributed according to the terms -of the GNU General Public License, incorporated herein by reference.''' - -# this is based on matt's original demandload module. it is a -# complete rewrite. some time, we may need to support syntax of -# "import foo as bar". - -class _importer(object): - '''import a module. it is not imported until needed, and is - imported at most once per scope.''' - - def __init__(self, scope, modname, fromlist): - '''scope is context (globals() or locals()) in which import - should be made. modname is name of module to import. - fromlist is list of modules for "from foo import ..." - emulation.''' - - self.scope = scope - self.modname = modname - self.fromlist = fromlist - self.mod = None - - def module(self): - '''import the module if needed, and return.''' - if self.mod is None: - self.mod = __import__(self.modname, self.scope, self.scope, - self.fromlist) - del self.modname, self.fromlist - return self.mod - -class _replacer(object): - '''placeholder for a demand loaded module. demandload puts this in - a target scope. when an attribute of this object is looked up, - this object is replaced in the target scope with the actual - module. - - we use __getattribute__ to avoid namespace clashes between - placeholder object and real module.''' - - def __init__(self, importer, target): - self.importer = importer - self.target = target - # consider case where we do this: - # demandload(globals(), 'foo.bar foo.quux') - # foo will already exist in target scope when we get to - # foo.quux. so we remember that we will need to demandload - # quux into foo's scope when we really load it. - self.later = [] - - def module(self): - return object.__getattribute__(self, 'importer').module() - - def __getattribute__(self, key): - '''look up an attribute in a module and return it. replace the - name of the module in the caller\'s dict with the actual - module.''' - - module = object.__getattribute__(self, 'module')() - target = object.__getattribute__(self, 'target') - importer = object.__getattribute__(self, 'importer') - later = object.__getattribute__(self, 'later') - - if later: - demandload(module.__dict__, ' '.join(later)) - - importer.scope[target] = module - - return getattr(module, key) - -class _replacer_from(_replacer): - '''placeholder for a demand loaded module. used for "from foo - import ..." emulation. semantics of this are different than - regular import, so different implementation needed.''' - - def module(self): - importer = object.__getattribute__(self, 'importer') - target = object.__getattribute__(self, 'target') - - return getattr(importer.module(), target) - - def __call__(self, *args, **kwargs): - target = object.__getattribute__(self, 'module')() - return target(*args, **kwargs) - -def demandload(scope, modules): - '''import modules into scope when each is first used. - - scope should be the value of globals() in the module calling this - function, or locals() in the calling function. - - modules is a string listing module names, separated by white - space. names are handled like this: - - foo import foo - foo bar import foo, bar - foo@bar import foo as bar - foo.bar import foo.bar - foo:bar from foo import bar - foo:bar,quux from foo import bar, quux - foo.bar:quux from foo.bar import quux''' - - for mod in modules.split(): - col = mod.find(':') - if col >= 0: - fromlist = mod[col+1:].split(',') - mod = mod[:col] - else: - fromlist = [] - as_ = None - if '@' in mod: - mod, as_ = mod.split("@") - importer = _importer(scope, mod, fromlist) - if fromlist: - for name in fromlist: - scope[name] = _replacer_from(importer, name) - else: - dot = mod.find('.') - if dot >= 0: - basemod = mod[:dot] - val = scope.get(basemod) - # if base module has already been demandload()ed, - # remember to load this submodule into its namespace - # when needed. - if isinstance(val, _replacer): - later = object.__getattribute__(val, 'later') - later.append(mod[dot+1:]) - continue - else: - basemod = mod - if not as_: - as_ = basemod - scope[as_] = _replacer(importer, as_)
--- a/mercurial/dirstate.py Thu Dec 14 19:30:52 2006 +0100 +++ b/mercurial/dirstate.py Thu Dec 14 13:49:33 2006 -0800 @@ -9,8 +9,7 @@ from node import * from i18n import gettext as _ -from demandload import * -demandload(globals(), "struct os time bisect stat strutil util re errno") +import struct, os, time, bisect, stat, strutil, util, re, errno class dirstate(object): format = ">cllll"
--- a/mercurial/filelog.py Thu Dec 14 19:30:52 2006 +0100 +++ b/mercurial/filelog.py Thu Dec 14 13:49:33 2006 -0800 @@ -6,8 +6,7 @@ # of the GNU General Public License, incorporated herein by reference. from revlog import * -from demandload import * -demandload(globals(), "os") +import os class filelog(revlog): def __init__(self, opener, path, defversion=REVLOG_DEFAULT_VERSION):
--- a/mercurial/hg.py Thu Dec 14 19:30:52 2006 +0100 +++ b/mercurial/hg.py Thu Dec 14 13:49:33 2006 -0800 @@ -8,10 +8,11 @@ from node import * from repo import * -from demandload import * from i18n import gettext as _ -demandload(globals(), "localrepo bundlerepo httprepo sshrepo statichttprepo") -demandload(globals(), "errno lock os shutil util merge@_merge verify@_verify") +import localrepo, bundlerepo, httprepo, sshrepo, statichttprepo +import errno, lock, os, shutil, util +import merge as _merge +import verify as _verify def _local(path): return (os.path.isfile(util.drop_scheme('file', path)) and
--- a/mercurial/hgweb/__init__.py Thu Dec 14 19:30:52 2006 +0100 +++ b/mercurial/hgweb/__init__.py Thu Dec 14 13:49:33 2006 -0800 @@ -6,6 +6,11 @@ # This software may be used and distributed according to the terms # of the GNU General Public License, incorporated herein by reference. -from mercurial.demandload import demandload -demandload(globals(), "mercurial.hgweb.hgweb_mod:hgweb") -demandload(globals(), "mercurial.hgweb.hgwebdir_mod:hgwebdir") +import hgweb_mod, hgwebdir_mod + +def hgweb(*args, **kwargs): + return hgweb_mod.hgweb(*args, **kwargs) + +def hgwebdir(*args, **kwargs): + return hgwebdir_mod.hgwebdir(*args, **kwargs) +
--- a/mercurial/hgweb/common.py Thu Dec 14 19:30:52 2006 +0100 +++ b/mercurial/hgweb/common.py Thu Dec 14 13:49:33 2006 -0800 @@ -7,7 +7,6 @@ # of the GNU General Public License, incorporated herein by reference. import os, mimetypes -import os.path def get_mtime(repo_path): store_path = os.path.join(repo_path, ".hg")
--- a/mercurial/hgweb/hgweb_mod.py Thu Dec 14 19:30:52 2006 +0100 +++ b/mercurial/hgweb/hgweb_mod.py Thu Dec 14 13:49:33 2006 -0800 @@ -6,17 +6,13 @@ # This software may be used and distributed according to the terms # of the GNU General Public License, incorporated herein by reference. -import os -import os.path -import mimetypes -from mercurial.demandload import demandload -demandload(globals(), "re zlib ConfigParser mimetools cStringIO sys tempfile") -demandload(globals(), 'urllib bz2') -demandload(globals(), "mercurial:mdiff,ui,hg,util,archival,streamclone,patch") -demandload(globals(), "mercurial:revlog,templater") -demandload(globals(), "mercurial.hgweb.common:get_mtime,staticfile,style_map") +import os, mimetypes, re, zlib, ConfigParser, mimetools, cStringIO, sys +import tempfile, urllib, bz2 from mercurial.node import * from mercurial.i18n import gettext as _ +from mercurial import mdiff, ui, hg, util, archival, streamclone, patch +from mercurial import revlog, templater +from common import get_mtime, staticfile, style_map def _up(p): if p[0] != "/":
--- a/mercurial/hgweb/hgwebdir_mod.py Thu Dec 14 19:30:52 2006 +0100 +++ b/mercurial/hgweb/hgwebdir_mod.py Thu Dec 14 13:49:33 2006 -0800 @@ -6,13 +6,12 @@ # This software may be used and distributed according to the terms # of the GNU General Public License, incorporated herein by reference. -import os -from mercurial.demandload import demandload -demandload(globals(), "mimetools cStringIO") -demandload(globals(), "mercurial:ui,hg,util,templater") -demandload(globals(), "mercurial.hgweb.hgweb_mod:hgweb") -demandload(globals(), "mercurial.hgweb.common:get_mtime,staticfile,style_map") +from mercurial import demandimport; demandimport.enable() +import os, mimetools, cStringIO from mercurial.i18n import gettext as _ +from mercurial import ui, hg, util, templater +from common import get_mtime, staticfile, style_map +from hgweb_mod import hgweb # This is a stopgap class hgwebdir(object):
--- a/mercurial/hgweb/request.py Thu Dec 14 19:30:52 2006 +0100 +++ b/mercurial/hgweb/request.py Thu Dec 14 13:49:33 2006 -0800 @@ -6,8 +6,7 @@ # This software may be used and distributed according to the terms # of the GNU General Public License, incorporated herein by reference. -from mercurial.demandload import demandload -demandload(globals(), "socket sys cgi os errno") +import socket, sys, cgi, os, errno from mercurial.i18n import gettext as _ class wsgiapplication(object):
--- a/mercurial/hgweb/server.py Thu Dec 14 19:30:52 2006 +0100 +++ b/mercurial/hgweb/server.py Thu Dec 14 13:49:33 2006 -0800 @@ -6,11 +6,11 @@ # This software may be used and distributed according to the terms # of the GNU General Public License, incorporated herein by reference. -from mercurial.demandload import demandload -import os, sys, errno -demandload(globals(), "urllib BaseHTTPServer socket SocketServer") -demandload(globals(), "mercurial:ui,hg,util,templater") -demandload(globals(), "hgweb_mod:hgweb hgwebdir_mod:hgwebdir request:wsgiapplication") +import os, sys, errno, urllib, BaseHTTPServer, socket, SocketServer +from mercurial import ui, hg, util, templater +from hgweb_mod import hgweb +from hgwebdir_mod import hgwebdir +from request import wsgiapplication from mercurial.i18n import gettext as _ def _splitURI(uri):
--- a/mercurial/httprepo.py Thu Dec 14 19:30:52 2006 +0100 +++ b/mercurial/httprepo.py Thu Dec 14 13:49:33 2006 -0800 @@ -9,9 +9,8 @@ from node import * from remoterepo import * from i18n import gettext as _ -from demandload import * -demandload(globals(), "hg os urllib urllib2 urlparse zlib util httplib") -demandload(globals(), "errno keepalive tempfile socket changegroup") +import hg, os, urllib, urllib2, urlparse, zlib, util, httplib +import errno, keepalive, tempfile, socket, changegroup class passwordmgr(urllib2.HTTPPasswordMgrWithDefaultRealm): def __init__(self, ui):
--- a/mercurial/localrepo.py Thu Dec 14 19:30:52 2006 +0100 +++ b/mercurial/localrepo.py Thu Dec 14 13:49:33 2006 -0800 @@ -7,12 +7,10 @@ from node import * from i18n import gettext as _ -from demandload import * -import repo -demandload(globals(), "appendfile changegroup") -demandload(globals(), "changelog dirstate filelog manifest context") -demandload(globals(), "re lock transaction tempfile stat mdiff errno ui") -demandload(globals(), "os revlog time util") +import repo, appendfile, changegroup +import changelog, dirstate, filelog, manifest, context +import re, lock, transaction, tempfile, stat, mdiff, errno, ui +import os, revlog, time, util class localrepository(repo.repository): capabilities = ('lookup', 'changegroupsubset') @@ -993,112 +991,6 @@ heads.sort() return [n for (r, n) in heads] - # branchlookup returns a dict giving a list of branches for - # each head. A branch is defined as the tag of a node or - # the branch of the node's parents. If a node has multiple - # branch tags, tags are eliminated if they are visible from other - # branch tags. - # - # So, for this graph: a->b->c->d->e - # \ / - # aa -----/ - # a has tag 2.6.12 - # d has tag 2.6.13 - # e would have branch tags for 2.6.12 and 2.6.13. Because the node - # for 2.6.12 can be reached from the node 2.6.13, that is eliminated - # from the list. - # - # It is possible that more than one head will have the same branch tag. - # callers need to check the result for multiple heads under the same - # branch tag if that is a problem for them (ie checkout of a specific - # branch). - # - # passing in a specific branch will limit the depth of the search - # through the parents. It won't limit the branches returned in the - # result though. - def branchlookup(self, heads=None, branch=None): - if not heads: - heads = self.heads() - headt = [ h for h in heads ] - chlog = self.changelog - branches = {} - merges = [] - seenmerge = {} - - # traverse the tree once for each head, recording in the branches - # dict which tags are visible from this head. The branches - # dict also records which tags are visible from each tag - # while we traverse. - while headt or merges: - if merges: - n, found = merges.pop() - visit = [n] - else: - h = headt.pop() - visit = [h] - found = [h] - seen = {} - while visit: - n = visit.pop() - if n in seen: - continue - pp = chlog.parents(n) - tags = self.nodetags(n) - if tags: - for x in tags: - if x == 'tip': - continue - for f in found: - branches.setdefault(f, {})[n] = 1 - branches.setdefault(n, {})[n] = 1 - break - if n not in found: - found.append(n) - if branch in tags: - continue - seen[n] = 1 - if pp[1] != nullid and n not in seenmerge: - merges.append((pp[1], [x for x in found])) - seenmerge[n] = 1 - if pp[0] != nullid: - visit.append(pp[0]) - # traverse the branches dict, eliminating branch tags from each - # head that are visible from another branch tag for that head. - out = {} - viscache = {} - for h in heads: - def visible(node): - if node in viscache: - return viscache[node] - ret = {} - visit = [node] - while visit: - x = visit.pop() - if x in viscache: - ret.update(viscache[x]) - elif x not in ret: - ret[x] = 1 - if x in branches: - visit[len(visit):] = branches[x].keys() - viscache[node] = ret - return ret - if h not in branches: - continue - # O(n^2), but somewhat limited. This only searches the - # tags visible from a specific head, not all the tags in the - # whole repo. - for b in branches[h]: - vis = False - for bb in branches[h].keys(): - if b != bb: - if b in visible(bb): - vis = True - break - if not vis: - l = out.setdefault(h, []) - l[len(l):] = self.nodetags(b) - return out - def branches(self, nodes): if not nodes: nodes = [self.changelog.tip()]
--- a/mercurial/lock.py Thu Dec 14 19:30:52 2006 +0100 +++ b/mercurial/lock.py Thu Dec 14 13:49:33 2006 -0800 @@ -5,8 +5,7 @@ # This software may be used and distributed according to the terms # of the GNU General Public License, incorporated herein by reference. -from demandload import * -demandload(globals(), 'errno os socket time util') +import errno, os, socket, time, util class LockException(IOError): def __init__(self, errno, strerror, filename, desc):
--- a/mercurial/mail.py Thu Dec 14 19:30:52 2006 +0100 +++ b/mercurial/mail.py Thu Dec 14 13:49:33 2006 -0800 @@ -6,8 +6,7 @@ # of the GNU General Public License, incorporated herein by reference. from i18n import gettext as _ -from demandload import * -demandload(globals(), "os re smtplib templater util") +import os, re, smtplib, templater, util def _smtp(ui): '''send mail using smtp.'''
--- a/mercurial/manifest.py Thu Dec 14 19:30:52 2006 +0100 +++ b/mercurial/manifest.py Thu Dec 14 13:49:33 2006 -0800 @@ -7,9 +7,7 @@ from revlog import * from i18n import gettext as _ -from demandload import * -demandload(globals(), "array bisect struct") -demandload(globals(), "mdiff") +import array, bisect, struct, mdiff class manifestdict(dict): def __init__(self, mapping=None, flags=None):
--- a/mercurial/mdiff.py Thu Dec 14 19:30:52 2006 +0100 +++ b/mercurial/mdiff.py Thu Dec 14 13:49:33 2006 -0800 @@ -5,9 +5,7 @@ # This software may be used and distributed according to the terms # of the GNU General Public License, incorporated herein by reference. -from demandload import demandload -import bdiff, mpatch -demandload(globals(), "re struct util") +import bdiff, mpatch, re, struct, util def splitnewlines(text): '''like str.splitlines, but only split on newlines.'''
--- a/mercurial/merge.py Thu Dec 14 19:30:52 2006 +0100 +++ b/mercurial/merge.py Thu Dec 14 13:49:33 2006 -0800 @@ -7,8 +7,7 @@ from node import * from i18n import gettext as _ -from demandload import * -demandload(globals(), "errno util os tempfile") +import errno, util, os, tempfile def filemerge(repo, fw, fo, wctx, mctx): """perform a 3-way merge in the working directory @@ -441,6 +440,9 @@ wlock = working dir lock, if already held """ + if node is None: + node = "tip" + if not wlock: wlock = repo.wlock()
--- a/mercurial/node.py Thu Dec 14 19:30:52 2006 +0100 +++ b/mercurial/node.py Thu Dec 14 13:49:33 2006 -0800 @@ -7,8 +7,7 @@ of the GNU General Public License, incorporated herein by reference. """ -from demandload import demandload -demandload(globals(), "binascii") +import binascii nullrev = -1 nullid = "\0" * 20
--- a/mercurial/packagescan.py Thu Dec 14 19:30:52 2006 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,131 +0,0 @@ -# packagescan.py - Helper module for identifing used modules. -# Used for the py2exe distutil. -# This module must be the first mercurial module imported in setup.py -# -# Copyright 2005, 2006 Volker Kleinfeld <Volker.Kleinfeld@gmx.de> -# -# This software may be used and distributed according to the terms -# of the GNU General Public License, incorporated herein by reference. -import glob -import os -import sys -import ihooks -import types -import string - -# Install this module as fake demandload module -sys.modules['mercurial.demandload'] = sys.modules[__name__] - -# Requiredmodules contains the modules imported by demandload. -# Please note that demandload can be invoked before the -# mercurial.packagescan.scan method is invoked in case a mercurial -# module is imported. -requiredmodules = {} -def demandload(scope, modules): - """ fake demandload function that collects the required modules - foo import foo - foo bar import foo, bar - foo.bar import foo.bar - foo@bar import foo as bar - foo:bar from foo import bar - foo:bar,quux from foo import bar, quux - foo.bar:quux from foo.bar import quux""" - - for m in modules.split(): - mod = None - try: - module, fromlist = m.split(':') - fromlist = fromlist.split(',') - except: - module = m - fromlist = [] - as_ = None - if '@' in module: - module, as_ = module.split('@') - mod = __import__(module, scope, scope, fromlist) - if fromlist == []: - # mod is only the top package, but we need all packages - comp = module.split('.') - i = 1 - mn = comp[0] - while True: - # mn and mod.__name__ might not be the same - if not as_: - as_ = mn - scope[as_] = mod - requiredmodules[mod.__name__] = 1 - if len(comp) == i: break - mod = getattr(mod, comp[i]) - mn = string.join(comp[:i+1],'.') - i += 1 - else: - # mod is the last package in the component list - requiredmodules[mod.__name__] = 1 - for f in fromlist: - scope[f] = getattr(mod, f) - if type(scope[f]) == types.ModuleType: - requiredmodules[scope[f].__name__] = 1 - -class SkipPackage(Exception): - def __init__(self, reason): - self.reason = reason - -scan_in_progress = False - -def scan(libpath, packagename): - """ helper for finding all required modules of package <packagename> """ - global scan_in_progress - scan_in_progress = True - # Use the package in the build directory - libpath = os.path.abspath(libpath) - sys.path.insert(0, libpath) - packdir = os.path.join(libpath, packagename.replace('.', '/')) - # A normal import would not find the package in - # the build directory. ihook is used to force the import. - # After the package is imported the import scope for - # the following imports is settled. - p = importfrom(packdir) - globals()[packagename] = p - sys.modules[packagename] = p - # Fetch the python modules in the package - cwd = os.getcwd() - os.chdir(packdir) - pymodulefiles = glob.glob('*.py') - extmodulefiles = glob.glob('*.pyd') - os.chdir(cwd) - # Import all python modules and by that run the fake demandload - for m in pymodulefiles: - if m == '__init__.py': continue - tmp = {} - mname, ext = os.path.splitext(m) - fullname = packagename+'.'+mname - try: - __import__(fullname, tmp, tmp) - except SkipPackage, inst: - print >> sys.stderr, 'skipping %s: %s' % (fullname, inst.reason) - continue - requiredmodules[fullname] = 1 - # Import all extension modules and by that run the fake demandload - for m in extmodulefiles: - tmp = {} - mname, ext = os.path.splitext(m) - fullname = packagename+'.'+mname - __import__(fullname, tmp, tmp) - requiredmodules[fullname] = 1 - -def getmodules(): - return requiredmodules.keys() - -def importfrom(filename): - """ - import module/package from a named file and returns the module. - It does not check on sys.modules or includes the module in the scope. - """ - loader = ihooks.BasicModuleLoader() - path, file = os.path.split(filename) - name, ext = os.path.splitext(file) - m = loader.find_module_in_dir(name, path) - if not m: - raise ImportError, name - m = loader.load_module(name, m) - return m
--- a/mercurial/patch.py Thu Dec 14 19:30:52 2006 +0100 +++ b/mercurial/patch.py Thu Dec 14 13:49:33 2006 -0800 @@ -5,12 +5,11 @@ # This software may be used and distributed according to the terms # of the GNU General Public License, incorporated herein by reference. -from demandload import demandload from i18n import gettext as _ from node import * -demandload(globals(), "base85 cmdutil mdiff util") -demandload(globals(), "cStringIO email.Parser errno os popen2 re shutil sha") -demandload(globals(), "sys tempfile zlib") +import base85, cmdutil, mdiff, util +import cStringIO, email.Parser, errno, os, popen2, re, shutil, sha +import sys, tempfile, zlib # helper functions
--- a/mercurial/revlog.py Thu Dec 14 19:30:52 2006 +0100 +++ b/mercurial/revlog.py Thu Dec 14 13:49:33 2006 -0800 @@ -12,9 +12,8 @@ from node import * from i18n import gettext as _ -from demandload import demandload -demandload(globals(), "binascii changegroup errno ancestor mdiff os") -demandload(globals(), "sha struct util zlib") +import binascii, changegroup, errno, ancestor, mdiff, os +import sha, struct, util, zlib # revlog version strings REVLOGV0 = 0
--- a/mercurial/sshrepo.py Thu Dec 14 19:30:52 2006 +0100 +++ b/mercurial/sshrepo.py Thu Dec 14 13:49:33 2006 -0800 @@ -8,8 +8,7 @@ from node import * from remoterepo import * from i18n import gettext as _ -from demandload import * -demandload(globals(), "hg os re stat util") +import hg, os, re, stat, util class sshrepository(remoterepository): def __init__(self, ui, path, create=0):
--- a/mercurial/sshserver.py Thu Dec 14 19:30:52 2006 +0100 +++ b/mercurial/sshserver.py Thu Dec 14 13:49:33 2006 -0800 @@ -6,10 +6,9 @@ # This software may be used and distributed according to the terms # of the GNU General Public License, incorporated herein by reference. -from demandload import demandload from i18n import gettext as _ from node import * -demandload(globals(), "os streamclone sys tempfile util") +import os, streamclone, sys, tempfile, util class sshserver(object): def __init__(self, ui, repo):
--- a/mercurial/statichttprepo.py Thu Dec 14 19:30:52 2006 +0100 +++ b/mercurial/statichttprepo.py Thu Dec 14 13:49:33 2006 -0800 @@ -7,10 +7,9 @@ # This software may be used and distributed according to the terms # of the GNU General Public License, incorporated herein by reference. -from demandload import * from i18n import gettext as _ -demandload(globals(), "changelog filelog httprangereader") -demandload(globals(), "repo localrepo manifest os urllib urllib2 util") +import changelog, filelog, httprangereader +import repo, localrepo, manifest, os, urllib, urllib2, util class rangereader(httprangereader.httprangereader): def read(self, size=None):
--- a/mercurial/streamclone.py Thu Dec 14 19:30:52 2006 +0100 +++ b/mercurial/streamclone.py Thu Dec 14 13:49:33 2006 -0800 @@ -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. -from demandload import demandload from i18n import gettext as _ -demandload(globals(), "os stat util lock") +import os, stat, util, lock # if server supports streaming clone, it advertises "stream" # capability with value that is version+flags of repo it is serving.
--- a/mercurial/templater.py Thu Dec 14 19:30:52 2006 +0100 +++ b/mercurial/templater.py Thu Dec 14 13:49:33 2006 -0800 @@ -5,10 +5,9 @@ # This software may be used and distributed according to the terms # of the GNU General Public License, incorporated herein by reference. -from demandload import demandload from i18n import gettext as _ from node import * -demandload(globals(), "cgi re sys os time urllib util textwrap") +import cgi, re, sys, os, time, urllib, util, textwrap def parsestring(s, quoted=True): '''parse a string using simple c-like syntax.
--- a/mercurial/transaction.py Thu Dec 14 19:30:52 2006 +0100 +++ b/mercurial/transaction.py Thu Dec 14 13:49:33 2006 -0800 @@ -11,9 +11,8 @@ # This software may be used and distributed according to the terms # of the GNU General Public License, incorporated herein by reference. -from demandload import demandload from i18n import gettext as _ -demandload(globals(), 'os') +import os class transaction(object): def __init__(self, report, opener, journal, after=None):
--- a/mercurial/ui.py Thu Dec 14 19:30:52 2006 +0100 +++ b/mercurial/ui.py Thu Dec 14 13:49:33 2006 -0800 @@ -6,9 +6,8 @@ # of the GNU General Public License, incorporated herein by reference. from i18n import gettext as _ -from demandload import * -demandload(globals(), "errno getpass os re socket sys tempfile") -demandload(globals(), "ConfigParser traceback util") +import errno, getpass, os, re, socket, sys, tempfile +import ConfigParser, traceback, util def dupconfig(orig): new = util.configparser(orig.defaults())
--- a/mercurial/util.py Thu Dec 14 19:30:52 2006 +0100 +++ b/mercurial/util.py Thu Dec 14 13:49:33 2006 -0800 @@ -13,9 +13,8 @@ """ from i18n import gettext as _ -from demandload import * -demandload(globals(), "cStringIO errno getpass popen2 re shutil sys tempfile") -demandload(globals(), "os threading time calendar ConfigParser locale") +import cStringIO, errno, getpass, popen2, re, shutil, sys, tempfile +import os, threading, time, calendar, ConfigParser, locale _encoding = os.environ.get("HGENCODING") or locale.getpreferredencoding() \ or "ascii" @@ -693,7 +692,7 @@ # Platform specific variants if os.name == 'nt': - demandload(globals(), "msvcrt") + import msvcrt nulldev = 'NUL:' class winstdout:
--- a/mercurial/util_win32.py Thu Dec 14 19:30:52 2006 +0100 +++ b/mercurial/util_win32.py Thu Dec 14 13:49:33 2006 -0800 @@ -13,10 +13,10 @@ import win32api -from demandload import * from i18n import gettext as _ -demandload(globals(), 'errno os pywintypes win32con win32file win32process') -demandload(globals(), 'cStringIO win32com.shell:shell,shellcon winerror') +import errno, os, pywintypes, win32con, win32file, win32process +import cStringIO, winerror +from win32com.shell import shell,shellcon class WinError: winerror_map = {
--- a/setup.py Thu Dec 14 19:30:52 2006 +0100 +++ b/setup.py Thu Dec 14 13:49:33 2006 -0800 @@ -13,8 +13,6 @@ from distutils.core import setup, Extension from distutils.command.install_data import install_data -# mercurial.packagescan must be the first mercurial module imported -import mercurial.packagescan import mercurial.version # py2exe needs to be installed to work @@ -35,31 +33,6 @@ except ImportError: pass - # Due to the use of demandload py2exe is not finding the modules. - # packagescan.getmodules creates a list of modules included in - # the mercurial package plus dependant modules. - from py2exe.build_exe import py2exe as build_exe - - class py2exe_for_demandload(build_exe): - """ overwrites the py2exe command class for getting the build - directory and for setting the 'includes' option.""" - def initialize_options(self): - self.build_lib = None - build_exe.initialize_options(self) - def finalize_options(self): - # Get the build directory, ie. where to search for modules. - self.set_undefined_options('build', - ('build_lib', 'build_lib')) - # Sets the 'includes' option with the list of needed modules - if not self.includes: - self.includes = [] - else: - self.includes = self.includes.split(',') - mercurial.packagescan.scan(self.build_lib, 'mercurial') - mercurial.packagescan.scan(self.build_lib, 'mercurial.hgweb') - mercurial.packagescan.scan(self.build_lib, 'hgext') - self.includes += mercurial.packagescan.getmodules() - build_exe.finalize_options(self) except ImportError: py2exe_for_demandload = None
--- a/tests/test-branch Thu Dec 14 19:30:52 2006 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ -#!/bin/sh -# -# test for branch handling -# -# XXX: need more tests - -hg init -echo a > a -echo b > b -hg ci -A -m 0 -d "1000000 0" -echo aa > a -echo bb > b -hg ci -m 1 -d "1000000 0" -hg tag -l foo -hg update 0 -hg parents -b - -# test update -hg update -b foo -hg parents - -# test merge -hg update 0 -echo c > c -hg ci -A -m 0.0 -d "1000000 0" -hg merge -b foo -hg parents -b - -# re-test with more branches -hg update -C 0 -echo d > d -hg ci -A -m 0.0 -d "1000000 0" -hg merge -b foo -hg parents -b
--- a/tests/test-branch.out Thu Dec 14 19:30:52 2006 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,61 +0,0 @@ -adding a -adding b -2 files updated, 0 files merged, 0 files removed, 0 files unresolved -the --branches option is deprecated, please use 'hg branches' instead -changeset: 0:b544c4ac4389 -user: test -date: Mon Jan 12 13:46:40 1970 +0000 -summary: 0 - -the --branch option is deprecated, please use 'hg branch' instead -Using head f4ac749470f2 for branch foo -2 files updated, 0 files merged, 0 files removed, 0 files unresolved -changeset: 1:f4ac749470f2 -tag: foo -tag: tip -user: test -date: Mon Jan 12 13:46:40 1970 +0000 -summary: 1 - -2 files updated, 0 files merged, 0 files removed, 0 files unresolved -adding c -the --branch option is deprecated, please use 'hg branch' instead -Using head f4ac749470f2 for branch foo -2 files updated, 0 files merged, 0 files removed, 0 files unresolved -(branch merge, don't forget to commit) -the --branches option is deprecated, please use 'hg branches' instead -changeset: 2:1505d56ee00e -tag: tip -parent: 0:b544c4ac4389 -user: test -date: Mon Jan 12 13:46:40 1970 +0000 -summary: 0.0 - -changeset: 1:f4ac749470f2 -tag: foo -branch: foo -user: test -date: Mon Jan 12 13:46:40 1970 +0000 -summary: 1 - -2 files updated, 0 files merged, 1 files removed, 0 files unresolved -adding d -the --branch option is deprecated, please use 'hg branch' instead -Using head f4ac749470f2 for branch foo -2 files updated, 0 files merged, 0 files removed, 0 files unresolved -(branch merge, don't forget to commit) -the --branches option is deprecated, please use 'hg branches' instead -changeset: 3:53b72df12ae5 -tag: tip -parent: 0:b544c4ac4389 -user: test -date: Mon Jan 12 13:46:40 1970 +0000 -summary: 0.0 - -changeset: 1:f4ac749470f2 -tag: foo -branch: foo -user: test -date: Mon Jan 12 13:46:40 1970 +0000 -summary: 1 -