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


Python util.rename函数代码示例

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


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

示例1: setwithlimit

 def setwithlimit(self, hexnode, manifest, limit=-1):
     """Writes a manifest to the cache.  Returns True if the cache already
     contains the item or if the write is successful.  Returns False if the
     write fails.  Raises CacheFullException if writing the cache entry would
     cause us to pass the limit.
     """
     if hexnode in self:
         return True
     path = self._pathfromnode(hexnode)
     if (isinstance(manifest, cfastmanifest.fastmanifest) or
         isinstance(manifest, fastmanifestdict)):
         fm = manifest
     else:
         fm = cfastmanifest.fastmanifest(manifest.text())
     tmpfpath = util.mktempcopy(path, True)
     entrysize = fm.bytes()
     if limit != -1 and self.totalsize()[0] + entrysize > limit:
         raise CacheFullException()
     try:
         fm._save(tmpfpath)
         util.rename(tmpfpath, path)
         return True
     except EnvironmentError:
         return False
     finally:
         try:
             os.unlink(tmpfpath)
         except OSError:
             pass
开发者ID:davidshepherd7,项目名称:dotfiles,代码行数:29,代码来源:implementation.py

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

示例3: unshare

def unshare(ui, repo):
    """convert a shared repository to a normal one

    Copy the store data to the repo and remove the sharedpath data.
    """

    if not repo.shared():
        raise error.Abort(_("this is not a shared repo"))

    destlock = lock = None
    lock = repo.lock()
    try:
        # we use locks here because if we race with commit, we
        # can end up with extra data in the cloned revlogs that's
        # not pointed to by changesets, thus causing verify to
        # fail

        destlock = hg.copystore(ui, repo, repo.path)

        sharefile = repo.join('sharedpath')
        util.rename(sharefile, sharefile + '.old')

        repo.requirements.discard('sharedpath')
        repo._writerequirements()
    finally:
        destlock and destlock.release()
        lock and lock.release()

    # update store, spath, svfs and sjoin of repo
    repo.unfiltered().__init__(repo.baseui, repo.root)
开发者ID:Distrotech,项目名称:mercurial,代码行数:30,代码来源:share.py

示例4: _gethash

    def _gethash(self, filename, hash):
        """Get file with the provided hash and store it in the local repo's
        store and in the usercache.
        filename is for informational messages only.
        """
        util.makedirs(lfutil.storepath(self.repo, ''))
        storefilename = lfutil.storepath(self.repo, hash)

        tmpname = storefilename + '.tmp'
        tmpfile = util.atomictempfile(
            tmpname, createmode=self.repo.store.createmode)

        try:
            gothash = self._getfile(tmpfile, filename, hash)
        except StoreError as err:
            self.ui.warn(err.longmessage())
            gothash = ""
        tmpfile.close()

        if gothash != hash:
            if gothash != "":
                self.ui.warn(
                    _('%s: data corruption (expected %s, got %s)\n') %
                    (filename, hash, gothash))
            util.unlink(tmpname)
            return False

        util.rename(tmpname, storefilename)
        lfutil.linktousercache(self.repo, hash)
        return True
开发者ID:html-shell,项目名称:mozilla-build,代码行数:30,代码来源:basestore.py

示例5: rollback

 def rollback(self, dryrun=False):
     if os.path.exists(self.join('undo.bookmarks')):
         if not dryrun:
             util.rename(self.join('undo.bookmarks'), self.join('bookmarks'))
         elif not os.path.exists(self.sjoin("undo")):
             # avoid "no rollback information available" message
             return 0
     return super(bookmark_repo, self).rollback(dryrun)
开发者ID:helloandre,项目名称:cr48,代码行数:8,代码来源:bookmarks.py

示例6: _bind

 def _bind(self, sock):
     # use a unique temp address so we can stat the file and do ownership
     # check later
     tempaddress = _tempaddress(self._realaddress)
     util.bindunixsocket(sock, tempaddress)
     self._socketstat = os.stat(tempaddress)
     # rename will replace the old socket file if exists atomically. the
     # old server will detect ownership change and exit.
     util.rename(tempaddress, self._realaddress)
开发者ID:motlin,项目名称:cyg,代码行数:9,代码来源:chgserver.py

