Suppose Jerry accidently modifies array.C document and he is getting compilation mistakes. Now he desires to throw away the modifications. In this example, 'revert' operation will assist. Revert operation will undo any neighborhood adjustments to a file or directory and clear up any conflicted states.
[jerry@CentOS trunk]$ svn status
Above command will produce the subsequent result.
M array.c
Let's try and make array as follows:
[jerry@CentOS trunk]$ make array
Above command will produce the following result.
cc array.c -o array
array.c: In function ‘main’:
array.c:26: error: ‘n’ undeclared (first use in this function)
array.c:26: error: (Each undeclared identifier is reported only once
array.c:26: error: for each function it appears in.)
array.c:34: error: ‘arr’ undeclared (first use in this function)
make: *** [array] Error 1
Jerry plays 'revert' operation on array.C record.
[jerry@CentOS trunk]$ svn revert array.c
Reverted 'array.c'
[jerry@CentOS trunk]$ svn status
[jerry@CentOS trunk]$
Now assemble the code.
[jerry@CentOS trunk]$ make array
cc array.c -o array
After the revert operation, his operating reproduction is lower back to its original nation. Revert operation can revert a unmarried file as well as a complete directory. To revert a directory, use -R alternative as proven under.
[jerry@CentOS project_repo]$ pwd
/home/jerry/project_repo
[jerry@CentOS project_repo]$ svn revert -R trunk
Till now, we've visible the way to revert modifications, which has been made to the working replica. But what if you need to revert a dedicated revision! Version Control System tool does not permit to delete history from the repository. We can best append history. It will manifest even if you delete documents from the repository. To undo an old revision, we have to opposite some thing modifications had been made inside the old revision after which dedicate a brand new revision. This is referred to as a opposite merge.
Let us suppose Jerry adds a code for linear seek operation. After verification he commits his changes.
[jerry@CentOS trunk]$ svn diff
Index: array.c
===================================================================
--- array.c (revision 21)
+++ array.c (working copy)
@@ -2,6 +2,16 @@
#define MAX 16
+int linear_search(int *arr, int n, int key)
+{
+ int i;
+
+ for (i = 0; i < n; ++i)
+ if (arr[i] == key)
+ return i;
+ return -1;
+}
+
void bubble_sort(int *arr, int n)
{
int i, j, temp, flag = 1;
[jerry@CentOS trunk]$ svn status
? array
M array.c
[jerry@CentOS trunk]$ svn commit -m "Added code for linear search"
Sending trunk/array.c
Transmitting file data .
Committed revision 22.
Jerry is curious about what Tom is doing. So he tests the Subversion log messages.
[jerry@CentOS trunk]$ svn log
The above command will produce the following result.
------------------------------------------------------------------------
r5 | tom | 2013-08-24 17:15:28 +0530 (Sat, 24 Aug 2013) | 1 line
Add binary search operation
------------------------------------------------------------------------
r4 | jerry | 2013-08-18 20:43:25 +0530 (Sun, 18 Aug 2013) | 1 line
Add function to accept input and to display array contents
After viewing the log messages, Jerry realizes that he did a extreme mistake. Because Tom already carried out binary search operation, that is better than the linear seek; his code is redundant, and now Jerry has to revert his modifications to the preceding revision. So, first discover the modern revision of the repository. Currently, the repository is at revision 22 and we must revert it to the previous revision, i.E. Revision 21.
[jerry@CentOS trunk]$ svn up
At revision 22.
[jerry@CentOS trunk]$ svn merge -r 22:21 array.c
--- Reverse-merging r22 into 'array.c':
U array.c
[jerry@CentOS trunk]$ svn commit -m "Reverted to revision 21"
Sending trunk/array.c
Transmitting file data .
Committed revision 23.