Web Site
Developers

Regaining Control of Subversion*

Unintentionally Going Out of Sync

We introduced a new section to the site called Product News that required some quick customized appearance changes to make this content stand out. Hence, as a result of some rapid experimentation new additions were made to this site's production cascading style sheet. The imposed changes seemed to be acceptable, however, there has been another version of our css file that was awaiting approval to become the new production version. Thus, we now had incompatible versions that will have to be synchronized.

Of course, when I set out to correct the obvious problem I soon noted I might have introduced other defects by having versions of articles residing in the working copy, but not even ready either to be published or to be included in the next commit. There were other files that I wished to add to the new version, however, I did not want to resort to the revert command to bring in a single file or even several files into the source control. Finally, I discovered a number of files that should have been part of the last version. Shown below is my approach to solving these issues.

Root Cause

At the end of the commit and the subsequent checkout of the second version, it seemed the system was easy partner. So why worry when at worse I forgot to include a couple or at most a few files that I will eventually find? Well one reason is that unexpected changes in course can have consequences. Some of the methods I used to recover from such a change and corrections due to my own errors can be instructive. However, if you are part of a larger development group you might want to spend some time reading the documentation on Subversion branching (and merging). Nonetheless, from the little I read on that topic and the nature of my problems I would still resort to the direct change.

Perhaps a key to my problems is my tendency to commit only when forced to by the impending major update of the site. Hence, when falling behind it is easy to neglect some tasks. In another case, it is being too conscientious by introducing new source files prematurely. The latter caused me unnecessary worry. Nonetheless, I am uncertain if I was cognizant of the potential problem at this stage:

  :~/OST-1$ svn status howto/
  ?      howto/articles/HowTo-VersionControl-III.html 

This file was going to be part of the next site update, hence, it should not be part of the commit that was approaching. That is, I should have committed before saving this file within the working copy. The next status command I ran, was more complete than I expected, because I forgot to include a back slash to escape the question mark's attribute role in the grep portion of the command. So I was surprised seeing the modified lines:

  :~/OST-1$ svn status |egrep '^?.*'
  ?      pr
  ?      howto/articles/HowTo-VersionControl-III.html
  ?      ceo/articles/EU-climate-III.html
  M      ceo/articles/EU-climate-II.html
  M      ceo/articles/EU-climate-I.html
  M      css/style-sheet.css
  M      page-1/index.html
  M      page-2/index-2.html 

If I was not bothered by the first result, I certainly now knew the third climate article along with the map were items not ready for the next update, hence, they should not have been part of the current working copy. The pr directory was not a problem. The new Product News section mentioned at the start, needed to be added to the version control. In order to be certain that there were no extra files I checked the contents of the pr directory:

  :~/OST-1$  ls -l pr/news/
  total 40
  -rw-r--r-- 1   5604 2007-09-04 20:38 pr-Sandisk-2G-FlashDrive.html
  -rw-r--r-- 1   5595 2007-09-04 11:37 pr-Sandisk-2G-FlashDrive.html~
  -rw-r--r-- 1   3026 2007-09-04 10:41 pr-template.html
  -rw-r--r-- 1   3102 2007-09-04 10:35 pr-template.html~
  -rw-r--r-- 1   4487 2007-09-06 13:30 virtual_iron.html
  -rw-r--r-- 1   4793 2007-09-07 10:23 westminster.html 

That was fine, with all those included in the last version of the front page. As a precaution, I ran the status on the full project but sent it to a file. As I should have known there were no other changes or unknown files. The next task was adding the pr directory and its contents to the system:

  :~/OST-1$ svn add pr/
  A         pr
  A         pr/news
  A         pr/news/pr-template.html
  A         pr/news/pr-Sandisk-2G-FlashDrive.html
  A         pr/news/virtual_iron.html
  A         pr/news/westminster.html 

