Mercurial > hg > hgforest
changeset 57:d865dae2261b
Refactor the findcmd compatibility system to prefer the newer syntax.
The code's usage of findcmd() looks like Mercurial tip, so merging this
extension will become easier.
author | Simon Law <simon@akoha.org> |
---|---|
date | Mon, 20 Aug 2007 16:28:55 -0400 |
parents | 8648e7ba97e8 |
children | d575d52a113b |
files | forest.py |
diffstat | 1 files changed, 18 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/forest.py Wed Aug 15 10:50:30 2007 -0400 +++ b/forest.py Mon Aug 20 16:28:55 2007 -0400 @@ -48,27 +48,35 @@ import os import re -from mercurial import commands, hg, node, util +from mercurial import cmdutil, commands, hg, node, util from mercurial import localrepo, sshrepo, sshserver, httprepo, statichttprepo from mercurial.hgweb import hgweb_mod -try: - _findcmd = commands.findcmd -except AttributeError: - from mercurial import cmdutil - _findcmd = cmdutil.findcmd from mercurial.i18n import gettext as _ from mercurial.repo import RepoError +# For backwards compatibility, we need the following function definition. +# If we didn't want that, we'd have just written: +# from mercurial.commands import +def findcmd(ui, cmd, table): + """Find and execute mercurial.*.findcmd(ui, cmd[, table]).""" + try: + return findcmd.findcmd(ui, cmd, table) + except TypeError: + return findcmd.findcmd(ui, cmd) +try: + findcmd.findcmd = cmdutil.findcmd + findcmd.__doc__ = cmdutil.findcmd.__doc__ +except AttributeError: + findcmd.findcmd = commands.findcmd + findcmd.__doc__ = commands.findcmd.__doc__ + cmdtable = None commands.norepo += " fclone fseed" def cmd_options(ui, cmd, remove=None): - try: - aliases, spec = _findcmd(ui, cmd, commands.table) - except TypeError: - aliases, spec = _findcmd(ui, cmd) + aliases, spec = findcmd(ui, cmd, commands.table) res = list(spec[1]) if remove is not None: res = [opt for opt in res if opt[0] not in remove]