Esempio n. 1
0
def uisetup(ui):
    if '--debugger' in sys.argv or not ui.formatted():
        return

    # chg has its own pager implementation
    argv = sys.argv[:]
    if 'chgunix' in dispatch._earlygetopt(['--cmdserver'], argv):
        return

    def pagecmd(orig, ui, options, cmd, cmdfunc):
        p = ui.config("pager", "pager", os.environ.get("PAGER"))
        usepager = False
        always = util.parsebool(options['pager'])
        auto = options['pager'] == 'auto'

        if not p:
            pass
        elif always:
            usepager = True
        elif not auto:
            usepager = False
        else:
            attend = ui.configlist('pager', 'attend', attended)
            ignore = ui.configlist('pager', 'ignore')
            cmds, _ = cmdutil.findcmd(cmd, commands.table)

            for cmd in cmds:
                var = 'attend-%s' % cmd
                if ui.config('pager', var):
                    usepager = ui.configbool('pager', var)
                    break
                if (cmd in attend or (cmd not in ignore and not attend)):
                    usepager = True
                    break

        setattr(ui, 'pageractive', usepager)

        if usepager:
            ui.setconfig('ui', 'formatted', ui.formatted(), 'pager')
            ui.setconfig('ui', 'interactive', False, 'pager')
            if util.safehasattr(signal, "SIGPIPE"):
                signal.signal(signal.SIGPIPE, signal.SIG_DFL)
            _runpager(ui, p)
        return orig(ui, options, cmd, cmdfunc)

    # Wrap dispatch._runcommand after color is loaded so color can see
    # ui.pageractive. Otherwise, if we loaded first, color's wrapped
    # dispatch._runcommand would run without having access to ui.pageractive.
    def afterloaded(loaded):
        extensions.wrapfunction(dispatch, '_runcommand', pagecmd)

    extensions.afterloaded('color', afterloaded)
Esempio n. 2
0
File: pager.py Progetto: motlin/cyg
def uisetup(ui):
    if '--debugger' in sys.argv or not ui.formatted():
        return

    # chg has its own pager implementation
    argv = sys.argv[:]
    if 'chgunix' in dispatch._earlygetopt(['--cmdserver'], argv):
        return

    def pagecmd(orig, ui, options, cmd, cmdfunc):
        p = ui.config("pager", "pager", os.environ.get("PAGER"))
        usepager = False
        always = util.parsebool(options['pager'])
        auto = options['pager'] == 'auto'

        if not p:
            pass
        elif always:
            usepager = True
        elif not auto:
            usepager = False
        else:
            attend = ui.configlist('pager', 'attend', attended)
            ignore = ui.configlist('pager', 'ignore')
            cmds, _ = cmdutil.findcmd(cmd, commands.table)

            for cmd in cmds:
                var = 'attend-%s' % cmd
                if ui.config('pager', var):
                    usepager = ui.configbool('pager', var)
                    break
                if (cmd in attend or
                     (cmd not in ignore and not attend)):
                    usepager = True
                    break

        setattr(ui, 'pageractive', usepager)

        if usepager:
            ui.setconfig('ui', 'formatted', ui.formatted(), 'pager')
            ui.setconfig('ui', 'interactive', False, 'pager')
            if util.safehasattr(signal, "SIGPIPE"):
                signal.signal(signal.SIGPIPE, signal.SIG_DFL)
            _runpager(ui, p)
        return orig(ui, options, cmd, cmdfunc)

    # Wrap dispatch._runcommand after color is loaded so color can see
    # ui.pageractive. Otherwise, if we loaded first, color's wrapped
    # dispatch._runcommand would run without having access to ui.pageractive.
    def afterloaded(loaded):
        extensions.wrapfunction(dispatch, '_runcommand', pagecmd)
    extensions.afterloaded('color', afterloaded)
Esempio n. 3
0
def extsetup(ui):
    extensions.wrapfunction(cmdutil, 'amend', _amend)
    extensions.wrapfunction(localrepo.localrepository, 'commit', _commit)

    def wrapshelve(loaded=False):
        try:
            shelvemod = extensions.find('shelve')
            extensions.wrapcommand(shelvemod.cmdtable, 'shelve',
                                   _bypassdirsync)
            extensions.wrapcommand(shelvemod.cmdtable, 'unshelve',
                                   _bypassdirsync)
        except KeyError:
            pass
    extensions.afterloaded('shelve', wrapshelve)