I think at this point it is telling to print the note I wrote to myself about some of the problems I saw and the worries I had:

  /* Only the version control article III is complete, and it is not part of this commit.
   
     Next the graphic and the EU climate article have not been published or near ready.
     However, if they were they would be added as individual entities.  I am taking the
     risk that they are not added as part of this commit and identified as arising from
     an unknown source.  I will see how it works when the commit is run. */ 

My next comment to myself actually under rated the style sheet problem:

  /* There is a bigger problem with the new style sheet that was updated and used in
     this version in haste, while another with large differences was still in a test
     server.  These changes must be identified and reconciled before the next version
     of the style sheet can be added for the following commit. */ 

My interest is in seeing what has been added to the current production version, that is the difference between the previous Subversion version and the current working copy (I will not show it completely):

  :~/OST-1$ svn diff css/style-sheet.css
  Index: css/style-sheet.css
  ===================================================================
  --- css/style-sheet.css (revision 1)
  +++ css/style-sheet.css (working copy)
  ...
  +#central-grouping-news  {
  +   text-align: center;
  +   color: #cb1741;
  +   font-size: 110%;
  +}
  +
  ...
  +#news-bands  {
  +   position: relative;
  +   text-align: justify;
  +   font-size: 11pt;
  +   width: 99%;
  +   height: auto;
  +   min-height: 50px;
  +   background-color:  #ADD8E6;
  +   color:  #000000;
  +   padding-left: .5%;
  +   padding-right: .5%;
  ...
  +} 

The new heading for the Product News text can be added immediately to the test version of the cascading style sheet. However, the news-bands portion conflicts with the test css file. The latter corrects for Safari 2.0 inability to properly process fractional percentage values[1.]. Therefore, it was obvious I would need to change the padding left and right values to a full percent value. Nonetheless, I had forgotten another change of the border values in the central div column I have to make certain that the width is proper, since I now remember it as 98% not the value shown[2.].

I had one more discovery. When I compared the articles on open source to the files in the Subversion system I came up well short of the number that should have been there. I downloaded files directly from the server into the version control and I added each, singly as a file as I had expected to do upon each update of the site. Here is an example:

  :~/OST-1$ svn add floss/articles/OSS-right_or_wrong.html
  A         floss/articles/OSS-right_or_wrong.html

Then I checked the status of the directory:

  :~/OST-1$ svn status floss/
  A      floss/articles/what_is_open_source_really.html
  A      floss/articles/why_deploy_oss.html
  A      floss/articles/OSSproduct_types.html
  A      floss/articles/OSS-right_or_wrong.html

No surprises here.

Ready to Run the Commit

I thought I knew enough to properly commit the changes as package that was published the previous week. Again as the limited rights user of the working copy I could not make the commit work. This time, however, changing to the sudo user with root rights did not suffice:

  # svn commit -m "Content for Early Sept - with some missed files"
  Sending        howto/HowTo-template.html
  svn: Commit failed (details follow):
  svn: Out of date: '/OST-1/howto/HowTo-template.html' in transaction '2-1'

This was preplexing, however, by checking all versions of this file it was determined that the one on the root copy was older than in the working copy. I think I even tried to copy the most recent version in manually, but that too had no effect. Following the rule, when all else fails: read the manual[3.] where the discussion about the system update command seemed to make some sense. I decided to take a chance and run this on the root copy, where a full copy of version 2 was taken. I show selected portions below:

  # svn update
  A    howto/images
  A    howto/images/Band-Closeup.gif
  ...  ...
  A    howto/articles
  A    howto/articles/HowTo-Browser-Compatibility-I-2.html
  ...  ...
  A    howto/articles/HowTo-VersionControl-I.html
  G    howto/HowTo-template.html
  A    ceo/images
  A    ceo/images/Heat-energy-use-2.jpg
  ...  ...
  A    ceo/articles
  A    ceo/articles/Why-Pick-On-GE.html
  ...  ...
  U    ceo/ceo-template-page.html
  A    floss/images
  A    floss/images/tom1.jpg
  ...  ...
  A    floss/articles
  A    floss/articles/OSS-Welcome.html
  ...  ...
  A    index/images
  A    index/images/OST2-small2-logo.gif
  ...  ...
  U    page-1/index.html
  U    page-2/index-2.html
  Updated to revision 2.

