Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get hardlink cloning on Windows

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?

like image 357
Mike Caron Avatar asked Mar 26 '10 13:03

Mike Caron


People also ask

What is a HardLink clone?

HardLink or Symbolic Link Clones are useful if you need to replicate a folder tree at a different location. The disk space required is minimal because the new structure consists entirely of NTFS directory entries with no real amount of actual data storage.

Is a HardLink a copy?

This hard link is duplicate copy of the original file, a shortcut to the file. Editing it will make changes to the file. The hard link acts like the copy.

Does Windows have hard link?

Hard links, junction points and symbolic links are linking processes used by Windows to associate other files, directories or volumes. One of the methods to create file links is to use the command line program mklink: To create a file hard link: mklink /H linkName target.

How do I create a symbolic link in Windows?

On Windows 10, you can set up symlinks through the Command Prompt using the mklink command. First up, launch the Command Prompt by typing cmd in the Start menu search bar, then right-click the Best Match and select Run as administrator. You can use the mklink command to create hard and soft links.


1 Answers

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.

like image 93
Ry4an Brase Avatar answered Oct 05 '22 06:10

Ry4an Brase