必须是 root 才能推送/提交到 Mercurial 存储库
我在工作站上使用 Ubuntu,每当我尝试提交/推送到位于 LAN 中 CIFS 共享上的 Mercurial 存储库时,都会抛出此错误:abort: 不允许操作: /media/repos/myRepo/ .hg/journal.dirstate
但是,在任何导致此问题的命令前添加 sudo 将使 Mercurial 继续运行,而不会向我抛出任何错误。
我应该怎么做才能不再需要 sudo
每次提交?
I am using Ubuntu on my workstation and whenever I try to commit/push to a Mercurial repository located on a CIFS share in my LAN, I get this error thrown: abort: Operation not permitted: /media/repos/myRepo/.hg/journal.dirstate
However, prepending any command that causes this with sudo
, will let mercurial continue without throwing any errors at me.
What should I do stop having to sudo
every commit?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的用户没有
/media/repos/myRepo
的写入权限。您可以使用ls -la
检查所有者和权限。根据结果,您应该:尝试使用 chmod 更改权限以允许您的用户或组进行访问。
(
ug+w
表示为组和所有者用户添加写入权限,如果您与所有者位于同一组中,这将起作用。否则,您可以尝试仅+w< /code> 将为所有用户添加它,但这不太安全。)
尝试使用
chown
将所有者更改为您的用户或组。(
myuser
和mygroup
都是可选的)另外请务必在整个存储库上递归使用
chown
和chmod
。如果每次都重新创建journal.dirstate
(我认为这就是发生的情况),它会从.hg
目录继承其权限,因此您对文件本身更改的任何权限可能会迷路。Your user doesn’t have write permissions for
/media/repos/myRepo
. You can check the owner and permissions usingls -la
. Depending on the result of that you should either:Try changing the permissions with
chmod
to allow access by your user or group.(
ug+w
means add write permissions for the group and the owner user, this will work if you’re in the same group as the owner. Otherwise, you could try just+w
which will add it for all users, but this is less secure.)Try changing the owner with
chown
to your user or group.(Both
myuser
andmygroup
are optional)Also be sure to use
chown
andchmod
recursively on the entire repository. Ifjournal.dirstate
is recreated every time (which I think is what happens), it inherits its permissions from the.hg
directory, so any permissions you change on the file itself may get lost.该问题可能与之前的 Mercurial 版本中的错误有关2.1.2 与失败的交易有关。
如果
hg Push
在操作中途失败,问题就会出现。例如,由于网络中断或服务器端的挂钩中止事务,可能会发生这种情况。这可能会导致过时的文件journal.dirstate
留在服务器端.hg
目录中。从此时起,除了
journal.dirstate
的所有者或 root 之外的任何用户都无法进行推送,无论journal.dirstate
上的文件权限如何。这是因为在推送期间,Mercurial 尝试向执行推送的用户chmod
文件,并给出您观察到的错误:不允许操作
。要解决此问题,您可以尝试以下任一方法:
让文件
journal.dirstate
的所有者执行成功推送。在此过程中应清理陈旧文件;或将 Mercurial 服务器版本更新至 2.1.2 或更高版本;或
删除服务器端的文件
journal.dirstate
。执行其中任何一项操作后,所有用户都应该能够再次推送。
The problem might be related to a bug in Mercurial versions prior to 2.1.2 related to a failed transaction.
The problem begins to crop up if a
hg push
fails midway through the operation. This might occur, for example, due to the network dropping out or a hook on the server-side aborting a transaction. This can lead to a stale filejournal.dirstate
being left inside the server-side.hg
directory.From this point on, no user other than the owner of
journal.dirstate
or root will be able to push, regardless of the file permissions onjournal.dirstate
. This is because during a push, Mercurial attempts tochmod
the file to the user performing the push, giving the error you observed:Operation not permitted
.To solve the problem, you can try either of the following:
Have the owner of the file
journal.dirstate
perform a successful push. The stale file should be cleaned up in the process; orUpdate the server version of Mercurial to version 2.1.2 or above; or
Delete the file
journal.dirstate
on the server-side.After carrying out any of these, all users should be able to push once more.