示例7: backup

 def backup(self, repo, files, copy=False):
     # backup local changes in --force case
     for f in sorted(files):
         absf = repo.wjoin(f)
         if os.path.lexists(absf):
             self.ui.note(_('saving current version of %s as %s\n') %
                          (f, f + '.orig'))
             if copy:
                 util.copyfile(absf, absf + '.orig')
             else:
                 util.rename(absf, absf + '.orig')
开发者ID:peiyaoyao,项目名称:intellij-community,代码行数:11,代码来源:mq.py

示例8: get

    def get(self, files):
        '''Get the specified largefiles from the store and write to local
        files under repo.root.  files is a list of (filename, hash)
        tuples.  Return (success, missing), lists of files successfully
        downloaded and those not found in the store.  success is a list
        of (filename, hash) tuples; missing is a list of filenames that
        we could not get.  (The detailed error message will already have
        been presented to the user, so missing is just supplied as a
        summary.)'''
        success = []
        missing = []
        ui = self.ui

        util.makedirs(lfutil.storepath(self.repo, ''))

        at = 0
        available = self.exists(set(hash for (_filename, hash) in files))
        for filename, hash in files:
            ui.progress(_('getting largefiles'), at, unit='lfile',
                total=len(files))
            at += 1
            ui.note(_('getting %s:%s\n') % (filename, hash))

            if not available.get(hash):
                ui.warn(_('%s: largefile %s not available from %s\n')
                        % (filename, hash, self.url))
                missing.append(filename)
                continue

            storefilename = lfutil.storepath(self.repo, hash)
            tmpfile = util.atomictempfile(storefilename + '.tmp',
                                          createmode=self.repo.store.createmode)

            try:
                hhash = self._getfile(tmpfile, filename, hash)
            except StoreError, err:
                ui.warn(err.longmessage())
                hhash = ""
            tmpfile.close()

            if hhash != hash:
                if hhash != "":
                    ui.warn(_('%s: data corruption (expected %s, got %s)\n')
                            % (filename, hash, hhash))
                util.unlink(storefilename + '.tmp')
                missing.append(filename)
                continue

            util.rename(storefilename + '.tmp', storefilename)
            lfutil.linktousercache(self.repo, hash)
            success.append((filename, hhash))
开发者ID:32bitfloat,项目名称:intellij-community,代码行数:51,代码来源:basestore.py

示例9: pickle_atomic

def pickle_atomic(data, file_path, dir=None):
    """pickle some data to a path atomically.

    This is present because I kept corrupting my revmap by managing to hit ^C
    during the pickle of that file.
    """
    try:
        f, path = tempfile.mkstemp(prefix='pickling', dir=dir)
        f = os.fdopen(f, 'w')
        pickle.dump(data, f)
        f.close()
    except: #pragma: no cover
        raise
    else:
        hgutil.rename(path, file_path)
开发者ID:chaptastic,项目名称:config_files,代码行数:15,代码来源:svnmeta.py

示例10: mergefiles

def mergefiles(ui, repo, wctx, shelvectx):
    """updates to wctx and merges the changes from shelvectx into the
    dirstate."""
    with ui.configoverride({('ui', 'quiet'): True}):
        hg.update(repo, wctx.node())
        files = []
        files.extend(shelvectx.files())
        files.extend(shelvectx.parents()[0].files())

        # revert will overwrite unknown files, so move them out of the way
        for file in repo.status(unknown=True).unknown:
            if file in files:
                util.rename(file, scmutil.origpath(ui, repo, file))
        ui.pushbuffer(True)
        cmdutil.revert(ui, repo, shelvectx, repo.dirstate.parents(),
                       *pathtofiles(repo, files),
                       **{'no_backup': True})
        ui.popbuffer()
开发者ID:davidshepherd7,项目名称:dotfiles,代码行数:18,代码来源:obsshelve.py

示例11: unshelvecontinue

def unshelvecontinue(ui, repo, state, opts):
    """subcommand to continue an in-progress unshelve"""
    # We're finishing off a merge. First parent is our original
    # parent, second is the temporary "fake" commit we're unshelving.
    wlock = repo.wlock()
    lock = None
    try:
        checkparents(repo, state)
        ms = merge.mergestate(repo)
        if [f for f in ms if ms[f] == 'u']:
            raise error.Abort(
                _("unresolved conflicts, can't continue"),
                hint=_("see 'hg resolve', then 'hg unshelve --continue'"))

        lock = repo.lock()

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

        shelvectx = repo['tip']
        if not shelvectx in state.pendingctx.children():
            # rebase was a no-op, so it produced no child commit
            shelvectx = state.pendingctx
        else:
            # only strip the shelvectx if the rebase produced it
            state.stripnodes.append(shelvectx.node())

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

        repair.strip(ui, repo, state.stripnodes, backup=False, topic='shelve')
        shelvedstate.clear(repo)
        unshelvecleanup(ui, repo, state.name, opts)
        ui.status(_("unshelve of '%s' complete\n") % state.name)
    finally:
        lockmod.release(lock, wlock)