The interesting lines have the U and G designations, where the former means an updated file from the repository and G means a non-conflicting merge of code between the files. This time a commit yields nothing. So I ran the commit after moving to the user's working directory:

  # cd /path/to-user/OST-1/
  # svn commit -m "Content for Early Sept - with some missed files"
  Sending        ceo/articles/EU-climate-I.html
  Sending        ceo/articles/EU-climate-II.html
  Sending        css/style-sheet.css
  Adding         floss/articles/OSS-right_or_wrong.html
  Adding         floss/articles/OSSproduct_types.html
  Adding         floss/articles/what_is_open_source_really.html
  Adding         floss/articles/why_deploy_oss.html
  Sending        page-1/index.html
  Sending        page-2/index-2.html
  Adding         pr
  Adding         pr/news
  Adding         pr/news/pr-Sandisk-2G-FlashDrive.html
  Adding         pr/news/pr-template.html
  Adding         pr/news/virtual_iron.html
  Adding         pr/news/westminster.html
  Transmitting file data .............
  Committed revision 3.

We have a new version was committed successfully, containing only the newly added files and those few altered. Version control treats its users as adults allowing us to make our own errors, hence, the present but unidentified files were not forced into this latest version. One additional action was taken as the empowered user, an update was ran on sudo copy and brought up fully to version 3. Only afterward was the new working version checked out by the limited rights user:

  :~/OST-1$ svn checkout file:///etc/subversion/repos/OST-1
  A    OST-1/howto
  A    OST-1/howto/images
  ...  ...
  A    OST-1/howto/articles
  ...  ...
  A    OST-1/pr
  A    OST-1/pr/news
  ...  ...
  A    OST-1/ceo
  A    OST-1/ceo/images
  ...  ...
  A    OST-1/ceo/articles
  ...  ...
  A    OST-1/floss
  A    OST-1/floss/OSS-template.html
  A    OST-1/floss/images
  ...  ...
  A    OST-1/floss/articles
  ...  ...
  A    OST-1/index
  A    OST-1/index/images
  ...  ...
  A    OST-1/css
  A    OST-1/css/style-sheet.css
  A    OST-1/page-1
  A    OST-1/page-1/index.html
  A    OST-1/page-2
  A    OST-1/page-2/index-2.html
  A    OST-1/page-3
  Checked out revision 3.

What remains is to modify the code in the test version of the css file and bring in the few files published this next week. And that will successfully complete another cycle, despite my errors.

Another in the Series

How To: Coding html and css files by hand. Perhaps the first encounter using Subversion in a complete cycle went too easily and made me complacent. The non-linear changes and errors intoduced some complexities. Nonetheless, we seemed to have regained our composure while encountering other new, unexpected errors as part of the commit process. Now we know: we need to update the core version and commit within the working copy's directory. If we fail to find other errors and problems life will become boring, hence, we must move on to other topics despite this being no more than an introduction to the topic of source / version control systems.

Corrections, suggested extension or comments write: How-To-Guy. If the mailto does not work, use this: hcohen[-At-]bst-softwaredevs.com.

     © Herschel Cohen, All Rights Reserved

Return to Home or Tools Page
____________________________________________________________________

  1. It was already clear in the first article, Safari 2.0 had
     problems with precentage values.  Return

  2. Suspicion confirmed, new value for width is 98%.  Return

  3. Under the section "Resolving Conflicts (Merging Others' Changes)"
     the example of the update command was of interest.  Return

    * Originally published on the Open Source Today site September 18, 2007. Content may have been altered prior to being moved onto Web Site Developers.