Esempio n. 4
0
def extsetup(ui):
    # Wrap the APIs used to get the revisions for "hg log" so we
    # can peekahead into the rev list and query phabricator for multiple diffs
    # at once.
    extensions.wrapfunction(cmdutil, 'getlogrevs', _getlogrevs)
    extensions.wrapfunction(cmdutil, 'getgraphlogrevs', _getlogrevs)

    # Also wrap the APIs used by smartlog
    def _smartlogloaded(loaded):
        smartlog = None
        try:
            smartlog = extensions.find('smartlog')
        except KeyError:
            pass
        if smartlog:
            extensions.wrapfunction(smartlog, 'getdag', _getsmartlogdag)

    extensions.afterloaded('smartlog', _smartlogloaded)
Esempio n. 5
0
def uisetup(ui):
    """Wraps user facing Mercurial commands to swap them out with shallow
    versions.
    """
    hg.wirepeersetupfuncs.append(fileserverclient.peersetup)

    entry = extensions.wrapcommand(commands.table, 'clone', cloneshallow)
    entry[1].append(('', 'shallow', None,
                     _("create a shallow clone which uses remote file "
                       "history")))

    extensions.wrapcommand(commands.table, 'debugindex',
                           debugcommands.debugindex)
    extensions.wrapcommand(commands.table, 'debugindexdot',
                           debugcommands.debugindexdot)
    extensions.wrapcommand(commands.table, 'log', log)
    extensions.wrapcommand(commands.table, 'pull', pull)

    # Prevent 'hg manifest --all'
    def _manifest(orig, ui, repo, *args, **opts):
        if (isenabled(repo) and opts.get(r'all')):
            raise error.Abort(_("--all is not supported in a shallow repo"))

        return orig(ui, repo, *args, **opts)

    extensions.wrapcommand(commands.table, "manifest", _manifest)

    # Wrap remotefilelog with lfs code
    def _lfsloaded(loaded=False):
        lfsmod = None
        try:
            lfsmod = extensions.find('lfs')
        except KeyError:
            pass
        if lfsmod:
            lfsmod.wrapfilelog(remotefilelog.remotefilelog)
            fileserverclient._lfsmod = lfsmod

    extensions.afterloaded('lfs', _lfsloaded)

    # debugdata needs remotefilelog.len to work
    extensions.wrapcommand(commands.table, 'debugdata', debugdatashallow)
Esempio n. 6
0
def uisetup(ui):
    """Wraps user facing Mercurial commands to swap them out with shallow
    versions.
    """
    hg.wirepeersetupfuncs.append(fileserverclient.peersetup)

    entry = extensions.wrapcommand(commands.table, 'clone', cloneshallow)
    entry[1].append(('', 'shallow', None,
                     _("create a shallow clone which uses remote file "
                       "history")))

    extensions.wrapcommand(commands.table, 'debugindex',
        debugcommands.debugindex)
    extensions.wrapcommand(commands.table, 'debugindexdot',
        debugcommands.debugindexdot)
    extensions.wrapcommand(commands.table, 'log', log)
    extensions.wrapcommand(commands.table, 'pull', pull)

    # Prevent 'hg manifest --all'
    def _manifest(orig, ui, repo, *args, **opts):
        if shallowrepo.requirement in repo.requirements and opts.get('all'):
            raise error.Abort(_("--all is not supported in a shallow repo"))

        return orig(ui, repo, *args, **opts)
    extensions.wrapcommand(commands.table, "manifest", _manifest)

    # Wrap remotefilelog with lfs code
    def _lfsloaded(loaded=False):
        lfsmod = None
        try:
            lfsmod = extensions.find('lfs')
        except KeyError:
            pass
        if lfsmod:
            lfsmod.wrapfilelog(remotefilelog.remotefilelog)
            fileserverclient._lfsmod = lfsmod
    extensions.afterloaded('lfs', _lfsloaded)

    # debugdata needs remotefilelog.len to work
    extensions.wrapcommand(commands.table, 'debugdata', debugdatashallow)
Esempio n. 7
0
def uisetup(ui):
    hiddenoverride.uisetup(ui)
    prune.uisetup(ui)
    entry = extensions.wrapcommand(commands.table, 'commit', commit)
    for opt in amendopts:
        opt = (opt[0], opt[1], opt[2], "(with --amend) " + opt[3])
        entry[1].append(opt)

    # manual call of the decorator
    command('^amend', [
            ('A', 'addremove', None,
             _('mark new/missing files as added/removed before committing')),
           ('e', 'edit', None, _('prompt to edit the commit message')),
           ('i', 'interactive', None, _('use interactive mode')),
       ] + amendopts + commands.walkopts + commands.commitopts
        + commands.commitopts2,
       _('hg amend [OPTION]...'))(amend)

    def has_automv(loaded):
        if not loaded:
            return
        automv = extensions.find('automv')
        entry = extensions.wrapcommand(cmdtable, 'amend', automv.mvcheck)
        entry[1].append(
            ('', 'no-move-detection', None,
             _('disable automatic file move detection')))
    extensions.afterloaded('automv', has_automv)

    def evolveloaded(loaded):
        if not loaded:
            return

        evolvemod = extensions.find('evolve')

        # Remove conflicted commands from evolve.
        table = evolvemod.cmdtable
        for name in ['prev', 'next', 'split', 'fold', 'metaedit', 'prune']:
            todelete = [k for k in table if name in k]
            for k in todelete:
                oldentry = table[k]
                table['debugevolve%s' % name] = oldentry
                del table[k]

    extensions.afterloaded('evolve', evolveloaded)

    def rebaseloaded(loaded):
        if not loaded:
            return
        entry = extensions.wrapcommand(rebasemod.cmdtable, 'rebase',
                                       wraprebase)
        entry[1].append((
            '', 'restack', False, _('rebase all changesets in the current '
                                    'stack onto the latest version of their '
                                    'respective parents')
        ))
    extensions.afterloaded('rebase', rebaseloaded)
