練習題
[root@dywHome2 ~]# rcs [-Aabeilmnotu] parameter
-A file 將其它檔案的可存取名單寫入該檔的可存取名單
-a name 將使用者寫入可存取名單
-b branch number 設定主支( default branch )
-e name 將使用者自可存取名單內剔除
-i file 產生及初始化一個新的 RCS 檔案
-l[number] lock 該版本但不取出
-m 更改檔案版本的附注( log ) 的內容
-n symbol 產生或去除標記符號( mark symbol )
-o[number] 從檔案的 archive file 中移除某版本
-t 改檔案版本的描述( description ) 的內容
-u[number] 去除該版本 lock 的狀態
# u[number] 表示選項 u 後面馬上接版本序號
[dywang@dywOffice testrcs]$ vi important.c
/*
This is an important file for managing the project.
It implements the canoncial "Hello World" program.
*/
#include <stdlib.h>
#include <stdio.h>
int main()
{
printf("Hello World\n");
exit(EXIT_SUCCESS);
}
[dywang@dywOffice testrcs]$ rcs -i important.c
RCS file: important.c,v
enter description, terminated with single '.' or end of file:
NOTE: This is NOT the log message!
>> This is an important demonstration file
>> .
done
# 可以輸入很多註解。要跳離提示符號,必須輸入(.),或者在檔案字元的結尾輸入 Ctrl+D。
[dywang@dywOffice testrcs]$ ll
total 12
-rw-r--r-- 1 dywang users 226 Mar 5 13:45 important.c
-r--r--r-- 1 dywang users 105 Mar 5 13:55 important.c,v
[dywang@dywOffice testrcs]$ mkdir RCS
[dywang@dywOffice testrcs]$ ll
total 8
-rw-r--r-- 1 dywang users 226 Mar 5 13:45 important.c
drwxr-xr-x 2 dywang users 4096 Mar 5 13:49 RCS/
[dywang@dywOffice testrcs]$ rcs -i important.c
RCS file: RCS/important.c,v
enter description, terminated with single '.' or end of file:
NOTE: This is NOT the log message!
>> This is an important demonstration file
>> .
done
[dywang@dywOffice testrcs]$ ll . RCS
.:
total 8
-rw-r--r-- 1 dywang users 226 Mar 5 13:45 important.c
drwxr-xr-x 2 dywang users 4096 Mar 5 13:49 RCS/
RCS:
total 4
-r--r--r-- 1 dywang users 105 Mar 5 13:49 important.c,v
[dywang@dywOffice testrcs]$ cat RCS/important.c,v
head ;
access;
symbols;
locks; strict;
comment @ * @;
desc
@This is an important demonstration file
@
[root@dywHome2 ~]# ci [-dfwmnrtlu] parameter
-d date 給定版本生成時間
-f 強制產生新版本(不管是否寫入相同版本內容)
-w name 給定生成該版本的作者名
-m log-message 直接以 log-message 寫入附記( log )
-n symbol 在寫入 archive file 同時, 給定標記符號( mark symbol )
-r[number] 寫入時指定版本的 rivision number
-t description 直接以檔案的形式寫入描述( description )
-l 寫入後再取出該版本為工作檔案( lock )
-u 寫入後再取出該版本為工作檔案( unlock )
[dywang@dywOffice testrcs]$ ci important.c
RCS/important.c,v <-- important.c
initial revision: 1.1
done
[dywang@dywOffice testrcs]$ ll . RCS
.:
total 4
drwxr-xr-x 2 dywang users 4096 Mar 5 14:06 RCS/
RCS:
total 4
-r--r--r-- 1 dywang users 446 Mar 5 14:06 important.c,v
[dywang@dywOffice testrcs]$ cat RCS/important.c,v
head 1.1;
access;
symbols;
locks; strict;
comment @ * @;
1.1
date 2008.03.05.06.06.15; author dywang; state Exp;
branches;
next ;
desc
@This is an important demonstration file
@
1.1
log
@Initial revision
@
text
@/*
This is an important file for managing the project.
It implements the canoncial "Hello World" program.
*/
#include <stdlib.h>
#include <stdio.h>
int main()
{
printf("Hello World\n");
exit(EXIT_SUCCESS);
}
@
[root@dywHome2 ~]# co [-dfjlprwu] parameter
-d date 取出在指定時間前最後生成的版本
-f 強制取出版本內容取代目前工作檔案
-j 取出並整合指定的版本內容
-l lock 取出版本
-p 取出版本內容至標準輸出( standard output )
-r number 指定取出版本
-w name 取出指定作者名之版本
-u 取出 unlock 的版本內容
[dywang@dywOffice testrcs]$ co important.c
RCS/important.c,v --> important.c
revision 1.1
done
[dywang@dywOffice testrcs]$ ll
total 8
-r--r--r-- 1 dywang users 226 Mar 5 14:15 important.c
drwxr-xr-x 2 dywang users 4096 Mar 5 14:06 RCS/
[dywang@dywOffice testrcs]$ co -l important.c
RCS/important.c,v --> important.c
revision 1.1 (locked)
done
[dywang@dywOffice testrcs]$ ll
total 8
-rw-r--r-- 1 dywang users 226 Mar 5 14:18 important.c
drwxr-xr-x 2 dywang users 4096 Mar 5 14:18 RCS/
[dywang@dywOffice testrcs]$ vi important.c
[dywang@dywOffice testrcs]$ cat important.c
/*
This is an important file for managing the project.
It implements the canoncial "Hello World" program.
*/
#include <stdlib.h>
#include <stdio.h>
int main()
{
printf("Hello World\n");
printf("This is an extra line added later\n");
exit(EXIT_SUCCESS);
}
[dywang@dywOffice testrcs]$ ci important.c
RCS/important.c,v <-- important.c
new revision: 1.2; previous revision: 1.1
enter log message, terminated with single '.' or end of file:
>> Added an extra line to be printed out
>> .
done
[dywang@dywOffice testrcs]$ ll . RCS
.:
total 8
-rw-r--r-- 1 dywang users 226 Mar 5 14:18 important.c~
drwxr-xr-x 2 dywang users 4096 Mar 5 14:24 RCS/
RCS:
total 4
-r--r--r-- 1 dywang users 639 Mar 5 14:24 important.c,v
[dywang@dywOffice testrcs]$ cat RCS/important.c,v
head 1.2;
access;
symbols;
locks; strict;
comment @ * @;
1.2
date 2008.03.05.06.23.52; author dywang; state Exp;
branches;
next 1.1;
1.1
date 2008.03.05.06.06.15; author dywang; state Exp;
branches;
next ;
desc
@This is an important demonstration file
@
1.2
log
@Added an extra line to be printed out
@
text
@/*
This is an important file for managing the project.
It implements the canoncial "Hello World" program.
*/
#include <stdlib.h>
#include <stdio.h>
int main()
{
printf("Hello World\n");
printf("This is an extra line added later\n");
exit(EXIT_SUCCESS);
}
@
1.1
log
@Initial revision
@
text
@d12 1
@
[dywang@dywOffice testrcs]$ rcs -i important.c
RCS file: important.c,v
enter description, terminated with single '.' or end of file:
NOTE: This is NOT the log message!
>> This is an important demonstration file
>> .
done
# 可以輸入很多註解。要跳離提示符號,必須輸入(.),或者在檔案字元的結尾輸入 Ctrl+D。
[dywang@dywOffice testrcs]$ ci important.c
RCS/important.c,v <-- important.c
new revision: 1.2; previous revision: 1.1
enter log message, terminated with single '.' or end of file:
>> Added an extra line to be printed out
>> .
done
[dywang@dywOffice testrcs]$ co -l important.c
RCS/important.c,v --> important.c
revision 1.3
done
[dywang@dywOffice testrcs]$ vi important.c
[dywang@dywOffice testrcs]$ ci -m"test for comment" important.c
RCS/important.c,v <-- important.c
new revision: 1.4; previous revision: 1.3
done
[dywang@dywOffice testrcs]$ rlog -r1.4 important.c
RCS file: RCS/important.c,v
Working file: important.c
head: 1.4
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 5; selected revisions: 1
description:
This is an important demonstration file
----------------------------
revision 1.4
date: 2008/03/07 02:30:48; author: dywang; state: Exp; lines: +1 -0
test for comment
=======================================================================
[root@dywHome2 ~]# rlog [-bhLRt] parameter
-b 列出檔案主分支( default branch )的附記( log )一覽表
-h 列出檔案附記( log )的標頭( header )
-L 若該檔有被 lock 則列出各版本附記( log )一覽表
-R 列出檔案的 archive file 路徑與名稱
-t 列出檔案附記( log )的標頭( header )+ 描述( description )
[dywang@dywOffice testrcs]$ rlog important.c
RCS file: RCS/important.c,v
Working file: important.c
head: 1.2
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 2; selected revisions: 2
description:
This is an important demonstration file
----------------------------
revision 1.2
date: 2008/03/05 06:23:52; author: dywang; state: Exp; lines: +1 -0
Added an extra line to be printed out
----------------------------
revision 1.1
date: 2008/03/05 06:06:15; author: dywang; state: Exp;
Initial revision
=======================================================================
# 在 1.2 版中的第一行行尾 lines:+1 -0 表示增加了一行,但沒有刪除任何行。
[dywang@dywOffice testrcs]$ rlog -h important.c
RCS file: RCS/important.c,v
Working file: important.c
head: 1.2
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 2
=======================================================================
[dywang@dywOffice testrcs]$ rlog -R important.c
RCS/important.c,v
[dywang@dywOffice testrcs]$ rlog -t important.c
RCS file: RCS/important.c,v
Working file: important.c
head: 1.2
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 2
description:
This is an important demonstration file
=======================================================================
[dywang@dywOffice testrcs]$ co important.c
RCS/important.c,v --> important.c
revision 1.2
done
[dywang@dywOffice testrcs]$ ll
total 12
-r--r--r-- 1 dywang users 276 Mar 6 09:56 important.c
-rw-r--r-- 1 dywang users 277 Mar 5 21:09 important.c~
drwxr-xr-x 2 dywang users 4096 Mar 6 09:56 RCS/
[dywang@dywOffice testrcs]$ vi important.c
[dywang@dywOffice testrcs]$ ci important.c
RCS/important.c,v <-- important.c
ci: RCS/important.c,v: no lock set by dywang
[dywang@dywOffice testrcs]$ rcs -l1.2 important.c
RCS file: RCS/important.c,v
1.2 locked
done
[dywang@dywOffice testrcs]$ ci important.c
RCS/important.c,v <-- important.c
new revision: 1.3; previous revision: 1.2
enter log message, terminated with single '.' or end of file:
>> test for lock
>> .
done
[dywang@dywOffice testrcs]$ co -l important.c
RCS/important.c,v --> important.c
revision 1.2 (locked)
done
[dywang@dywOffice testrcs]$ vi important.c
[dywang@dywOffice testrcs]$ ci -r1.2 important.c
RCS/important.c,v <-- important.c
ci: RCS/important.c,v: revision 1.2 too low; must be higher than 1.2
[dywang@dywOffice testrcs]$ ci important.c
RCS/important.c,v <-- important.c
new revision: 1.3; previous revision: 1.2
enter log message, terminated with single '.' or end of file:
>> test for lock
>> .
done
[dywang@dywOffice testrcs]$ co -l important.c
RCS/important.c,v --> important.c
revision 1.3 (locked)
done
[dywang@dywOffice testrcs]$ vi important.c
[dywang@dywOffice testrcs]$ rcs -o1.3 important.c
RCS file: RCS/important.c,v
rcs: RCS/important.c,v: can't remove locked revision 1.3
[dywang@dywOffice testrcs]$ rcs -u1.3 important.c
RCS file: RCS/important.c,v
1.3 unlocked
done
[dywang@dywOffice testrcs]$ rcs -o1.3 important.c
RCS file: RCS/important.c,v
deleting revision 1.3
done
[dywang@dywOffice testrcs]$ ci important.c
RCS/important.c,v <-- important.c
ci: RCS/important.c,v: no lock set by dywang
[dywang@dywOffice testrcs]$ rcs -l1.2 important.c
RCS file: RCS/important.c,v
1.2 locked
done
[dywang@dywOffice testrcs]$ ci important.c
RCS/important.c,v <-- important.c
new revision: 1.3; previous revision: 1.2
enter log message, terminated with single '.' or end of file:
>> test for deletes
>> .
done
如果在版本 1.2 產生版本 1.3 之後, 又修改版本 1.2 的內容而欲生成新的版本, 則需在版本 1.2 處產生分支( branch ) 1.2.1.1。
[dywang@dywOffice testrcs]$ co -r1.2 -l important.c
RCS/important.c,v --> important.c
revision 1.2 (locked)
done
[dywang@dywOffice testrcs]$ ci important.c
RCS/important.c,v <-- important.c
file is unchanged; reverting to previous revision 1.2
done
[dywang@dywOffice testrcs]$ ll
total 8
-rw-r--r-- 1 dywang users 276 Mar 6 10:12 important.c~
drwxr-xr-x 2 dywang users 4096 Mar 6 13:05 RCS/
[dywang@dywOffice testrcs]$ co -r1.2 -l important.c
RCS/important.c,v --> important.c
revision 1.2 (locked)
done
[dywang@dywOffice testrcs]$ vi important.c
[dywang@dywOffice testrcs]$ cat important.c
/*
This is an important file for managing the project.
It implements the canoncial "Hello World" program.
*/
#include <stdlib.h>
#include <stdio.h>
int main()
{
printf("Hello World\n");
printf("This is an extra line added later\n");
printf("test for branch\n");
exit(EXIT_SUCCESS);
}
[dywang@dywOffice testrcs]$ ci important.c
RCS/important.c,v <-- important.c
new revision: 1.2.1.1; previous revision: 1.2
enter log message, terminated with single '.' or end of file:
>> test for branch
>> .
done
[dywang@dywOffice testrcs]$ rlog important.c
RCS file: RCS/important.c,v
Working file: important.c
head: 1.3
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 4; selected revisions: 4
description:
This is an important demonstration file
----------------------------
revision 1.3
date: 2008/03/06 03:17:00; author: dywang; state: Exp; lines: +1 -0
test for deletes
----------------------------
revision 1.2
date: 2008/03/05 06:23:52; author: dywang; state: Exp; lines: +1 -0
branches: 1.2.1;
Added an extra line to be printed out
----------------------------
revision 1.1
date: 2008/03/05 06:06:15; author: dywang; state: Exp;
Initial revision
----------------------------
revision 1.2.1.1
date: 2008/03/06 05:07:38; author: dywang; state: Exp; lines: +1 -0
test for branch
=======================================================================
Sol.
rcs -i important.c
Sol.
important.c,v
Sol.
輸入一點(.),或按鍵 Ctrl+D。
Sol.
檔名為 RCS (不可為小寫)的子目錄。
Sol.
co important.c
Sol.
co -l important.c
-r--r--r--,則取出版本是否鎖定?
Sol.
沒鎖定
-rw-r--r--,則取出版本是否鎖定?
Sol.
已鎖定
Sol.
不存在
Sol.
1. 初始 RCS 管理檔案;2.寫入管理檔案。
Sol.
ci -m"test for log" important.c
Sol.
rlog important.c
Sol.
表示增加了一行,但沒有刪除任何行。
Sol.
rlog -h important.c
Sol.
rlog -R important.c
Sol.
rlog -t important.c
Sol.
鎖住方式為 strict
Sol.
識別關鍵字串解釋方式為 kv
Sol.
沒有鎖住,故無法存入。
Sol.
先執行指令 rcs -l1.2 important.c 鎖住,再寫入。
Sol.
rcs -o1.3 important.c
Sol.
rcs -u1.3 important.c
Sol.
1.2.1.1
Sol.
不會
Sol.
1.4.1.1
Next: 識別關鍵字串
Up: *RCS 版本控制系統
Previous: 版本控制
Contents
2017-06-14