• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python util.safehasattr函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mercurial.util.safehasattr函数的典型用法代码示例。如果您正苦于以下问题:Python safehasattr函数的具体用法?Python safehasattr怎么用?Python safehasattr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了safehasattr函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: log

        def log(self, event, *msg, **opts):
            global lastblackbox
            super(blackboxui, self).log(event, *msg, **opts)

            if not '*' in self.track and not event in self.track:
                return

            if util.safehasattr(self, '_blackbox'):
                blackbox = self._blackbox
            elif util.safehasattr(self, '_bbopener'):
                try:
                    self._blackbox = self._openlogfile()
                except (IOError, OSError) as err:
                    self.debug('warning: cannot write to blackbox.log: %s\n' %
                               err.strerror)
                    del self._bbopener
                    self._blackbox = None
                blackbox = self._blackbox
            else:
                # certain ui instances exist outside the context of
                # a repo, so just default to the last blackbox that
                # was seen.
                blackbox = lastblackbox

            if blackbox:
                date = util.datestr(None, '%Y/%m/%d %H:%M:%S')
                user = util.getuser()
                formattedmsg = msg[0] % msg[1:]
                try:
                    blackbox.write('%s %s> %s' % (date, user, formattedmsg))
                except IOError as err:
                    self.debug('warning: cannot write to blackbox.log: %s\n' %
                               err.strerror)
                lastblackbox = blackbox
开发者ID:pierfort123,项目名称:mercurial,代码行数:34,代码来源:blackbox.py


示例2: populateresponseforphab

def populateresponseforphab(repo, diffnum):
    """:populateresponse: Runs the memoization function
        for use of phabstatus and sync status
    """
    if not hgutil.safehasattr(repo, '_phabstatusrevs'):
        return

    if (hgutil.safehasattr(repo, '_phabstatuscache') and
            (repo, diffnum) in repo._phabstatuscache):
        # We already have cached data for this diff
        return

    next_revs = repo._phabstatusrevs.peekahead()
    if repo._phabstatusrevs.done:
        # repo._phabstatusrevs doesn't have anything else to process.
        # Remove it so we will bail out earlier next time.
        del repo._phabstatusrevs

    alldiffnumbers = [getdiffnum(repo, repo[rev])
                      for rev in next_revs]
    okdiffnumbers = set(d for d in alldiffnumbers if d is not None)
    # Make sure we always include the requested diff number
    okdiffnumbers.add(diffnum)
    # To populate the cache, the result will be used by the templater
    getdiffstatus(repo, *okdiffnumbers)
开发者ID:davidshepherd7,项目名称:dotfiles,代码行数:25,代码来源:phabstatus.py


示例3: clearcaches

def clearcaches(cl):
    # behave somewhat consistently across internal API changes
    if util.safehasattr(cl, 'clearcaches'):
        cl.clearcaches()
    elif util.safehasattr(cl, '_nodecache'):
        from mercurial.node import nullid, nullrev
        cl._nodecache = {nullid: nullrev}
        cl._nodepos = None
开发者ID:CSCI-362-02-2015,项目名称:RedTeam,代码行数:8,代码来源:perf.py


示例4: extsetup