Esempio n. 8
0
def uisetup(ui):
    # developer config: fbamend.safestrip
    if ui.configbool('fbamend', 'safestrip'):
        extensions.afterloaded('strip', wrapstrip)
Esempio n. 9
0
def extsetup(ui):
    entry = wrapcommand(commands.table, 'update', update)
    options = entry[1]
    # try to put in alphabetical order
    options.insert(3, ('', 'inactive', None,
        _('update without activating bookmarks')))
    wrapblame()

    entry = wrapcommand(commands.table, 'commit', commitcmd)
    options = entry[1]
    options.insert(9, ('M', 'reuse-message', '',
        _('reuse commit message from REV'), _('REV')))
    opawarerebase = markermetadatawritingcommand(ui, _rebase, 'rebase')
    wrapcommand(rebase.cmdtable, 'rebase', opawarerebase)
    wrapfunction(scmutil, 'cleanupnodes', cleanupnodeswrapper)
    entry = wrapcommand(commands.table, 'pull', pull)
    options = entry[1]
    options.append(
        ('d', 'dest', '', _('destination for rebase or update')))

    # anonymous function to pass ui object to _analyzewrapper
    def _analyzewrap(orig, x):
        return _analyzewrapper(orig, x, ui)

    wrapfunction(revsetlang, '_analyze', _analyzewrap)

    try:
        rebaseext = extensions.find('rebase')
        # tweakdefaults is already loaded before other extensions
        # (see tweakorder() function) so if these functions are wrapped
        # by something else, it's not a problem.
        wrapfunction(rebaseext, '_computeobsoletenotrebased',
                     _computeobsoletenotrebasedwrapper)
        wrapfunction(rebaseext, '_checkobsrebase',
                     _checkobsrebasewrapper)
    except KeyError:
        pass # no rebase, no problem
    except AssertionError:
        msg = _('tweakdefaults: _computeobsoletenotrebased or ' +
                '_checkobsrebase are not what we expect them to be')
        ui.warning(msg)

    try:
        remotenames = extensions.find('remotenames')
        wrapfunction(remotenames, '_getrebasedest', _getrebasedest)
    except KeyError:
        pass # no remotenames, no worries
    except AttributeError:
        pass # old version of remotenames doh

    entry = wrapcommand(commands.table, 'log', log)
    for opt in logopts:
        opt = (opt[0], opt[1], opt[2], opt[3])
        entry[1].append(opt)

    entry = wrapcommand(commands.table, 'branch', branchcmd)
    options = entry[1]
    options.append(('', 'new', None, _('allow branch creation')))
    wrapcommand(commands.table, 'branches', branchescmd)

    wrapcommand(commands.table, 'merge', mergecmd)

    entry = wrapcommand(commands.table, 'status', statuscmd)
    options = entry[1]
    options.append(
        ('', 'root-relative', None, _('show status relative to root')))

    wrapcommand(commands.table, 'rollback', rollbackcmd)

    wrapcommand(commands.table, 'tag', tagcmd)
    wrapcommand(commands.table, 'tags', tagscmd)
    wrapcommand(commands.table, 'graft', graftcmd)
    try:
        fbamendmodule = extensions.find('fbamend')
        opawareamend = markermetadatawritingcommand(ui, amendcmd, 'amend')
        wrapcommand(fbamendmodule.cmdtable, 'amend', opawareamend)
    except KeyError:
        pass
    try:
        histeditmodule = extensions.find('histedit')
        wrapfunction(histeditmodule, 'commitfuncfor', histeditcommitfuncfor)
    except KeyError:
        pass

    # wrapped createmarkers knows how to write operation-aware
    # metadata (e.g. 'amend', 'rebase' and so forth)
    wrapfunction(obsolete, 'createmarkers', _createmarkers)

    # bookmark -D is an alias to strip -B
    entry = wrapcommand(commands.table, 'bookmarks', bookmarkcmd)
    entry[1].insert(3, ('D', 'strip', None,
                        _('like --delete but also strip changesets')))

    # wrap bookmarks after remotenames
    def afterloaded(loaded):
        if loaded:
            # remotenames is loaded, wrap its wrapper directly
            remotenames = extensions.find('remotenames')
            wrapfunction(remotenames, 'exbookmarks', unfilteredcmd)
            wrapfunction(remotenames, 'expullcmd', pullrebaseffwd)
        else:
            # otherwise wrap the bookmarks command
            wrapcommand(commands.table, 'bookmarks', unfilteredcmd)
    extensions.afterloaded('remotenames', afterloaded)

    entry = wrapcommand(commands.table, 'diff', diffcmd)
    options = entry[1]
    options.append(
        ('', 'per-file-stat-json', None,
         _('show diff stat per file in json (ADVANCED)')))

    pipei_bufsize = ui.configint('experimental', 'winpipebufsize', 4096)
    if pipei_bufsize != 4096 and os.name == 'nt':
        wrapfunction(util, 'popen4', get_winpopen4(pipei_bufsize))

    # Tweak Behavior
    tweakbehaviors(ui)
    _fixpager(ui)

    # Change manifest template output
    templatekw.defaulttempl['manifest'] = '{node}'
