课程表

SVN课程

工具箱
速查手册

SVN 检查更改

当前位置:免费教程 » 软件/图像 » SVN

Jerry 往仓库里添加了一个叫做 array.c 的文件。 Tom 签出最后一个版本后开始工作。

  1. [tom@CentOS ~]$ svn co http://svn.server.com/svn/project_repo --username=tom

上面的命令将会产生下面的效果

  1. A project_repo/trunk
  2. A project_repo/trunk/array.c
  3. A project_repo/branches
  4. A project_repo/tags
  5. Checked out revision 2.

但是,他发现有人已经添加了代码,他很好奇是谁添加的,于是他用下面的命令检查 log 信息:

  1. [tom@CentOS trunk]$ svn log

上面的命令将会产生下面的效果

  1. ------------------------------------------------------------------------
  2. r2 | jerry | 2013-08-17 20:40:43 +0530 (Sat, 17 Aug 2013) | 1 line
  3. Initial commit
  4. ------------------------------------------------------------------------
  5. r1 | jerry | 2013-08-04 23:43:08 +0530 (Sun, 04 Aug 2013) | 1 line
  6. Create trunk, branches, tags directory structure
  7. ------------------------------------------------------------------------

当 Tom 查看 Jerry 的代码时,他注意到了里面的一个 bug 。 Jerry 没有检查数组溢出,这会导致很严重的问题。所以 Tom 决定修复这个问题。在修改之后, array.c 将会是这个样子。

  1. #include <stdio.h>
  2. #define MAX 16
  3. int main(void)
  4. {
  5. int i, n, arr[MAX];
  6. printf("Enter the total number of elements: ");
  7. scanf("%d", &n);
  8. /* handle array overflow condition */
  9. if (n > MAX) {
  10. fprintf(stderr, "Number of elements must be less than %d\n", MAX);
  11. return 1;
  12. }
  13. printf("Enter the elements\n");
  14. for (i = 0; i < n; ++i)
  15. scanf("%d", &arr[i]);
  16. printf("Array has following elements\n");
  17. for (i = 0; i < n; ++i)
  18. printf("|%d| ", arr[i]);
  19. printf("\n");
  20. return 0;
  21. }

Tom 想使用 status 操作来看看将要生效的更改列表

  1. [tom@CentOS trunk]$ svn status
  2. M array.c

array.c 文件已经被修改,Subversion 会在修改过的文件前面加一个字母 M 。接下来 Tom 编译测试了他的代码,并且工作良好。在提交更改前,他想要再次检查他的更改。

  1. [tom@CentOS trunk]$ svn diff
  2. Index: array.c
  3. ===================================================================
  4. --- array.c (revision 2)
  5. +++ array.c (working copy)
  6. @@ -9,6 +9,11 @@
  7. printf("Enter the total number of elements: ");
  8. scanf("%d", &n);
  9. + if (n > MAX) {
  10. + fprintf(stderr, "Number of elements must be less than %d\n", MAX);
  11. + return 1;
  12. + }
  13. +
  14. printf("Enter the elements\n");
  15. for (i = 0; i < n; ++i)

Tom 在 array.c 文件中添加了几行代码,Subversion 会在新添加的这几行代码前面添加 + 号标记,现在,他已经准备好提交他的代码。

  1. [tom@CentOS trunk]$ svn commit -m "Fix array overflow problem"

上面的命令将会产生下面的效果

  1. Sending trunk/array.c
  2. Transmitting file data .
  3. Committed revision 3.

Tom 的更改被成功得提交到了仓库中。

转载本站内容时,请务必注明来自W3xue,违者必究。
 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号