def extsetup(ui):
    """insert command wrappers for a bunch of commands"""

    docvals = {"extension": "hgsubversion"}
    for cmd, (generic, target, fixdoc, ppopts, opts) in wrapcmds.iteritems():

        if fixdoc and wrappers.generic.__doc__:
            docvals["command"] = cmd
            docvals["Command"] = cmd.capitalize()
            docvals["target"] = target
            doc = wrappers.generic.__doc__.strip() % docvals
            fn = getattr(commands, cmd)
            fn.__doc__ = fn.__doc__.rstrip() + "\n\n    " + doc

        wrapped = generic and wrappers.generic or getattr(wrappers, cmd)
        entry = extensions.wrapcommand(commands.table, cmd, wrapped)
        if ppopts:
            entry[1].extend(svnopts)
        if opts:
            entry[1].extend(opts)

    try:
        rebase = extensions.find("rebase")
        if not rebase:
            return
        entry = extensions.wrapcommand(rebase.cmdtable, "rebase", wrappers.rebase)
        entry[1].append(("", "svn", None, "automatic svn rebase"))
    except:
        pass

    if not hgutil.safehasattr(localrepo.localrepository, "push"):
        # Mercurial >= 3.2
        extensions.wrapfunction(exchange, "push", wrappers.exchangepush)
    if not hgutil.safehasattr(localrepo.localrepository, "pull"):
        # Mercurial >= 3.2
        extensions.wrapfunction(exchange, "pull", wrappers.exchangepull)

    helpdir = os.path.join(os.path.dirname(__file__), "help")

    entries = (
        (
            ["subversion"],
            "Working with Subversion Repositories",
            lambda: open(os.path.join(helpdir, "subversion.rst")).read(),
        ),
    )

    help.helptable.extend(entries)

    templatekw.keywords.update(util.templatekeywords)

    revset.symbols.update(util.revsets)

    subrepo.types["hgsubversion"] = svnexternals.svnsubrepo
开发者ID:ZanderZhang,项目名称:Andriod-Learning,代码行数:54,代码来源:__init__.py


示例5: extsetup

def extsetup(ui):
    """insert command wrappers for a bunch of commands"""
    docvals = {'extension': 'hgsubversion'}
    for cmd, (generic, target, fixdoc, ppopts, opts) in wrapcmds.iteritems():

        if fixdoc and wrappers.generic.__doc__:
            docvals['command'] = cmd
            docvals['Command'] = cmd.capitalize()
            docvals['target'] = target
            doc = wrappers.generic.__doc__.strip() % docvals
            fn = getattr(commands, cmd)
            fn.__doc__ = fn.__doc__.rstrip() + '\n\n    ' + doc

        wrapped = generic and wrappers.generic or getattr(wrappers, cmd)
        entry = extensions.wrapcommand(commands.table, cmd, wrapped)
        if ppopts:
            entry[1].extend(svnopts)
        if opts:
            entry[1].extend(opts)

    try:
        rebase = extensions.find('rebase')
        if not rebase:
            return
        entry = extensions.wrapcommand(rebase.cmdtable, 'rebase', wrappers.rebase)
        entry[1].append(('', 'svn', None, 'automatic svn rebase'))
    except:
        pass

    if not hgutil.safehasattr(localrepo.localrepository, 'push'):
        # Mercurial >= 3.2
        extensions.wrapfunction(exchange, 'push', wrappers.exchangepush)
    if not hgutil.safehasattr(localrepo.localrepository, 'pull'):
        # Mercurial >= 3.2
        extensions.wrapfunction(exchange, 'pull', wrappers.exchangepull)

    helpdir = os.path.join(os.path.dirname(__file__), 'help')

    entries = (
        (['subversion'],
         "Working with Subversion Repositories",
         # Mercurial >= 3.6: doc(ui)
         lambda *args: open(os.path.join(helpdir, 'subversion.rst')).read()),
    )

    help.helptable.extend(entries)

    templatekw.keywords.update(util.templatekeywords)

    revset.symbols.update(util.revsets)

    subrepo.types['hgsubversion'] = svnexternals.svnsubrepo
开发者ID:seewindcn,项目名称:tortoisehg,代码行数:52,代码来源:__init__.py


示例6: relink

