Changeset 52f190ed3212…
Parent e5ee05b3f381…
by
Changes to 4 files · Browse files at 52f190ed3212 Showing diff from parent e5ee05b3f381 Diff from another changeset...
@@ -463,13 +463,8 @@ if dopatch:
try:
pfiles = {}
- if patch.patchfile.__bases__:
- # Mercurial 1.3
- patch.internalpatch(fp, ui, 1, repo.root, files=pfiles,
+ patch.internalpatch(fp, ui, 1, repo.root, files=pfiles,
eolmode=None)
- else:
- # Mercurial 1.2
- patch.internalpatch(fp, ui, 1, repo.root, files=pfiles)
patch.updatedir(ui, repo, pfiles)
except patch.PatchError, err:
s = str(err)
|
@@ -429,7 +429,7 @@
? - display help'''
- if not hglib.calliffunc(ui.interactive):
+ if not ui.interactive():
raise util.Abort(_('shelve can only be run interactively'))
forced = opts['force'] or opts['append']
@@ -501,12 +501,7 @@ if dopatch:
ui.debug(_('applying patch\n'))
ui.debug(fp.getvalue())
- if patch.patchfile.__bases__:
- # Mercurial 1.3
- patch.internalpatch(fp, ui, 1, repo.root, eolmode=None)
- else:
- # Mercurial 1.2
- patch.internalpatch(fp, ui, 1, repo.root)
+ patch.internalpatch(fp, ui, 1, repo.root, eolmode=None)
del fp
# 3c. apply filtered patch to clean repo (shelve)
|
@@ -23,14 +23,8 @@ main thread to pickup.
'''
def __init__(self, src=None, outputq=None, errorq=None, dialogq=None,
- responseq=None, parentui=None):
- if parentui:
- # Mercurial 1.2
- super(GtkUi, self).__init__(parentui=parentui)
- src = parentui
- else:
- # Mercurial 1.3
- super(GtkUi, self).__init__(src)
+ responseq=None):
+ super(GtkUi, self).__init__(src)
if src:
self.outputq = src.outputq
self.errorq = src.errorq
@@ -57,7 +51,7 @@
def prompt(self, msg, choices=None, default="y"):
import re
- if not hglib.calliffunc(self.interactive): return default
+ if not self.interactive(): return default
if isinstance(choices, str):
pat = choices
choices = None
@@ -154,24 +148,7 @@
def run(self):
try:
- ret = None
- if hasattr(self.ui, 'copy'):
- # Mercurial 1.3
- ret = hglib.dispatch._dispatch(self.ui, self.args)
- else:
- # Mercurial 1.2
- # Some commands create repositories, and thus must create
- # new ui() instances. For those, we monkey-patch ui.ui()
- # as briefly as possible.
- origui = None
- if self.args[0] in ('clone', 'init'):
- origui = ui.ui
- ui.ui = GtkUi
- try:
- ret = hglib.thgdispatch(self.ui, None, self.args)
- finally:
- if origui:
- ui.ui = origui
+ ret = hglib.dispatch._dispatch(self.ui, self.args)
if ret:
self.ui.write(_('[command returned code %d]\n') % int(ret))
else:
@@ -181,7 +158,5 @@ self.postfunc(ret)
except (hglib.RepoError, urllib2.HTTPError, util.Abort), e:
self.ui.write_err(str(e) + '\n')
- except Exception, e:
+ except (Exception, OSError, IOError), e:
self.ui.write_err(str(e) + '\n')
- except hglib.WinIOError, e:
- self.ui.write_err(str(e) + '\n')
|
|
@@ -16,41 +16,13 @@ from i18n import _
import paths
-try:
- from mercurial.error import RepoError, ParseError, LookupError
- from mercurial.error import UnknownCommand, AmbiguousCommand
-except ImportError:
- from mercurial.cmdutil import UnknownCommand, AmbiguousCommand
- from mercurial.repo import RepoError
- from mercurial.dispatch import ParseError
- from mercurial.revlog import LookupError
-
-from mercurial import dispatch
-
-try:
- from mercurial import encoding
- _encoding = encoding.encoding
- _encodingmode = encoding.encodingmode
- _fallbackencoding = encoding.fallbackencoding
-except ImportError:
- _encoding = util._encoding
- _encodingmode = util._encodingmode
- _fallbackencoding = util._fallbackencoding
-
-try:
- # post 1.1.2
- from mercurial import util
- hgversion = util.version()
-except AttributeError:
- # <= 1.1.2
- from mercurial import version
- hgversion = version.get_version()
-
-try:
- from mercurial.util import WinIOError
-except:
- class WinIOError(Exception):
- 'WinIOError stub'
+from mercurial.error import RepoError, ParseError, LookupError
+from mercurial.error import UnknownCommand, AmbiguousCommand
+from mercurial import dispatch, encoding, util
+_encoding = encoding.encoding
+_encodingmode = encoding.encodingmode
+_fallbackencoding = encoding.fallbackencoding
+hgversion = util.version()
def toutf(s):
"""
@@ -130,23 +102,12 @@ return False
return True
-def calliffunc(f):
- return hasattr(f, '__call__') and f() or f
-
-
def invalidaterepo(repo):
repo.invalidate()
repo.dirstate.invalidate()
if 'mq' in repo.__dict__: #do not create if it did not exist
mq = repo.mq
- if hasattr(mq, 'invalidate'):
- #Mercurial 1.3
- mq.invalidate()
- else:
- #Mercurial 1.2
- mqclass = mq.__class__
- repo.mq = mqclass(mq.ui, mq.basepath, mq.path)
-
+ mq.invalidate()
def hgcmd_toq(path, q, *args):
'''
@@ -163,11 +124,7 @@ for a in args:
q.put(str(a))
u = Qui()
- if hasattr(ui.ui, 'copy'):
- # Mercurial 1.3
- return dispatch._dispatch(u, list(args))
- else:
- return thgdispatch(u, path, list(args))
+ return dispatch._dispatch(u, list(args))
def displaytime(date):
@@ -175,160 +132,3 @@
def utctime(date):
return time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(date[0]))
-
-# the remaining functions are only needed for Mercurial versions < 1.3
-def _earlygetopt(aliases, args):
- """Return list of values for an option (or aliases).
-
- The values are listed in the order they appear in args.
- The options and values are removed from args.
- """
- try:
- argcount = args.index("--")
- except ValueError:
- argcount = len(args)
- shortopts = [opt for opt in aliases if len(opt) == 2]
- values = []
- pos = 0
- while pos < argcount:
- if args[pos] in aliases:
- if pos + 1 >= argcount:
- # ignore and let getopt report an error if there is no value
- break
- del args[pos]
- values.append(args.pop(pos))
- argcount -= 2
- elif args[pos][:2] in shortopts:
- # short option can have no following space, e.g. hg log -Rfoo
- values.append(args.pop(pos)[2:])
- argcount -= 1
- else:
- pos += 1
- return values
-
-_loaded = {}
-def thgdispatch(ui, path=None, args=[], nodefaults=True):
- '''
- Replicate functionality of mercurial dispatch but force the use
- of the passed in ui for all purposes
- '''
-
- # clear all user-defined command defaults
- if nodefaults:
- for k, v in ui.configitems('defaults'):
- ui.setconfig('defaults', k, '')
-
- # read --config before doing anything else
- # (e.g. to change trust settings for reading .hg/hgrc)
- config = _earlygetopt(['--config'], args)
- if config:
- for section, name, value in dispatch._parseconfig(config):
- ui.setconfig(section, name, value)
-
- # check for cwd
- cwd = _earlygetopt(['--cwd'], args)
- if cwd:
- os.chdir(cwd[-1])
-
- # read the local repository .hgrc into a local ui object
- path = paths.find_root(path) or ""
- if path:
- try:
- ui.readconfig(os.path.join(path, ".hg", "hgrc"))
- except IOError:
- pass
-
- # now we can expand paths, even ones in .hg/hgrc
- rpath = _earlygetopt(["-R", "--repository", "--repo"], args)
- if rpath:
- path = ui.expandpath(rpath[-1])
-
- extensions.loadall(ui)
- if not hasattr(extensions, 'extensions'):
- extensions.extensions = lambda: () # pre-0.9.5, loadall did below
- for name, module in extensions.extensions():
- if name in _loaded:
- continue
-
- # setup extensions
- extsetup = getattr(module, 'extsetup', None)
- if extsetup:
- extsetup()
-
- cmdtable = getattr(module, 'cmdtable', {})
- overrides = [cmd for cmd in cmdtable if cmd in commands.table]
- if overrides:
- ui.warn(_("extension '%s' overrides commands: %s\n") %
- (name, " ".join(overrides)))
- commands.table.update(cmdtable)
- _loaded[name] = 1
-
- # check for fallback encoding
- fallback = ui.config('ui', 'fallbackencoding')
- if fallback:
- _fallbackencoding = fallback
-
- fullargs = args
- cmd, func, args, options, cmdoptions = dispatch._parse(ui, args)
-
- if options["encoding"]:
- _encoding = options["encoding"]
- if options["encodingmode"]:
- _encodingmode = options["encodingmode"]
- if options['verbose'] or options['debug'] or options['quiet']:
- ui.setconfig('ui', 'verbose', str(bool(options['verbose'])))
- ui.setconfig('ui', 'debug', str(bool(options['debug'])))
- ui.setconfig('ui', 'quiet', str(bool(options['quiet'])))
- if options['traceback']:
- ui.setconfig('ui', 'traceback', 'on')
- if options['noninteractive']:
- ui.setconfig('ui', 'interactive', 'off')
-
- if options['help']:
- return commands.help_(ui, cmd, options['version'])
- elif options['version']:
- return commands.version_(ui)
- elif not cmd:
- return commands.help_(ui, 'shortlist')
-
- repo = None
- if cmd not in commands.norepo.split():
- try:
- repo = hg.repository(ui, path=path)
- repo.ui = ui
- ui.setconfig("bundle", "mainreporoot", repo.root)
- if not repo.local():
- raise util.Abort(_("repository '%s' is not local") % path)
- except RepoError:
- if cmd not in commands.optionalrepo.split():
- if not path:
- raise RepoError(_('There is no Mercurial repository here'
- ' (.hg not found)'))
- raise
- d = lambda: func(ui, repo, *args, **cmdoptions)
- else:
- d = lambda: func(ui, *args, **cmdoptions)
-
- # run pre-hook, and abort if it fails
- ret = hook.hook(ui, repo, "pre-%s" % cmd, False, args=" ".join(fullargs))
- if ret:
- return ret
-
- # Run actual command
- try:
- ret = d()
- except TypeError:
- # was this an argument error?
- tb = traceback.extract_tb(sys.exc_info()[2])
- if len(tb) != 2: # no
- raise
- raise ParseError(cmd, _('invalid arguments'))
-
- # run post-hook, passing command result
- hook.hook(ui, repo, "post-%s" % cmd, False, args=" ".join(fullargs),
- result = ret)
-
- if repo:
- shlib.update_thgstatus(repo.ui, repo.root, wait=True)
-
- return ret
|
Loading...