可以使Mercurial保留文件权限吗? [英] Can Mercurial be made to preserve file permissions?
问题描述
我看过许多博客文章,并亲身体验到Mercurial不会保留从一个存储库推送到另一个存储库的文件的权限.有谁知道可以保留权限的Mercurial扩展?我假设它不能用钩子完成,因为钩子对原始存储库中的权限了解什么?
I've seen a number of blog posts, and have experienced for myself, that Mercurial does not preserve the permissions on files pushed from one repo to another. Does anyone know of a Mercurial extension that would preserve the permissions? I'm assuming it can't be done with a hook, because what does a hook know about permissions at the originating repo?
要求的详细说明:
-
如果对文件的唯一更改是权限的更改(例如,
chmod o+r filename
),则尝试提交文件失败,并显示一条消息,指出文件未更改.
If the only change to a file is a change in permissions (e.g.,
chmod o+r filename
), attempts to commit the file fail with a message saying that the file has not changed.
如果我提交具有权限600(rw -------)的文件,然后克隆该存储库,则克隆中的同一文件具有权限664(rw-rw-r-):
If I commit a file with permissions 600 (rw-------), then clone the repo, the same file in the clone has permissions 664 (rw-rw-r--):
: nr@yorkie 6522 ; hg clone one two
updating working directory
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
: nr@yorkie 6523 ; ls -l one two
one:
total 4
-rw------- 1 nr nr 8 Aug 18 21:50 foo
two:
total 4
-rw-rw-r-- 1 nr nr 8 Aug 18 21:51 foo
此示例显示hg clone
不会保留权限,但hg push
也不也会保留权限.
This examples shows that hg clone
does not preserve permissions, but hg push
does not preserve them either.
在我的应用程序中,一个回购在一条可公开访问的路径上,这是最重要的
In my application, one repo is on a publically accessible path, and it's of major importance that
-
多个用户有权更改存储库
Multiple users have the right to change the repo
仅在显式可读的情况下,公共仓库中的文件才可读.
Files in the public repo become readable only when explicitly made readable.
推荐答案
看起来可以使用钩子和辅助工具(还有一点口香糖和打包线)来完成:
It looks like it can be done using hooks and an auxiliary tool (and a little chewing gum and baling wire):
-
获取David Hardeman的 Metastore ,该文件可以保存和恢复文件元数据.
Get David Hardeman's Metastore, which saves and restores file metadata.
更改源,因此它将忽略目录.hg
和.git
.
Alter the sources so it will ignore directory .hg
as well as .git
.
使用以下Mercurial挂钩:
Use the following Mercurial hooks:
precommit.meta = metastore -s
changegroup.update = hg update
update.meta = /usr/unsup/nr/bin/metastore -a
您必须将.metadata
文件添加到存储库中.
You have to add the .metadata
file to the repo.
此修改通常在大多数时间都有效,但是如果您仅更改 权限并希望传播该权限,则必须运行metastore -s
才能将这些更改推送到.metadata中. hg将看到更改的文件;否则,提交者认为没有新内容.
This lashup will work most of the time, but if you change only permissions and want to propagate it, you'll have to run metastore -s
in order to push those changes into the .metadata file where hg will see the change; otherwise the commit thinks nothing is new.
这篇关于可以使Mercurial保留文件权限吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!