def relink(ui, repo, origin=None, **opts):
    """recreate hardlinks between two repositories

    When repositories are cloned locally, their data files will be
    hardlinked so that they only use the space of a single repository.

    Unfortunately, subsequent pulls into either repository will break
    hardlinks for any files touched by the new changesets, even if
    both repositories end up pulling the same changes.

    Similarly, passing --rev to "hg clone" will fail to use any
    hardlinks, falling back to a complete copy of the source
    repository.

    This command lets you recreate those hardlinks and reclaim that
    wasted space.

    This repository will be relinked to share space with ORIGIN, which
    must be on the same local disk. If ORIGIN is omitted, looks for
    "default-relink", then "default", in [paths].

    Do not attempt any read operations on this repository while the
    command is running. (Both repositories will be locked against
    writes.)
    """
    if (not util.safehasattr(util, 'samefile') or
        not util.safehasattr(util, 'samedevice')):
        raise error.Abort(_('hardlinks are not supported on this system'))
    src = hg.repository(repo.baseui, ui.expandpath(origin or 'default-relink',
                                          origin or 'default'))
    ui.status(_('relinking %s to %s\n') % (src.store.path, repo.store.path))
    if repo.root == src.root:
        ui.status(_('there is nothing to relink\n'))
        return

    if not util.samedevice(src.store.path, repo.store.path):
        # No point in continuing
        raise error.Abort(_('source and destination are on different devices'))

    locallock = repo.lock()
    try:
        remotelock = src.lock()
        try:
            candidates = sorted(collect(src, ui))
            targets = prune(candidates, src.store.path, repo.store.path, ui)
            do_relink(src.store.path, repo.store.path, targets, ui)
        finally:
            remotelock.release()
    finally:
        locallock.release()
开发者ID:Distrotech,项目名称:mercurial,代码行数:50,代码来源:relink.py


示例7: _hashmatcher

def _hashmatcher(matcher):
    if util.safehasattr(matcher, 'hash'):
        return matcher.hash()

    sha1 = hashlib.sha1()
    sha1.update(repr(matcher))
    return sha1.hexdigest()
开发者ID:davidshepherd7,项目名称:dotfiles,代码行数:7,代码来源:sparse.py


示例8: __init__

 def __init__(self, ctx, path, state):
     state = (state[0].split(':', 1)[1], state[1])
     super(svnsubrepo, self).__init__(ctx, path, state)
     # Mercurial 3.3+ set 'ui' rather than '_ui' -- set that and use 'ui'
     # everywhere to maintain compatibility across versions
     if not hgutil.safehasattr(self, 'ui'):
         self.ui = ctx._repo.ui
开发者ID:seewindcn,项目名称:tortoisehg,代码行数:7,代码来源:svnexternals.py


示例9: pagecmd

    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

        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)
开发者ID:ZanderZhang,项目名称:Andriod-Learning,代码行数:34,代码来源:pager.py


示例10: getpager

    def getpager(self):
        """Read cmdargs and write pager command to r-channel if enabled

        If pager isn't enabled, this writes '\0' because channeledoutput
        does not allow to write empty data.
        """
        args = self._readlist()
        try:
            cmd, _func, args, options, _cmdoptions = dispatch._parse(self.ui,
                                                                     args)
        except (error.Abort, error.AmbiguousCommand, error.CommandError,
                error.UnknownCommand):
            cmd = None
            options = {}
        if not cmd or 'pager' not in options:
            self.cresult.write('\0')
            return

        pagercmd = _setuppagercmd(self.ui, options, cmd)
        if pagercmd:
            # Python's SIGPIPE is SIG_IGN by default. change to SIG_DFL so
            # we can exit if the pipe to the pager is closed
            if util.safehasattr(signal, 'SIGPIPE') and \
                    signal.getsignal(signal.SIGPIPE) == signal.SIG_IGN:
                signal.signal(signal.SIGPIPE, signal.SIG_DFL)
            self.cresult.write(pagercmd)
        else:
            self.cresult.write('\0')
开发者ID:motlin,项目名称:cyg,代码行数:28,代码来源:chgserver.py


示例11: system

 def system(self, cmd, environ=None, cwd=None, onerr=None,
            errprefix=None):
     # fallback to the original system method if the output needs to be
     # captured (to self._buffers), or the output stream is not stdout
     # (e.g. stderr, cStringIO), because the chg client is not aware of
     # these situations and will behave differently (write to stdout).
     if (any(s[1] for s in self._bufferstates)
         or not util.safehasattr(self.fout, 'fileno')
         or self.fout.fileno() != sys.stdout.fileno()):
         return super(chgui, self).system(cmd, environ, cwd, onerr,
                                          errprefix)
     # copied from mercurial/util.py:system()
     self.flush()
     def py2shell(val):
         if val is None or val is False:
             return '0'
         if val is True:
             return '1'
         return str(val)
     env = os.environ.copy()
     if environ:
         env.update((k, py2shell(v)) for k, v in environ.iteritems())
     env['HG'] = util.hgexecutable()
     rc = self._csystem(cmd, env, cwd)
     if rc and onerr:
         errmsg = '%s %s' % (os.path.basename(cmd.split(None, 1)[0]),
                             util.explainexit(rc)[0])
         if errprefix:
             errmsg = '%s: %s' % (errprefix, errmsg)
         raise onerr(errmsg)
     return rc