Esempio n. 10
0
def uisetup(ui):
    """Wraps user facing Mercurial commands to swap them out with shallow
    versions.
    """
    hg.wirepeersetupfuncs.append(fileserverclient.peersetup)

    entry = extensions.wrapcommand(commands.table, b'clone', cloneshallow)
    entry[1].append((
        b'',
        b'shallow',
        None,
        _(b"create a shallow clone which uses remote file history"),
    ))

    extensions.wrapcommand(commands.table, b'debugindex',
                           debugcommands.debugindex)
    extensions.wrapcommand(commands.table, b'debugindexdot',
                           debugcommands.debugindexdot)
    extensions.wrapcommand(commands.table, b'log', log)
    extensions.wrapcommand(commands.table, b'pull', pull)

    # Prevent 'hg manifest --all'
    def _manifest(orig, ui, repo, *args, **opts):
        if isenabled(repo) and opts.get('all'):
            raise error.Abort(_(b"--all is not supported in a shallow repo"))

        return orig(ui, repo, *args, **opts)

    extensions.wrapcommand(commands.table, b"manifest", _manifest)

    # Wrap remotefilelog with lfs code
    def _lfsloaded(loaded=False):
        lfsmod = None
        try:
            lfsmod = extensions.find(b'lfs')
        except KeyError:
            pass
        if lfsmod:
            lfsmod.wrapfilelog(remotefilelog.remotefilelog)
            fileserverclient._lfsmod = lfsmod

    extensions.afterloaded(b'lfs', _lfsloaded)

    # debugdata needs remotefilelog.len to work
    extensions.wrapcommand(commands.table, b'debugdata', debugdatashallow)

    changegroup.cgpacker = shallowbundle.shallowcg1packer

    extensions.wrapfunction(changegroup, b'_addchangegroupfiles',
                            shallowbundle.addchangegroupfiles)
    extensions.wrapfunction(changegroup, b'makechangegroup',
                            shallowbundle.makechangegroup)
    extensions.wrapfunction(localrepo, b'makestore', storewrapper)
    extensions.wrapfunction(exchange, b'pull', exchangepull)
    extensions.wrapfunction(merge, b'applyupdates', applyupdates)
    extensions.wrapfunction(merge, b'_checkunknownfiles', checkunknownfiles)
    extensions.wrapfunction(context.workingctx, b'_checklookup', checklookup)
    extensions.wrapfunction(scmutil, b'_findrenames', findrenames)
    extensions.wrapfunction(copies, b'_computeforwardmissing',
                            computeforwardmissing)
    extensions.wrapfunction(dispatch, b'runcommand', runcommand)
    extensions.wrapfunction(repair, b'_collectbrokencsets',
                            _collectbrokencsets)
    extensions.wrapfunction(context.changectx, b'filectx', filectx)
    extensions.wrapfunction(context.workingctx, b'filectx', workingfilectx)
    extensions.wrapfunction(patch, b'trydiff', trydiff)
    extensions.wrapfunction(hg, b'verify', _verify)
    scmutil.fileprefetchhooks.add(b'remotefilelog', _fileprefetchhook)

    # disappointing hacks below
    extensions.wrapfunction(scmutil, b'getrenamedfn', getrenamedfn)
    extensions.wrapfunction(revset, b'filelog', filelogrevset)
    revset.symbols[b'filelog'] = revset.filelog