Linux 试图让Mercurial在我的Raspberry Pi上成为一个远程存储库

Linux 试图让Mercurial在我的Raspberry Pi上成为一个远程存储库,linux,mercurial,raspberry-pi,Linux,Mercurial,Raspberry Pi,此问题的解决方案位于文章的底部,最后一块灰色背景。 我正试图让我的Raspberry Pi——它运行Debian的股票版本,作为Mercurial的远程存储库。我已经在我的台式机和笔记本电脑上建立了本地存储库(运行Mageia),它们在本地运行良好。我希望能够推拉对Pi的任何更改。我已经在Pi上设置了OpenVPN,这样我就可以访问它,并希望能从世界任何地方推拉我的软件 因此,我遵循: 一步一步(使用Apache2作为我的web服务器)以及当我尝试按照步骤9.1.2连接时: 通过将浏览器定向到主

此问题的解决方案位于文章的底部,最后一块灰色背景。

我正试图让我的Raspberry Pi——它运行Debian的股票版本,作为Mercurial的远程存储库。我已经在我的台式机和笔记本电脑上建立了本地存储库(运行Mageia),它们在本地运行良好。我希望能够推拉对Pi的任何更改。我已经在Pi上设置了OpenVPN,这样我就可以访问它,并希望能从世界任何地方推拉我的软件

因此,我遵循:

一步一步(使用Apache2作为我的web服务器)以及当我尝试按照步骤9.1.2连接时:

通过将浏览器定向到主机/hg/来检查它是否有效

通过将pi/hg放入Firefox,我得到了一个内部服务器错误。(只需将pi放入Firefox中,我就得到了默认的Apache消息,一切都很好。)

我的Apache错误日志显示:

Traceback (most recent call last):
  File "/var/hg/hgwebdir.cgi", line 18, in <module>
    application = hgweb(config)
  File "/usr/lib/python2.7/dist-packages/mercurial/hgweb/__init__.py", line 27, in hgweb
    return hgweb_mod.hgweb(config, name=name, baseui=baseui)
  File "/usr/lib/python2.7/dist-packages/mercurial/hgweb/hgweb_mod.py", line 34, in __init__
    self.repo = hg.repository(u, repo)
  File "/usr/lib/python2.7/dist-packages/mercurial/hg.py", line 93, in repository
    repo = _peerlookup(path).instance(ui, path, create)
  File "/usr/lib/python2.7/dist-packages/mercurial/localrepo.py", line 2350, in instance
    return localrepository(ui, util.urllocalpath(path), create)
  File "/usr/lib/python2.7/dist-packages/mercurial/localrepo.py", line 79, in __init__
    raise error.RepoError(_("repository %s not found") % path)
mercurial.error.RepoError: repository /var/hg/repos not found
[Wed Jan 22 17:23:26 2014] [error] [client 10.8.0.6] Premature end of script headers: hgwebdir.cgi
[command returned code 255 Wed Jan 22 17:25:15 2014]

% hg --repository /path/sqlforms outgoing --quiet --template {node}^M http://pi/hg/
HTTP Error: 500 (Internal Server Error)

[command returned code 255 Wed Jan 22 17:25:24 2014]
sqlforms% 
/var/hg/repos确实作为目录存在

希望我在那里提供了正确数量的信息。我不是Linux新手,但我是Apache的新手,对Mercurial也相当陌生,所以我可能在做一些愚蠢的事情。好吧,我已经忠实地复制了我上面显示的网站链接上的步骤。这些信息是否足以进行故障排除?如果没有,我可以根据需要提供其他任何东西。非常感谢



仅当目录是存储库时,将其指定为
config
。您将它指向一个似乎不是存储库的目录

也许您正试图从该目录中为多个存储库提供服务?在这种情况下,您需要将
config
设置为指向一个配置文件,然后可以在其中指定要包含的存储库


看一看,它应该描述了您需要的所有内容。

