清華大佬耗費(fèi)三個(gè)月吐血整理的幾百G的資源,免費(fèi)分享!....>>>
Jerry 已經(jīng)將 array.c 文件已經(jīng)添加到庫中。Tom 也檢出最新的代碼,并開始運(yùn)作。
[tom@CentOS ~]$ svn co http://svn.server.com/svn/project_repo --username=tom
上面的命令將產(chǎn)生以下結(jié)果
A project_repo/trunk A project_repo/trunk/array.c A project_repo/branches A project_repo/tags Checked out revision 2.
但他是創(chuàng)立的,有人已經(jīng)添加的代碼。所以他好奇誰這樣做,他看到更多的細(xì)節(jié),使用下面的命令檢查日志消息:
[tom@CentOS trunk]$ svn log
上面的命令將產(chǎn)生以下結(jié)果
------------------------------------------------------------------------ r2 | jerry | 2013-08-17 20:40:43 +0530 (Sat, 17 Aug 2013) | 1 line Initial commit ------------------------------------------------------------------------ r1 | jerry | 2013-08-04 23:43:08 +0530 (Sun, 04 Aug 2013) | 1 line Create trunk, branches, tags directory structure ------------------------------------------------------------------------
當(dāng)Tom觀察了杰里的代碼。他立即注意到,一個(gè)bug已被放入。Jerry不檢查數(shù)組溢出,這將導(dǎo)致嚴(yán)重的問題。因此,Tom 決定來解決這個(gè)問題。經(jīng)過modificationarray.c會這個(gè)樣子。
#include <stdio.h> #define MAX 16 int main(void) { int i, n, arr[MAX]; printf("Enter the total number of elements: "); scanf("%d", &n); /* handle array overflow condition */ if (n > MAX) { fprintf(stderr, "Number of elements must be less than %d ", MAX); return 1; } printf("Enter the elements "); for (i = 0; i < n; ++i) scanf("%d", &arr[i]); printf("Array has following elements "); for (i = 0; i < n; ++i) printf("|%d| ", arr[i]); printf(" "); return 0; }
Tom 要使用狀態(tài)操作,看到掛起的更改列表。
[tom@CentOS trunk]$ svn status M array.c
array.c 文件被修改,這就是為什么Subversion 文件名前顯示中號信。接下來Tom編譯和測試自己的代碼和它的正常工作。在提交更改之前,他想通過審查所作的變化,他要仔細(xì)檢查它。
[tom@CentOS trunk]$ svn diff Index: array.c =================================================================== --- array.c (revision 2) +++ array.c (working copy) @@ -9,6 +9,11 @@ printf("Enter the total number of elements: "); scanf("%d", &n); + if (n > MAX) { + fprintf(stderr, "Number of elements must be less than %d ", MAX); + return 1; + } + printf("Enter the elements "); for (i = 0; i < n; ++i)
Tom 補(bǔ)充array.c文件,這就是為什么顛覆顯示+號新生產(chǎn)線前的幾行。現(xiàn)在準(zhǔn)備提交更改。
[tom@CentOS trunk]$ svn commit -m "Fix array overflow problem"
上面的命令將產(chǎn)生以下結(jié)果
Sending trunk/array.c Transmitting file data . Committed revision 3.
Tom 的變化成功提交到庫中。
掃碼二維碼 獲取免費(fèi)視頻學(xué)習(xí)資料
- 本文固定鏈接: http://www.wangchenghua.com/j/svn/1001022/
- 免費(fèi): Python視頻資料獲取