SVN Perform Changes

Advertisements


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

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

[jerry@CentOS trunk]$ cat array.c

Above command will produce 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\n");

   for (i = 0; i < n; ++i)
      scanf("%d", &arr[i]);

   printf("Array has following elements\n");
   for (i = 0; i < n; ++i)
      printf("|%d| ", arr[i]);
   
   printf("\n");

   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's time to commit changes.

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

Subversion is showing ? infront 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-list.

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

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

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

To store array.c file to the repository use commit command with -m option followed by commit message. If you omit -m option Subversion will bring up text editor where you can type a multi-line 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 revision number is incremented by one.



Advertisements
Advertisements