Windows 目录权限:Mercurial - hg merge - “中止:访问被拒绝”
背景:这是在 Windows 2008 Server 上运行的。
https://www.mercurial-scm.org/wiki/Workflows#Feature_separation_through_named_branches
我是 Mercurial 新手,我正在尝试遵循上面的建议,其中提到“将默认值合并到您的功能中”尽可能频繁地”——今天之前我已经对其他文件做过几次这样的操作。
但是,这个最新的更改不会合并。
当我执行“hg merge default”时,出现错误“中止:访问被拒绝”。经过谷歌搜索后,我发现有些人报告相关文件实际上存在权限问题。有关文件的权限没有什么特别的,至少我看不到。我是一名受过培训的 Linux 人员,而不是 Windows 人员,所以从根本上我并不真正了解 Windows 文件权限。 Cygwin 声称有问题的文件是 644(即我可以写入该文件),这与过去 hg 合并过程成功触及的所有其他文件具有相同的权限集。
我查看了 DOS 的“attrib”命令,它也没有在相关文件旁边显示“只读”标志。
如果这不是 Mercurial 问题而是 Windows 权限问题,我也很乐意进一步修改标签。
我假设这个“中止:访问被拒绝”错误指的是变更集中需要合并的文件,而不是 .hg/ 文件之一,但这是一个非常神秘的错误消息 - 它没有不要说哪个文件存在访问问题(并且变更集中只有一个文件发生了更改——我故意尝试让这个测试变得非常简单)。
更新:
进行了“hg回滚”并以相同的顺序尝试了相同的命令测试,使文件保持打开状态,只是使用了完全不同的文件(lib/blort.html而不是blah/foo.html)。 html)。
“hg merge”效果很好。
因此,我开始使用的特定文件(foo.html)或其父目录的权限可能有一些特别的问题。
另一个编辑
父目录肯定有问题,因为我在目录中的另一个文件中遇到了同样的问题,但问题并没有出现在目录结构的其他地方,只出现在这个目录中。
刚刚检查了 lib/ 与 blah/ 的权限,它们在 Cygwin 中看起来是相同的,但这只是 Windows ACL 的模糊近似。当通过右键单击每个目录并检查“属性”安全选项卡来检查这些内容时,两个目录的它们似乎再次相同,但我认为问题的关键在于我真的不太了解 ACL。
是否有一些 DOS 命令行工具,例如“attrib”,只是功能更强大,就像 Linux 中的“ls”一样,可以为我提供比“属性”中混乱的复选标记更多的信息?
希望最终编辑
'iCacls ' 似乎是这项工作的正确工具,并且似乎已经解决了问题,但我想在接受/关闭之前复制此内容。
摘要
如有疑问,请在 Mercurial 命令上使用
--debug
。现在这有点“废话”,但感谢@lazy-badger 指出了这一点。您可以使用
icacls path /grant domain\user:(OI)(CI)F
之类的命令修复 Server 2008 权限(请参见 http://www.petri.co.il/forums/showthread.php?t=23207),但请务必从升级的 CMD 窗口(“以管理员身份运行”)执行此操作。对于 Windows 用户来说,这又是“duh”,而对于 Linux 用户来说则不是那么明显(相反,我在谷歌上搜索了一些相当于sudo
的 DOS)。
Background: this is running on a Windows 2008 Server.
https://www.mercurial-scm.org/wiki/Workflows#Feature_separation_through_named_branches
I'm a Mercurial newbie, and am trying to follow the advice above where it says to "Merge default into your feature as often as possible" -- and I've done this a couple of times previously today, already, with other files.
However, this newest change just won't merge.
When I do the 'hg merge default' I get the error "abort: Access is denied". After googling around, I see that some people reported actually having permissions problems on the files in question. There's nothing special about the permissions on the file in question, at least not that I can see. I'm a Linux person by training, not a Windows person, so fundamentally I don't really understand Windows file permissions. Cygwin claims that the file in question is 644 (i.e., I can write to the file), which is the same set of permissions as every other file that has previously been successfully touched by the hg merge process in the past.
I took a look at the DOS 'attrib' command and it doesn't show a 'read-only' flag next the file in question, either.
If this is less a Mercurial question than it is a Windows permissions question, I'm happy to modify the tags further as well.
I'm assuming that this "abort: Access is denied" error refers to the file in the changeset that needs to be merged, and not to one of the .hg/ files, but it's a very cryptic error message -- it doesn't say which file has an access issue (and there is only one single file in the changeset that was changed -- I purposely tried to be VERY simple with this test).
UPDATE:
Did an 'hg rollback' and tried the same test of commands in the same order, leaving the files open, only with a completely different file (lib/blort.html instead of blah/foo.html).
The 'hg merge' worked just fine.
So there's probably something particularly hinky about the permissions on the specific file I started with (foo.html), or the directory that is its parent.
Another Edit
Definitely something off about the parent directory, as I had the same problem w/ another file in the directory, but the problem does not manifest elsewhere in the directory structure, only in this one directory.
Just checked the permissions on lib/ versus blah/ and they both seem the same in Cygwin, but that's only a vague approximation of the Windows ACLs. When examining those by right-clicking each directory and examining the 'Properties' Security tabs, they again seem the same for both directories, but I think the crux of the problem is that I really don't quite grok ACLs.
Is there some DOS command-line tool, like 'attrib' only more powerful, that, like 'ls' in linux, would give me more information than the confusing jumble of checkmarks I get in the 'Properties'?
Hopefully the final edit
How to diff Windows permissions
'iCacls' seems to be the correct tool for the job, and seems to have solved the problem, but I'd like to duplicate this before accepting/closing.
SUMMARY
When in doubt, use
--debug
on your Mercurial commands. This is a little bit 'duh' now, but thanks to @lazy-badger for pointing it out.You can fix your Server 2008 permissions using a command like
icacls path /grant domain\user:(OI)(CI)F
(see e.g. http://www.petri.co.il/forums/showthread.php?t=23207), but be sure to do this from an escalated CMD window ('Run As Adminstrator'). Again 'duh' to Windows people, not so obvious to a Linux person (instead I went googling around for some DOS equivalent tosudo
).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果其他程序打开了该文件,您可能会在 Windows 上收到访问被拒绝错误。您可以尝试关闭可能打开该树中任何文件的程序,或重新启动计算机(当然,这会关闭所有程序)。
You may get an access denied error on Windows if some other program has the file open. You can try closing programs that might have any files in that tree open, or rebooting the computer (which would, of course, close all programs).
只是要注意合并时的“访问被拒绝”可以有两个不同的根源:@emil 提到的以及用户的错误或不存在的权限(在该权限下启动凭据 hg)在 $TEMP 文件夹中创建临时文件
Just to note "Access denied" on merge can have two different roots: mentioned by @emil and wrong or nonexistent rights for user, under which credentials hg was started, to create temporary files in $TEMP folder