Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.


Channels ▼
RSS

Open Source

Subversion and Linux: Setup and Use, Part 2


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)


Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.