2013-02-16 34 views
8

Mercurial中是否存在與NIX軟目錄或文件的軟鏈接或硬鏈接等價的內容。Mercurial中的軟鏈接

基本上是一個文件(或目錄)鏈接到文件「別的地方」,並遵循該位置的版本(不同於一般的分支我認爲,其中一個人必須要合併)

回答

7

水銀版本軟該存儲庫內部的鏈接非常棒。它會檢測它們,記錄它們,併爲你創建它們。有沒有你正在尋找的具體用例?與存儲庫外的鏈接最接近的是一個subrepo,它是指向另一個repo特定版本的指針。

符號鏈接工作

(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 [email protected] -> 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 <[email protected]> 
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 [email protected] -> target 
-rw-r--r-- 1 ry4an staff  5B Feb 16 19:26 target 

但是硬連接不

$hg commit -Am "hardlinks target" 
adding link 
adding target 
$hg log -p 
changeset: 0:ec9407634133 
tag:   tip 
user:  Chris Wesseling <[email protected]> 
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 
+0

你的意思是它會在正在版本化的文件中處理NIX軟鏈接? – Olav 2013-02-16 19:15:14

+0

就是這樣。看到上面的更新。 – 2013-02-17 00:27:52

+0

感謝您的更新@ chris-wesseling他們詢問了有關soft/sym鏈接,但擁有ht鏈接信息也不錯。 – 2013-03-21 19:59:15

6

在* nix系統,hg Mercurial審計符號鏈接( 「符號鏈接」)的簡稱路徑的安全性。 例如,絕對路徑和空路徑被認爲是不安全的,因此不會被添加到存儲庫。

Mercurial開發人員尚未記錄此功能。然而,the source code contains a comment用有些含糊的解釋:

class pathauditor(object): 
    '''ensure that a filesystem path contains no banned components. 
    the following properties of a path are checked: 

    - ends with a directory separator 
    - under top-level .hg 
    - starts at the root of a windows drive 
    - contains ".." 
    - traverses a symlink (e.g. a/symlink_here/b) 
    - inside a nested repository (a callback can be used to approve 
     some nested repositories, e.g., subrepositories) 
    ''' 

在Windows上,符號鏈接不支持各種原因,請參閱:

+0

可以將添加到絕對路徑的符號鏈接添加到mercurial repo中。我不知道在這種情況下「空路」是什麼意思。 – Juan 2016-01-26 03:39:31