开发者ID:motlin,项目名称:cyg,代码行数:31,代码来源:chgserver.py


示例12: wrapdirstate

def wrapdirstate(orig, repo):
    """Make journal storage available to the dirstate object"""
    dirstate = orig(repo)
    if util.safehasattr(repo, 'journal'):
        dirstate.journalstorage = repo.journal
        dirstate.addparentchangecallback('journal', recorddirstateparents)
    return dirstate
开发者ID:motlin,项目名称:cyg,代码行数:7,代码来源:journal.py


示例13: wrapdirstate

def wrapdirstate(orig, self):
    ds = orig(self)
    # only override the dirstate when Watchman is available for the repo
    if util.safehasattr(self, "_fsmonitorstate"):
        ds.__class__ = makedirstate(ds.__class__)
        ds._fsmonitorinit(self._fsmonitorstate, self._watchmanclient)
    return ds
开发者ID:cmjonze,项目名称:mercurial,代码行数:7,代码来源:__init__.py


示例14: strip

def strip(ui, repo, revs, update=True, backup=True, force=None, bookmarks=None):
    wlock = lock = None
    try:
        wlock = repo.wlock()
        lock = repo.lock()

        if update:
            checklocalchanges(repo, force=force)
            urev, p2 = repo.changelog.parents(revs[0])
            if (util.safehasattr(repo, 'mq') and
                p2 != nullid
                and p2 in [x.node for x in repo.mq.applied]):
                urev = p2
            hg.clean(repo, urev)
            repo.dirstate.write(repo.currenttransaction())

        repair.strip(ui, repo, revs, backup)

        repomarks = repo._bookmarks
        if bookmarks:
            with repo.transaction('strip') as tr:
                if repo._activebookmark in bookmarks:
                    bookmarksmod.deactivate(repo)
                for bookmark in bookmarks:
                    del repomarks[bookmark]
                repomarks.recordchange(tr)
            for bookmark in sorted(bookmarks):
                ui.write(_("bookmark '%s' deleted\n") % bookmark)
    finally:
        release(lock, wlock)
开发者ID:motlin,项目名称:cyg,代码行数:30,代码来源:strip.py


示例15: checkhghelps

def checkhghelps():
    errorcnt = 0
    for names, sec, doc in helptable:
        if util.safehasattr(doc, '__call__'):
            doc = doc()
        errorcnt += checkseclevel(doc,
                                  '%s help topic' % names[0],
                                  initlevel_topic)

    errorcnt += checkcmdtable(table, '%s command', initlevel_cmd)

    for name in sorted(extensions.enabled().keys() +
                       extensions.disabled().keys()):
        mod = extensions.load(None, name, None)
        if not mod.__doc__:
            verbose('skip checking %s extension: no help document' % name)
            continue
        errorcnt += checkseclevel(mod.__doc__,
                                  '%s extension' % name,
                                  initlevel_ext)

        cmdtable = getattr(mod, 'cmdtable', None)
        if cmdtable:
            errorcnt += checkcmdtable(cmdtable,
                                      '%s command of ' + name + ' extension',
                                      initlevel_ext_cmd)
    return errorcnt
开发者ID:chuchiperriman,项目名称:hg-stable,代码行数:27,代码来源:check-seclevel.py


示例16: _adjustlinkrev

 def _adjustlinkrev(orig, self, *args, **kwargs):
     # When generating file blobs, taking the real path is too slow on large
     # repos, so force it to just return the linkrev directly.
     repo = self._repo
     if util.safehasattr(repo, 'forcelinkrev') and repo.forcelinkrev:
         return self._filelog.linkrev(self._filelog.rev(self._filenode))
     return orig(self, *args, **kwargs)
