当前位置: 首页>>代码示例>>Python>>正文


Python lock.release函数代码示例

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


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

示例1: _deleteunreachable

def _deleteunreachable(repo, ctx):
    """Deletes all ancestor and descendant commits of the given revision that
    aren't reachable from another bookmark.
    """
    keepheads = "bookmark() + ."
    try:
        extensions.find('remotenames')
        keepheads += " + remotenames()"
    except KeyError:
        pass
    hiderevs = repo.revs('::%s - ::(%r)', ctx.rev(), keepheads)
    if hiderevs:
        lock = None
        try:
            lock = repo.lock()
            if _isobsstoreenabled(repo):
                markers = []
                for rev in hiderevs:
                    markers.append((repo[rev], ()))
                obsolete.createmarkers(repo, markers)
                repo.ui.status(_("%d changesets pruned\n") % len(hiderevs))
            else:
                repair.strip(repo.ui, repo,
                             [repo.changelog.node(r) for r in hiderevs])
        finally:
            lockmod.release(lock)
开发者ID:davidshepherd7,项目名称:dotfiles,代码行数:26,代码来源:reset.py

示例2: 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:
            tr = None
            try:
                tr = repo.transaction('strip')
                if repo._activebookmark in bookmarks:
                    bookmarksmod.deactivate(repo)
                for bookmark in bookmarks:
                    del repomarks[bookmark]
                repomarks.recordchange(tr)
                tr.close()
                for bookmark in sorted(bookmarks):
                    ui.write(_("bookmark '%s' deleted\n") % bookmark)
            finally:
                release(tr)
    finally:
        release(lock, wlock)
开发者ID:Distrotech,项目名称:mercurial,代码行数:35,代码来源:strip.py

示例3: apply

 def apply(self, repo, series, list=False, update_status=True,
           strict=False, patchdir=None, merge=None, all_files=None,
           tobackup=None, keepchanges=False):
     wlock = lock = tr = None
     try:
         wlock = repo.wlock()
         lock = repo.lock()
         tr = repo.transaction("qpush")
         try:
             ret = self._apply(repo, series, list, update_status,
                               strict, patchdir, merge, all_files=all_files,
                               tobackup=tobackup, keepchanges=keepchanges)
             tr.close()
             self.savedirty()
             return ret
         except AbortNoCleanup:
             tr.close()
             self.savedirty()
             return 2, repo.dirstate.p1()
         except: # re-raises
             try:
                 tr.abort()
             finally:
                 repo.invalidate()
                 repo.dirstate.invalidate()
                 self.invalidate()
             raise
     finally:
         release(tr, lock, wlock)
         self.removeundo(repo)
开发者ID:peiyaoyao,项目名称:intellij-community,代码行数:30,代码来源:mq.py

示例4: histedit

def histedit(ui, repo, *freeargs, **opts):
    """interactively edit changeset history

    This command edits changesets between ANCESTOR and the parent of
    the working directory.

    With --outgoing, this edits changesets not found in the
    destination repository. If URL of the destination is omitted, the
    'default-push' (or 'default') path will be used.

    For safety, this command is aborted, also if there are ambiguous
    outgoing revisions which may confuse users: for example, there are
    multiple branches containing outgoing revisions.

    Use "min(outgoing() and ::.)" or similar revset specification
    instead of --outgoing to specify edit target revision exactly in
    such ambiguous situation. See :hg:`help revsets` for detail about
    selecting revisions.

    Returns 0 on success, 1 if user intervention is required (not only
    for intentional "edit" command, but also for resolving unexpected
    conflicts).
    """
    state = histeditstate(repo)
    try:
        state.wlock = repo.wlock()
        state.lock = repo.lock()
        _histedit(ui, repo, state, *freeargs, **opts)
    finally:
        release(state.lock, state.wlock)
开发者ID:RayFerr000,项目名称:PLTL,代码行数:30,代码来源:histedit.py

示例5: _inhibitmarkers

def _inhibitmarkers(repo, nodes):
    """add marker inhibitor for all obsolete revision under <nodes>

    Content of <nodes> and all mutable ancestors are considered. Marker for
    obsolete revision only are created.
    """
    if not _inhibitenabled(repo):
        return

    # we add (non public()) as a lower boundary to
    # - use the C code in 3.6 (no ancestors in C as this is written)
    # - restrict the search space. Otherwise, the ancestors can spend a lot of
    #   time iterating if you have a check very low in the repo. We do not need
    #   to iterate over tens of thousand of public revisions with higher
    #   revision number
    #
    # In addition, the revset logic could be made significantly smarter here.
    newinhibit = repo.revs('(not public())::%ln and obsolete()', nodes)
    if newinhibit:
        node = repo.changelog.node
        lock = tr = None
        try:
            lock = repo.lock()
            tr = repo.transaction('obsinhibit')
            repo._obsinhibit.update(node(r) for r in newinhibit)
            _schedulewrite(tr, _filterpublic(repo, repo._obsinhibit))
            repo.invalidatevolatilesets()
            tr.close()
        finally:
            lockmod.release(tr, lock)
