gpt4 book ai didi

python - 无法重置/tmp 值以推送 mercurial 更改

转载 作者:行者123 更新时间:2023-11-28 17:53:18 25 4
gpt4 key购买 nike

我已经使用 mercurial 大约一年了,没有遇到任何问题。

今天我第一次遇到问题。

当我尝试使用

推送到远程服务器时
$ hg push

我得到以下响应

searching for changes
remote: abort: No space left on device
abort: unexpected response: empty string

我用谷歌搜索了这个问题,发现这是一个记录在案的问题,我从 Mercurial FAQ 中找到了以下摘录:

4.28. I get a "no space left" or "disk quota exceeded" on push

I get a "no space left" or "disk quota exceeded" on push, but there is plenty of space or/and I have no quota limit on the device where the remote hg repository is.

The problem comes probably from the fact that mercurial uses /tmp (or one of the directory define by environment variables $TMPDIR, $TEMP or $TMP) to uncompress the bundle received on the wire. The decompression may then reach device limits.

You can of course set $TMPDIR to another location on remote in the default shell configuration file, but it will be potentially used by other processes than mercurial. Another solution is to set a hook in a global .hgrc on remote. See the description of how to set a hook for changing tmp directory on remote when pushing.

我在我的 /etc/mercurial/hgrc 文件中创建了钩子(Hook),看起来像这样

[hooks]
pre-serve.tmpdir = python:hgenviron.settmpdir

然后我应该创建 hgenviron.py

import os
#see http://docs.python.org/lib/module-tempfile.html
def settmpdir(ui, repo, hooktype, node=None, source=None, **kwargs):
os.environ["TMPDIR"] = "/home/tmp"

我遇到的问题是我不知道如何将这个文件添加到 fedora 中的 $PYTHONPATH

我的操作系统是 Fedora 12 x86_64
我有 python 2.6
我有 Mercurial 1.6.4

更新:

我刚刚将 hgenviron.py 添加到 /usr/lib/python2.6/site-packages/hg/hgenviron.py

PYTHONPATH=$PYTHONPATH:/usr/lib/python2.6/site-packages/hg/hgenviron.py
export PYTHONPATH

/etc/profile.d 中的 .sh 文件,以及 /etc/mercurial/ 中的钩子(Hook)。

但是我仍然得到错误:

remote: abort: pre-serve.tmpdir hook is invalid (import of "hgenviron" failed) abort: 
no suitable response from remote hg!

最佳答案

问题是使用了错误的导入语句。它应该是 from hg import hgenviron

用于设置 PYTHONPATH 取决于您要添加它的方式/位置。

/etc/profile.d 中,您可以找到一组在加载 bash 时运行的脚本。 /etc/profile 是全局文件,它调用脚本并有这样的注释:

# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc

# It's NOT good idea to change this file unless you know what you
# are doing. Much better way is to create custom.sh shell script in
# /etc/profile.d/ to make custom changes to environment. This will
# prevent need for merging in future updates.

/etc/profile 在加载 bash 环境时运行。在用户本地,您编辑 ~/.bash_profile~/.bashrc(如果它们不存在,您可以创建它们)。这些脚本在特定用户登录时运行。您应该详细检查这些文件以了解环境是如何创建和设置的。

你会添加这样的东西:

PYTHONPATH=/home/tmp:$PYTHONPATH
export PYTHONPATH

关于python - 无法重置/tmp 值以推送 mercurial 更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5767951/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com