谢谢您对格式进行排序,Mata.)我取得了一点进步。现在,当我将Firefox指向pi/hg时,我可以看到我在客户端工作时看到的页面。因此,它提出了Mercurial Repositories标题、Mercurial徽标和名称描述Contact Last modified的标题。当然,没有列出存储库,这是我所期望的,因为我还没有创建任何存储库。现在,我很难记住我是否必须在Tortoise Hg中做任何事情才能在服务器上实际创建存储库,或者在我尝试从Tortoise Hg推导出更改时,将更改从本地计算机推送到服务器是否应该将其复制到服务器上,我得到的信息是:''似乎不是一个hg存储库:然后这个网站的HTML负载似乎不允许我发布,最后。[命令返回代码255 Thu Jan 23 09:18:58 2014]那么,我是否必须以某种方式在服务器上创建存储库?我必须说,我以为Ortoise Hg会帮我解决这个问题,但我可能完全错了。你需要在目录中创建一个存储库,或者使用
Hg init
,或者只是在那里复制存储库,然后它就会显示出来(前提是你在配置的路径部分有一个规则
/=/var/Hg/repos/*
)。要拉/推,您需要使用回购的url,如索引页面所示,可能类似于
https://pi/hg/repo_name
…我已经添加了如何使其工作的详细信息。我能让它允许我发布的唯一方法是使用CTL-K缩进它,然后作为代码。如果有人能修好它,请放心。助教。
[command returned code 255 Wed Jan 22 17:25:15 2014]

% hg --repository /path/sqlforms outgoing --quiet --template {node}^M http://pi/hg/
HTTP Error: 500 (Internal Server Error)

[command returned code 255 Wed Jan 22 17:25:24 2014]
sqlforms% 
It ended up being a number of different things - some of which Mata mentioned, so I'm putting his/her answer down as he/she was kind enough to point me in the right direction. I'm putting some more details below in case it helps someone else because in all documentation I've found some points aren't well made.

    It's important to note that the /var/hg directory that you specify ends up being accessed as server_name/hg when accessing via http. So, if you put a directory on your server in path:

    /var/hg/dex 

    Then this is accessed via http as:

    http://serve_name/hg/dex

    So, in this case the http access you are "mapping" /var/hg/dex as hg/dex

I think what is super-confusing about the documentation is the way hg is used too much and it would be better described if the base directory structure on your server is something like this:

    /var/mercurial_repositories

You would obviously have to set up the Apache config file to point there as its base directory rather than at:

    /var/hg. 

This would make it far more obvious that you are mapping /var/mercurial_repositories to hg when it comes to remote access. The way it is described it is far too ambiguous with hg being used in too many different places. Whereas this might be obvious to experienced users or someone who's had someone sit down and explain it to them, to a newb, it's very confusing. 

Then, the other thing that is not obvious in the documentation is that:

    /var/hg/repos 

is not a directory for ALL repositories. This is a directory for one repository. I struggled with this for quite some time. Again, the documentation is very misleading for a newb. If it said:

    /var/hg/repo (singular) it might be a lot better. 

I realise later, tucked away somewhere in one of the pages of documentation is mentions you need subdirectories within repos, but, again, it is very confusing for someone starting out the way this is worded. Something like:

    /var/mercurial/repositories_base_directory

Would be far clearer.

Also, for every directory you set up in your base directory, you have to have a new entry in the file:

    /var/hg/hgweb.config

This is done like this:

    [paths]
    c82xx = /var/hg/repos/c82xx

The documentation on this is especially terrible the way it just says:

    repos/ = repos/

The issue with these path settings, which, again is explained nowhere (as far as I could see), is that on the left hand side of the equals sign is how your remote machine accesses the directory where your repository is as a subdirectory of: 

    http:://server/hg

The right hand side is the absolute path on the server. It means you can type a relatively small path while remotely pushing and pulling. This instance:

    http:://server/hg/c82xx

Next up, as Mata pointed out, you need  to do hg init in the directory on the server, then from the local machine, push whatever you have already got to the server. So, in the directory with .hg on your local machine (in this case my c82xx project:

    hg push http:://server/hg/c82xx

There are two more vital thing to note though before you can do this:

1. You need to create, within the .hg directory on the SERVER a file called hgrc and put this in it:

[web]
push_ssl = false
allow_push = *

Now, from what I understand, you should ONLY do this on a trusted network. For me, I'm on a VPN or my LAN, so it's fine. 

2. That hgrc file AND all the repository directory and subdirectories have to have permissions to allow writing to these directories and folders. 

That should do it. Phew! 

I swear, version control is more complex than writing the software in the first place! :D