Version-Control
測試樹中是否有任何 RCS 控制的文件未簽入
我有多個遺留程式碼項目樹,它們使用 RCS 對多個使用者進行版本控制。我希望能夠遍歷樹並測試是否有任何文件被簽出(因此樹還沒有準備好打包以進行分發更新)。
例如,我有一個測試樹:
tree -p .
. ├── [-r--r--r--] file1 ├── [drwxrwxr-x] RCS │ └── [-r--r--r--] file1,v ├── [drwxrwxr-x] subdir1 │ ├── [drwxrwxr-x] RCS │ │ └── [-r--r--r--] sfile1,v │ └── [-rw-r--r--] sfile1 └── [drwxrwxr-x] subdir2 ├── [drwxrwxr-x] RCS │ └── [-r--r--r--] sfile2,v └── [-r--r--r--] sfile2 5 directories, 6 files
其中所有文件
sfile1
都簽入到各自的 RCS 目錄中。sfile1
已檢查並修改。
rlog subdir1/sfile1
(正確簽出的文件)返回:RCS file: subdir1/RCS/sfile1,v Working file: subdir1/sfile1 head: 1.1 branch: locks: strict torfey: 1.1 access list: symbolic names: keyword substitution: kv total revisions: 1; selected revisions: 1 description: ---------------------------- revision 1.1 locked by: torfey; date: 2016/07/20 13:09:34; author: torfey; state: Exp; Initial revision =============================================================================
而
rlog subdir2/sfile2
(正確簽入的文件)返回:RCS file: subdir2/RCS/sfile2,v Working file: subdir2/sfile2 head: 1.1 branch: locks: strict access list: symbolic names: keyword substitution: kv total revisions: 1; selected revisions: 1 description: ---------------------------- revision 1.1 date: 2016/07/20 13:10:04; author: torfey; state: Exp; Initial revision =============================================================================
因此,在給定目錄參數的情況下,我想要的命令會搜尋該目錄下屬於 RCS 的所有文件,並返回未簽入的任何文件的名稱。(理想情況下,如果還有其他可檢測的狀態並且不好,就像沒有鎖定但與簽入的版本不同,也報告一下。)
test_rcs_tree .
對於我上面的簡單案例,它會返回:
./subdir1/sfile1 checked-out
我正在苦苦掙扎的是,是否有一些東西已經做到了這一點,而我在所有搜尋中都錯過了。
我在 RHEL 6.7 上執行,它具有 rcs 5.7、gnu awk 3.1.7、gnu make 3.81、bash 4.1.2
我有一個舊版 rcs 狀態腳本:
#!/bin/bash find ${@:-.} -type f | sed '\;/RCS/;d' | while read file do msg= if [ -z "$(rlog -R "$file" 2>/dev/null)" ] then msg="$msg no RCS" else if co -q -kk -p "$file" | cmp -s - "$file" || co -q -p "$file" | cmp -s - "$file" then msg="$msg same" else msg="$msg differs" fi if [ -z "$(rlog -L -R "$file")" ] then msg="$msg not locked" else msg="$msg locked" user=$(rlog -h "$file" | awk '/locks:/{ getline; sub(":"," "); print $1 }') if [ -n "$user" ] then msg="$msg by $user" fi fi fi if [ -w "$file" ] then msg="$msg writeable" fi echo "$file: $msg" done
給它一個目錄或文件,它會產生類似的輸出
whenerror: same not locked kshrc: same not locked writeable mylua.lua: no RCS writeable subshell: differs locked by meuh writeable mshrc: differs locked by meuh
其中“相同未鎖定”意味著它已簽入,並且是只讀的,通常是所需的狀態。