开发者ID:dan-passaro,项目名称:hgrc,代码行数:30,代码来源:inhibit.py

示例6: concludenode

def concludenode(repo, rev, p1, p2, commitmsg=None, editor=None, extrafn=None,
                 keepbranches=False):
    '''Commit the wd changes with parents p1 and p2. Reuse commit info from rev
    but also store useful information in extra.
    Return node of committed revision.'''
    dsguard = cmdutil.dirstateguard(repo, 'rebase')
    try:
        repo.setparents(repo[p1].node(), repo[p2].node())
        ctx = repo[rev]
        if commitmsg is None:
            commitmsg = ctx.description()
        keepbranch = keepbranches and repo[p1].branch() != ctx.branch()
        extra = {'rebase_source': ctx.hex()}
        if extrafn:
            extrafn(ctx, extra)

        backup = repo.ui.backupconfig('phases', 'new-commit')
        try:
            targetphase = max(ctx.phase(), phases.draft)
            repo.ui.setconfig('phases', 'new-commit', targetphase, 'rebase')
            if keepbranch:
                repo.ui.setconfig('ui', 'allowemptycommit', True)
            # Commit might fail if unresolved files exist
            newnode = repo.commit(text=commitmsg, user=ctx.user(),
                                  date=ctx.date(), extra=extra, editor=editor)
        finally:
            repo.ui.restoreconfig(backup)

        repo.dirstate.setbranch(repo[newnode].branch())
        dsguard.close()
        return newnode
    finally:
        release(dsguard)
开发者ID:CSCI-362-02-2015,项目名称:RedTeam,代码行数:33,代码来源:rebase.py

示例7: run

        def run(self):
            state = self.state
            repo, ctxnode = state.repo, state.parentctxnode
            hg.update(repo, ctxnode)

            # release locks so the program can call hg and then relock.
            lock.release(state.lock, state.wlock)

            try:
                ctx = repo[ctxnode]
                shell = encoding.environ.get('SHELL', None)
                cmd = self.command
                if shell and self.repo.ui.config('fbhistedit',
                                                 'exec_in_user_shell'):
                    cmd = "%s -c -i %s" % (shell, quote(cmd))
                rc = repo.ui.system(cmd,  environ={'HGNODE': ctx.hex()},
                                    cwd=self.cwd, blockedtag='histedit_exec')
            except OSError as ose:
                raise error.InterventionRequired(
                    _("Cannot execute command '%s': %s") % (self.command, ose))
            finally:
                # relock the repository
                state.wlock = repo.wlock()
                state.lock = repo.lock()
                repo.invalidateall()

            if rc != 0:
                raise error.InterventionRequired(
                    _("Command '%s' failed with exit status %d") %
                    (self.command, rc))

            m, a, r, d = self.repo.status()[:4]
            if m or a or r or d:
                self.continuedirty()
            return self.continueclean()
开发者ID:davidshepherd7,项目名称:dotfiles,代码行数:35,代码来源:fbhistedit.py

示例8: kwcommitctx

        def kwcommitctx(self, ctx, error=False):
            wlock = lock = None
            try:
                wlock = self.wlock()
                lock = self.lock()
                # store and postpone commit hooks
                commithooks = {}
                for name, cmd in ui.configitems('hooks'):
                    if name.split('.', 1)[0] == 'commit':
                        commithooks[name] = cmd
                        ui.setconfig('hooks', name, None)
                if commithooks:
                    # store parents for commit hooks
                    p1, p2 = ctx.p1(), ctx.p2()
                    xp1, xp2 = p1.hex(), p2 and p2.hex() or ''

                n = super(kwrepo, self).commitctx(ctx, error)

                kwt.overwrite(n, True, None)
                if commithooks:
                    for name, cmd in commithooks.iteritems():
                        ui.setconfig('hooks', name, cmd)
                    self.hook('commit', node=n, parent1=xp1, parent2=xp2)
                return n
            finally:
                release(lock, wlock)
开发者ID:iluxa-c0m,项目名称:mercurial-crew-tonfa,代码行数:26,代码来源:keyword.py

示例9: concludenode

def concludenode(repo, rev, p1, p2, commitmsg=None, editor=None, extrafn=None):
    """Commit the wd changes with parents p1 and p2. Reuse commit info from rev
    but also store useful information in extra.
    Return node of committed revision."""
    dsguard = cmdutil.dirstateguard(repo, "rebase")
    try:
        repo.setparents(repo[p1].node(), repo[p2].node())
        ctx = repo[rev]
        if commitmsg is None:
            commitmsg = ctx.description()
        extra = {"rebase_source": ctx.hex()}
        if extrafn:
            extrafn(ctx, extra)

        backup = repo.ui.backupconfig("phases", "new-commit")
        try:
            targetphase = max(ctx.phase(), phases.draft)
            repo.ui.setconfig("phases", "new-commit", targetphase, "rebase")
            # Commit might fail if unresolved files exist
            newnode = repo.commit(text=commitmsg, user=ctx.user(), date=ctx.date(), extra=extra, editor=editor)
        finally:
            repo.ui.restoreconfig(backup)

        repo.dirstate.setbranch(repo[newnode].branch())
        dsguard.close()
        return newnode
    finally:
        release(dsguard)
