English 中文(简体)
SVN - Perform Changes
  • 时间:2024-12-22

SVN - Perform Changes


Previous Page Next Page  

Jerry checks out the latest version of the repository and starts working on a project. He creates array.c file inside the trunk directory.

[jerry@CentOS ~]$ cd project_repo/trunk/

[jerry@CentOS trunk]$ cat array.c

The above command will produce the following result.

#include <stdio.h>
#define MAX 16

int main(void) {
   int i, n, arr[MAX];
   printf("Enter the total number of elements: ");
   scanf("%d", &n);

   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;
}

He wants to test his code before commit.

[jerry@CentOS trunk]$ make array
cc     array.c   -o array

[jerry@CentOS trunk]$ ./array 
Enter the total number of elements: 5
Enter the elements
1
2
3
4
5
Array has following elements
|1| |2| |3| |4| |5| 

He compiled and tested his code and everything is working as expected, now it is time to commit changes.

[jerry@CentOS trunk]$ svn status
?       array.c
?       array

Subversion is showing ? in front of filenames because it doesn t know what to do with these files.

Before commit, Jerry needs to add this file to the pending change-pst.

[jerry@CentOS trunk]$ svn add array.c 
A         array.c

Let us check it with the status operation. Subversion shows A before array.c, it means, the file is successfully added to the pending change-pst.

[jerry@CentOS trunk]$ svn status
?       array
A       array.c

To store array.c file to the repository, use the commit command with -m option followed by commit message. If you omit -m option Subversion will bring up the text editor where you can type a multi-pne message.

[jerry@CentOS trunk]$ svn commit -m "Initial commit"
Adding         trunk/array.c
Transmitting file data .
Committed revision 2.

Now array.c file is successfully added to the repository, and the revision number is incremented by one.

Advertisements