开发者ID:davidshepherd7,项目名称:dotfiles,代码行数:7,代码来源:remotefilelogserver.py


示例17: log

        def log(self, event, *msg, **opts):
            """Redirect filtered log event to a sampling file
            The configuration looks like:
            [sampling]
            filepath = path/to/file
            key.eventname = value
            key.eventname2 = value2

            If an event name appears in the config, it is logged to the
            samplingfile augmented with value stored as ref.

            Example:
            [sampling]
            filepath = path/to/file
            key.perfstatus = perf_status

            Assuming that we call:
            ui.log('perfstatus', t=3)
            ui.log('perfcommit', t=3)
            ui.log('perfstatus', t=42)

            Then we will log in path/to/file, two JSON strings separated by \0
            one for each perfstatus, like:
            {"event":"perfstatus",
             "ref":"perf_status",
             "msg":"",
             "opts":{"t":3}}\0
            {"event":"perfstatus",
             "ref":"perf_status",
             "msg":"",
             "opts":{"t":42}}\0
            """
            if not util.safehasattr(self, 'samplingfilters'):
                self.samplingfilters = logtofile.computesamplingfilters(self)
            if event not in self.samplingfilters:
                return super(logtofile, self).log(event, *msg, **opts)

            # special case: remove less interesting blocked fields starting
            # with "unknown_" or "alias_".
            if event == 'uiblocked':
                opts = {k: v
                        for k, v in opts.items()
                        if (not k.startswith('alias_') and not
                            k.startswith('unknown_'))}

            ref = self.samplingfilters[event]
            script = _getcandidatelocation(ui)
            if script:
                try:
                    opts["metrics_type"] = event
                    if msg:
                        # ui.log treats msg as a format string + format args.
                        opts["msg"] = msg[0] % msg[1:]
                    with open(script, 'a') as outfile:
                        outfile.write(json.dumps({"data": opts,
                                                  "category": ref}))
                        outfile.write("\0")
                except EnvironmentError:
                    pass
            return super(logtofile, self).log(event, *msg, **opts)
开发者ID:davidshepherd7,项目名称:dotfiles,代码行数:60,代码来源:sampling.py


示例18: reposetup

def reposetup(ui, repo):
    if _fbsparseexists(repo.ui):
        return
    if not util.safehasattr(repo, 'dirstate'):
        return

    _wraprepo(ui, repo)
开发者ID:davidshepherd7,项目名称:dotfiles,代码行数:7,代码来源:sparse.py


示例19: reposetup

def reposetup(ui, repo):
    client = ui.configbool('fastannotate', 'client', default=None)
    if client is None:
        if util.safehasattr(repo, 'requirements'):
            client = 'remotefilelog' in repo.requirements
    if client:
        protocol.clientreposetup(ui, repo)
开发者ID:davidshepherd7,项目名称:dotfiles,代码行数:7,代码来源:__init__.py


示例20: strip

def strip(ui, repo, revs, update=True, backup=True, force=None, bookmark=None):
    wlock = lock = None
    try:
        wlock = repo.wlock()
        lock = repo.lock()

        if update:
            checklocalchanges(repo, force=force)
            urev, p2 = repo.changelog.parents(revs[0])
            if (util.safehasattr(repo, 'mq') and
                p2 != nullid
                and p2 in [x.node for x in repo.mq.applied]):
                urev = p2
            hg.clean(repo, urev)
            repo.dirstate.write()

        repair.strip(ui, repo, revs, backup)

        marks = repo._bookmarks
        if bookmark:
            if bookmark == repo._bookmarkcurrent:
                bookmarks.unsetcurrent(repo)
            del marks[bookmark]
            marks.write()
            ui.write(_("bookmark '%s' deleted\n") % bookmark)
    finally:
        release(lock, wlock)
开发者ID:areshero,项目名称:ThirdWorldApp,代码行数:27,代码来源:strip.py



注:本文中的mercurial.util.safehasattr函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python util.sha1函数代码示例发布时间:2022-05-27
下一篇:
Python util.rename函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap