A Scenario
While writing this article, I realized that the draft for a second article and snapshots for the various commands were created, not in a private branch, but off a tag, MANU_01REVIEW_27FEB (i.e., my working copy was derived from this tag, and all commits were being done here):
$/opt/svn-1.4.3/bin/svn info /home/ram/svnarticle_rndtwo/ Path: /home/ram/svnarticle_rndtwo URL: file:///opt/samagdocs/tags/MANU_01REVIEW_27FEB Repository Root: file:///opt/samagdocs Repository UUID: d87b2b87-2545-461f-ae99-430b66f94c56 Revision: 43 Node Kind: directory Schedule: normal Last Changed Author: ram Last Changed Rev: 43 Last Changed Date: 2007-04-08 20:09:13 +0530 (Sun, 08 Apr 2007)
Consequently, I decided to create a new working copy directly from the trunk and name it samag-trunkwc. Then I merged the two trees, the trunk and the tag, into the newly created working copy.
The current directory is the new working copy:
$pwd /home/ram/samag-trunkwc
Here I merged the trunk and the tag to the working copy, samag-trunkwc. A letter is added by the merge command to indicate the status acquired by the file as a result of merge operation. See to the Collins-Sussman book for a detailed explanation of these letters.
$/opt/svn-1.4.3/bin/svn merge file:///opt/samagdocs/trunk \ file:///opt/samagdocs/tags/MANU_01REVIEW_27FEB/ D svn_article A svnfigs A svnfigs/svnserve-one-repo.conf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . U images/svn_move.png U images/svnignore_cmd.png . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A svnarticle_serone
The actual merge is not complete yet, because the changes made to the working copy are not committed to the repository.
The next example displays the status of the WC, post merge, and it looks like a lot of new files are due for addition (A+) and one file for deletion ("D+").
$/opt/svn-1.4.3/bin/svn status . A + svnfigs A + svnfigs/svnserve-one-repo.conf A + svnfigs/svnco-fromtag.output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . M images M images/svn_move.png . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A + svnarticle_serone D svn_article
After you commit the changes to the repo, the status is shown below:
$/opt/svn-1.4.3/bin/svn commit -m "merged the changes (branch copy), \ from tags/MANU_01REVIEW_27FEB" . Sending images Sending images/adding_newfiles.png Sending images/branch_create.png . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Deleting svn_article Adding svnarticle_serone Adding svnfigs Adding svnfigs/BASE.output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Committed revision 55.
As a result of merging the trees, one file has been removed from the current revision of the repo. Is there a way to recover the deleted file? Yes, it can be done, as the deleted file is available in older revisions of the repo. The procedure to recover the deleted file is shown below.
Let's first identify the revision of the repo in which the deleted file was available. We can do this with the svn log command. It is possible that the deleted file" was available in many revisions, but we are interested in the revision of the repo from which the latest version of the file can be resurrected.
$/opt/svn-1.4.3/bin/svn log --verbose . | more r38 | ram | 2007-02-27 23:02:48 +0530 (Tue, 27 Feb 2007) | 1 line Changed paths: M /trunk/svn_article final review comments updated r36 | ram | 2007-02-27 01:19:42 +0530 (Tue, 27 Feb 2007) | 1 line Changed paths: M /trunk/svn_article
We are interested in revision 38, as this is the repository from which we would be able to recover the file. This recovery is done via the svn copy command. After the copy, a new file is added to the WC and the changes then committed to the repository:
$pwd /home/ram/samag-trunkwc $/opt/svn-1.4.3/bin/svn copy -r 38 file:///opt/samagdocs/trunk/svn_article . A svn_article $/opt/svn-1.4.3/bin/svn commit -m "recovered first part of the article from old revision" . Adding svn_article Committed revision 56. $/opt/svn-1.4.3/bin/svn update . At revision 56. $/opt/svn-1.4.3/bin/svn info . Path: . URL: file:///opt/samagdocs/trunk Repository Root: file:///opt/samagdocs Repository UUID: d87b2b87-2545-461f-ae99-430b66f94c56 Revision: 56 Node Kind: directory Schedule: normal Last Changed Author: ram Last Changed Rev: 56 Last Changed Date: 2007-05-07 08:12:33 +0530 (Mon, 07 May 2007)