开发者ID:pierfort123,项目名称:mercurial,代码行数:28,代码来源:rebase.py

示例10: unshelveabort

def unshelveabort(ui, repo, state, opts):
    """subcommand that abort an in-progress unshelve"""
    wlock = repo.wlock()
    lock = None
    try:
        checkparents(repo, state)

        util.rename(repo.join('unshelverebasestate'),
                    repo.join('rebasestate'))
        try:
            rebase.rebase(ui, repo, **{
                'abort' : True
            })
        except Exception:
            util.rename(repo.join('rebasestate'),
                        repo.join('unshelverebasestate'))
            raise

        lock = repo.lock()

        mergefiles(ui, repo, state.wctx, state.pendingctx)

        repair.strip(ui, repo, state.stripnodes, backup='none', topic='shelve')
        shelvedstate.clear(repo)
        ui.warn(_("unshelve of '%s' aborted\n") % state.name)
    finally:
        lockmod.release(lock, wlock)
开发者ID:roopakparikh,项目名称:crane-node-hello,代码行数:27,代码来源:shelve.py

示例11: cleanupnode

def cleanupnode(ui, repo, name, nodes):
    """strip a group of nodes from the repository

    The set of node to strip may contains unknown nodes."""
    ui.debug('should strip %s nodes %s\n' %
             (name, ', '.join([node.short(n) for n in nodes])))
    lock = None
    try:
        lock = repo.lock()
        # do not let filtering get in the way of the cleanse
        # we should probably get rid of obsolescence marker created during the
        # histedit, but we currently do not have such information.
        repo = repo.unfiltered()
        # Find all nodes that need to be stripped
        # (we use %lr instead of %ln to silently ignore unknown items)
        nm = repo.changelog.nodemap
        nodes = sorted(n for n in nodes if n in nm)
        roots = [c.node() for c in repo.set("roots(%ln)", nodes)]
        for c in roots:
            # We should process node in reverse order to strip tip most first.
            # but this trigger a bug in changegroup hook.
            # This would reduce bundle overhead
            repair.strip(ui, repo, c)
    finally:
        release(lock)
开发者ID:CSCI-362-02-2015,项目名称:RedTeam,代码行数:25,代码来源:histedit.py

示例12: unshelveabort

def unshelveabort(ui, repo, state, opts):
    """subcommand that abort an in-progress unshelve"""
    wlock = repo.wlock()
    lock = None
    try:
        checkparents(repo, state)
        lock = repo.lock()
        merge.mergestate(repo).reset()
        if opts['keep']:
            repo.setparents(repo.dirstate.parents()[0])
        else:
            revertfiles = readshelvedfiles(repo, state.name)
            wctx = repo.parents()[0]
            cmdutil.revert(ui, repo, wctx, [wctx.node(), nullid],
                           *revertfiles, **{'no_backup': True})
            # fix up the weird dirstate states the merge left behind
            mf = wctx.manifest()
            dirstate = repo.dirstate
            for f in revertfiles:
                if f in mf:
                    dirstate.normallookup(f)
                else:
                    dirstate.drop(f)
            dirstate._pl = (wctx.node(), nullid)
            dirstate._dirty = True
        repair.strip(ui, repo, state.stripnodes, backup='none', topic='shelve')
        shelvedstate.clear(repo)
        ui.warn(_("unshelve of '%s' aborted\n") % state.name)
    finally:
        lockmod.release(lock, wlock)
开发者ID:jordigh,项目名称:mercurial-crew,代码行数:30,代码来源:shelve.py

示例13: 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

示例14: testlock

 def testlock(self):
     state = teststate(self, tempfile.mkdtemp(dir=os.getcwd()))
     lock = state.makelock()
     state.assertacquirecalled(True)
     lock.release()
     state.assertreleasecalled(True)
     state.assertpostreleasecalled(True)
     state.assertlockexists(False)
开发者ID:CSCI-362-02-2015,项目名称:RedTeam,代码行数:8,代码来源:test-lock.py

示例15: createcmd

def createcmd(ui, repo, pats, opts):
    """subcommand that creates a new shelve"""
    wlock = repo.wlock()
    try:
        cmdutil.checkunfinished(repo)
        return _docreatecmd(ui, repo, pats, opts)
    finally:
        lockmod.release(wlock)
开发者ID:Distrotech,项目名称:mercurial,代码行数:8,代码来源:shelve.py


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