如何在 Windows 上进行硬链接克隆

发布于 2024-08-26 20:59:45 字数 2453 浏览 2 评论 0原文

我有一个运行 Tortoise 1.0 x64 版本的 Win7 x64 机器。 About Tortoise 透露它是 1.0“带有 Mercurial-1.5、Python-2.6.4、PyGTK-2.16.0、GTK-2.18.7”。我还安装了 ActivePython 2.6 和 Mercurial 1.5 x64(通过 64 位安装程序。我的 Windows 机器上的驱动器都是 NTFS,

事实上,当我运行 python 解释器时 。并通过 win32file api 执行硬链接创建,它成功创建了一个链接:

me@pc C:\temp
> python
ActivePython 2.6.2.2 (ActiveState Software Inc.) based on
Python 2.6.2 (r262:71600, Apr 21 2009, 15:05:37) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from win32file import *
>>> CreateHardLink('C:\\temp\\Mike2.txt','C:\\temp\\Mike.txt')
>>> ^Z

me@pc C:\temp
> fsutil hardlink list Mike.txt
\temp\Mike.txt
\temp\Mike2.txt

但是,如果我使用 Mercurial 进行克隆,我不会得到相同的结果:

me@pc C:\Users\mcaron
> which hg
C:\Program Files (x86)\Mercurial\\hg.EXE
me@pc C:\temp
> hg status demo
mcaron@DEV-MCARON-W64 C:\temp
> hg log demo
changeset:   0:6db7092740d5
tag:         tip
user:        Michael Caron <[email protected]>
date:        Wed Mar 24 16:08:38 2010 -0500
summary:     first

me@pc C:\temp
> hg clone demo demo2
updating to branch default
5 files updated, 0 files merged, 0 files removed, 0 files unresolved
me@pc C:\temp
> fsutil hardlink list .\demo\mike.prtprp
\temp\demo\mike.prtprp
me@pc4 C:\temp
> fsutil hardlink list .\demo\mike1.prtprp
\temp\demo\mike1.prtprp
me@pc C:\temp
> fsutil hardlink list .\demo\mike1_2.prtprp
\temp\demo\mike1_2.prtprp
mme@pc C:\temp
> fsutil hardlink list .\demo\mike2.prtprp
\temp\demo\mike2.prtprp

me@pc4 C:\temp
> hg --version
Mercurial Distributed SCM (version 1.5)

Copyright (C) 2005-2010 Matt Mackall <[email protected]> and others
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
me@pc C:\temp
> python -V
Python 2.6.2

是否有人在使用硬链接的情况下在 Windows 上进行克隆工作?我注意到 TortoiseHg 安装程序附带了 Python 2.6 安装程序。还注意到它有自己的 Hg 可执行文件(我也尝试过并得到相同的结果)。

I've got a Win7 x64 box running Tortoise 1.0 x64 release. About Tortoise reveals that it's 1.0 "with Mercurial-1.5, Python-2.6.4, PyGTK-2.16.0, GTK-2.18.7". I've also got ActivePython 2.6 and Mercurial 1.5 x64 installed (installed via the Mercurial installer from the 64-bit installer. Neither one clone with Hard Links on my windows box. The drives on my box are also NTFS, which supports hard links.

In deed, when I run the python interpreter and execute a hard link creation via the win32file api, it creates a link successfully:

me@pc C:\temp
> python
ActivePython 2.6.2.2 (ActiveState Software Inc.) based on
Python 2.6.2 (r262:71600, Apr 21 2009, 15:05:37) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from win32file import *
>>> CreateHardLink('C:\\temp\\Mike2.txt','C:\\temp\\Mike.txt')
>>> ^Z

me@pc C:\temp
> fsutil hardlink list Mike.txt
\temp\Mike.txt
\temp\Mike2.txt

However, if I use Mercurial to clone, I don't get the same results:

me@pc C:\Users\mcaron
> which hg
C:\Program Files (x86)\Mercurial\\hg.EXE
me@pc C:\temp
> hg status demo
mcaron@DEV-MCARON-W64 C:\temp
> hg log demo
changeset:   0:6db7092740d5
tag:         tip
user:        Michael Caron <[email protected]>
date:        Wed Mar 24 16:08:38 2010 -0500
summary:     first

me@pc C:\temp
> hg clone demo demo2
updating to branch default
5 files updated, 0 files merged, 0 files removed, 0 files unresolved
me@pc C:\temp
> fsutil hardlink list .\demo\mike.prtprp
\temp\demo\mike.prtprp
me@pc4 C:\temp
> fsutil hardlink list .\demo\mike1.prtprp
\temp\demo\mike1.prtprp
me@pc C:\temp
> fsutil hardlink list .\demo\mike1_2.prtprp
\temp\demo\mike1_2.prtprp
mme@pc C:\temp
> fsutil hardlink list .\demo\mike2.prtprp
\temp\demo\mike2.prtprp

me@pc4 C:\temp
> hg --version
Mercurial Distributed SCM (version 1.5)

Copyright (C) 2005-2010 Matt Mackall <[email protected]> and others
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
me@pc C:\temp
> python -V
Python 2.6.2

Does anyone have cloning working on Windows with hardlinks being used or is it not supported? I noticed that the TortoiseHg installer comes with a Python 2.6 installation. Also noticed that it has it's own Hg executable (which I've also tried and get the same results). Could the TortoiseHg and Mercurial installations be causing problems?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

别在捏我脸啦 2024-09-02 20:59:45

是的,您得到了答案:硬链接位于存储库 (.hg) 中,而不是工作目录中。因此,如果您使用 -U 创建克隆,您的克隆不会占用额外的磁盘空间。无工作目录克隆在服务器端是一个不错的选择,有时在桌面上也很有用。如果您忘记了 -U,您始终可以使用 hg update -r null 删除存储库的工作目录,该目录会更新为 null 修订版,该修订版早于添加任何文件。

Yeah, you got the answer: the hardlinking is in the repo (.hg) not the working directory. Thus, if you create a clone with -U your clone takes up no additional diskspace. A no-working-dir clone is a great option on the server side, and sometimes useful on desktops too. If you forget the -U you can always get rid of a repo's working dir with hg update -r null which updates to the null revision, which predates the adding of any files.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文