开发者

Trouble resetting /tmp value to push mercurial changes

I have been using mercurial for about a year and haven't had any issues.

Today I ran into an issue for the first time.

When I try to push to the remote server with

$ hg push

I get the following response

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

I googled this issue and found that it is a documented issue, and I found the following excerpt from 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 p开发者_高级运维lenty 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.

I have created the hook in my /etc/mercurial/hgrc file that looks like this

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

and then I am supposed to create 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"

The problem I am having is that I don't know how to add this file to $PYTHONPATH in fedora

My operating system is Fedora 12 x86_64

I have python 2.6

I have mercurial 1.6.4

UPDATE:

I just added hgenviron.py to /usr/lib/python2.6/site-packages/hg/hgenviron.py and

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

to a .sh file in /etc/profile.d, along with the hook in /etc/mercurial/.

However I still get the error:

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


The problem is using the wrong import statement. It should be from hg import hgenviron

For setting PYTHONPATH Depends on how/where you want to add it.

In /etc/profile.d you can find a set of scripts that are ran when bash is loaded. /etc/profile is the global file, which calls the scripts and has this comment:

# 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 is ran when the bash environment is loaded. Locally to the user, you edit ~/.bash_profile or ~/.bashrc (if they doesn't exist, you can create them). These scripts are ran when the specific user logs in. You should examine these files in detail to understand how the environment is created and setup.

You would add something like this:

PYTHONPATH=/home/tmp:$PYTHONPATH
export PYTHONPATH


If you're struggling to get to the bottom of the PYTHONPATH issue, you can specifically state the location of the hgenviron.py file.

pre-serve.tmpdir = python:/var/hg/hgenviron.py:settmpdir

Note that settmpdir is then called with a : rather than . in the original example.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