Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
409 views
in Technique[技术] by (71.8m points)

symlink - Soft link in Mercurial

Is there some equivalent in Mercurial to NIX soft- or hard- links to directories or files.

Basically that a file (or directory) is linked to a file "somewhere else" and follows the version of that location (Unlike a regular branch I think, where one would have to merge)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Mercurial versions soft links that are internal to the repository just great. It'll detect them, record them, and create them for you. Is there a specific use case you're looking for? The closest thing to an link that reaches outside the repository is a subrepo, which is a pointer to a specific version of another repo.

Symlinks work

(df)Ry4ans-MacBook-Air:~ ry4an$ hg init olav
(df)Ry4ans-MacBook-Air:~ ry4an$ cd olav/
(df)Ry4ans-MacBook-Air:olav ry4an$ echo this > target
(df)Ry4ans-MacBook-Air:olav ry4an$ ln -s target link
(df)Ry4ans-MacBook-Air:olav ry4an$ ls -l
total 16
lrwxr-xr-x  1 ry4an  staff     6B Feb 16 19:25 link@ -> target
-rw-r--r--  1 ry4an  staff     5B Feb 16 19:25 target
(df)Ry4ans-MacBook-Air:olav ry4an$ hg commit -A -m "link and its target"
adding link
adding target
(df)Ry4ans-MacBook-Air:olav ry4an$ hg log -p
changeset:   0:42a41a431661
tag:         tip
user:        Ry4an Brase <ry4an-hg@ry4an.org>
date:        Sat Feb 16 19:26:17 2013 -0500
summary:     link and its target

diff -r 000000000000 -r 42a41a431661 link
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/link  Sat Feb 16 19:26:17 2013 -0500
@@ -0,0 +1,1 @@
+target
 No newline at end of file
diff -r 000000000000 -r 42a41a431661 target
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/target    Sat Feb 16 19:26:17 2013 -0500
@@ -0,0 +1,1 @@
+this

(df)Ry4ans-MacBook-Air:olav ry4an$ hg update null
0 files updated, 0 files merged, 2 files removed, 0 files unresolved
(df)Ry4ans-MacBook-Air:olav ry4an$ ls -l
(df)Ry4ans-MacBook-Air:olav ry4an$ hg update tip
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
(df)Ry4ans-MacBook-Air:olav ry4an$ ls -l
total 16
lrwxr-xr-x  1 ry4an  staff     6B Feb 16 19:26 link@ -> target
-rw-r--r--  1 ry4an  staff     5B Feb 16 19:26 target

But hardlinks don't

$hg commit -Am "hardlinks target"
adding link
adding target
$hg log -p
changeset:   0:ec9407634133
tag:         tip
user:        Chris Wesseling <chris.wesseling@cwi.nl>
date:        Wed Mar 13 23:14:44 2013 +0100
summary:     hardlinks target

diff -r 000000000000 -r ec9407634133 link
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/link      Wed Mar 13 23:14:44 2013 +0100
@@ -0,0 +1,1 @@
+foo
diff -r 000000000000 -r ec9407634133 target
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/target    Wed Mar 13 23:14:44 2013 +0100
@@ -0,0 +1,1 @@
+foo

$ls -lin
total 8
276702 -rw-r--r-- 2 1204653 5900 4 13 mrt 23:14 link
276702 -rw-r--r-- 2 1204653 5900 4 13 mrt 23:14 target
$hg update null
0 files updated, 0 files merged, 2 files removed, 0 files unresolved
$hg update tip
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ls -lin
total 8
276719 -rw-r--r-- 1 1204653 5900 4 13 mrt 23:15 link
276721 -rw-r--r-- 1 1204653 5900 4 13 mrt 23:15 target

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...