开发者ID:html-shell,项目名称:mozilla-build,代码行数:43,代码来源:shelve.py

示例12: server_bind

 def server_bind(self):
     # use a unique temp address so we can stat the file and do ownership
     # check later
     tempaddress = _tempaddress(self.server_address)
     # use relative path instead of full path at bind() if possible, since
     # AF_UNIX path has very small length limit (107 chars) on common
     # platforms (see sys/un.h)
     dirname, basename = os.path.split(tempaddress)
     bakwdfd = None
     if dirname:
         bakwdfd = os.open('.', os.O_DIRECTORY)
         os.chdir(dirname)
     self.socket.bind(basename)
     self._socketstat = os.stat(basename)
     # rename will replace the old socket file if exists atomically. the
     # old server will detect ownership change and exit.
     util.rename(basename, self.server_address)
     if bakwdfd:
         os.fchdir(bakwdfd)
         os.close(bakwdfd)
开发者ID:cmjonze,项目名称:mercurial,代码行数:20,代码来源:chgserver.py

示例13: stripmarker

def stripmarker(ui, repo, markers):
    """remove <markers> from the repo obsstore

    The old obsstore content is saved in a `obsstore.prestrip` file
    """
    repo = repo.unfiltered()
    repo.destroying()
    oldmarkers = list(repo.obsstore._all)
    util.rename(repo.sjoin('obsstore'),
                repo.join('obsstore.prestrip'))
    del repo.obsstore # drop the cache
    newstore = repo.obsstore
    assert not newstore # should be empty after rename
    newmarkers = [m for m in oldmarkers if m not in markers]
    tr = repo.transaction('drophack')
    try:
        newstore.add(tr, newmarkers)
        tr.close()
    finally:
        tr.release()
    repo.destroyed()
开发者ID:dan-passaro,项目名称:hgrc,代码行数:21,代码来源:drophack.py

示例14: mergefiles

def mergefiles(ui, repo, wctx, shelvectx):
    """updates to wctx and merges the changes from shelvectx into the
    dirstate."""
    oldquiet = ui.quiet
    try:
        ui.quiet = True
        hg.update(repo, wctx.node())
        files = []
        files.extend(shelvectx.files())
        files.extend(shelvectx.parents()[0].files())

        # revert will overwrite unknown files, so move them out of the way
        m, a, r, d, u = repo.status(unknown=True)[:5]
        for file in u:
            if file in files:
                util.rename(file, file + ".orig")
        cmdutil.revert(ui, repo, shelvectx, repo.dirstate.parents(),
                       *pathtofiles(repo, files),
                       **{'no_backup': True})
    finally:
        ui.quiet = oldquiet
开发者ID:roopakparikh,项目名称:crane-node-hello,代码行数:21,代码来源:shelve.py

示例15: unsharejournal

def unsharejournal(orig, ui, repo, repopath):
    """Copy shared journal entries into this repo when unsharing"""
    if (repo.path == repopath and repo.shared() and
            util.safehasattr(repo, 'journal')):
        sharedrepo = share._getsrcrepo(repo)
        sharedfeatures = _readsharedfeatures(repo)
        if sharedrepo and sharedfeatures > set(['journal']):
            # there is a shared repository and there are shared journal entries
            # to copy. move shared date over from source to destination but
            # move the local file first
            if repo.vfs.exists('namejournal'):
                journalpath = repo.join('namejournal')
                util.rename(journalpath, journalpath + '.bak')
            storage = repo.journal
            local = storage._open(
                repo.vfs, filename='namejournal.bak', _newestfirst=False)
            shared = (
                e for e in storage._open(sharedrepo.vfs, _newestfirst=False)
                if sharednamespaces.get(e.namespace) in sharedfeatures)
            for entry in _mergeentriesiter(local, shared, order=min):
                storage._write(repo.vfs, entry)

    return orig(ui, repo, repopath)
开发者ID:motlin,项目名称:cyg,代码行数:23,代码来源:journal.py


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