Archive for the ‘Subversion’ Category

Microsoft Office and Subversion (Part 2)

Wednesday, November 14th, 2007

In Part 1, we worked out how you access your documents located in a Subversion repository.
In this part we will discuss several ideas how you could expose Subversion meta data, like version information, (last) author, date and so on in your document.
Currently, it is very annoying always to update version number. Most time it will be forgotten and the document is being published to third parties with wrong version number leading to confusion. Let Subversion take care on document properties.

We have two possibilities to expose Subversion information, direct and via Microsoft Office document properties and field operators.

“Direct” Exposure

This method is pretty straight forward. Just type in somewhere in your document following placeholders:

$Author:: $
$Rev:: $
$Date:: $

You can put one these entries in any place, header page or page header and/or footer are usual locations. By entering blanks between the double colon “::” and the last “$” you reserve space even in the binary formats of Microsoft Office.
After committing you document back into server, Subversion replaces each time the placeholders and it looks like this:

$Author:: neherr $
$Rev:: 150 $
$Date:: 2007-09-26 07:52:07 +0200 (Wed, 26 Sep 2007)$

It does not look nice but it is useful. If you like to reformat this ugly information after an update, you need to throw an eye on the next method for Subversion meta data exposure.

Hint Experienced Subversion users should not play with plain placeholders you normally use in text files, like “$Rev$”, i.e. without blanks to preserve space for Subversion data. After a commit your document is scrambled and you cannot read nor open it anymore.

Exposure through Microsoft Office Fields

Before we can use fields, we define document properties which Subversion updates with each commit.
Open Microsoft Office document properties dialog as shown on the right side.

I added the screen-shot for proud owners of the new Microsoft Office 2007. In the first weeks, most time spending not with writing documents but to search features and functions known from former versions but moved (hidden?) to new locations. You click on this round Office symbol on the top left corner and you will find the properties under the topic “Prepare”.

A big bar above of your document opens. Click on the “I” info button and select “Advanced Properties…”.

Owners of the “old” versions just open the “Properties” to be found in the “File…” menu.

advancedproperties.gif

Finally, finally, we landed in the right dialogue to define our properties.

Click on the “Summary” tab and enter the Subversion placeholder for author as shown, if the document author should be maintained by Subversion here.
Please be aware that Subversion’s understanding of author is the person who updated the document most recently.

fixedlength.gif

Next click on “Custom” tab and enter two new custom properties. Please have a look on the screen-shot on the right hand side.

The name you enter is up to you. Define type as “Text” and in value you enter the Subversion placeholder as described in first section of this blog.

With the following step we are using fields to show Subversion meta data information in our document.
Click somewhere in your document where you like to show Subversion meta data and enter <Ctrl>F9. A pair of bracket appears. Enter following between the two brackets:
My first SVN property shown in my document: { DOCPROPERTY Author \# MERGEFORMAT }.
Now the second follows: { DOCPROPERTY SVNRevision \# MERGEFORMAT }.

Now the third one: { DOCPROPERTY SVNLastUpdate \# MERGEFORMAT }.

The string after the “DOCPROPERTY” corresponds with the name of your custom property you entered above.
After you checked in your document select the entire document by pressing <Ctrl>A, et violà.

Instead of the field definition you see the field content, like this:

My first SVN property shown in my document: $author:: neherr $.
Now the second follows: Revision: $Rev:: 151 $.

Now the third one: Last change date: $Date:: 2007-09-26 23:01:48 +0200 (Wed, 26 Sep 2007#$.

Due to the fact that the data exposed in both methods looks pretty ugly, macros could be triggered to cleanup and format Subversion revision information.
For this purpose it is much better to check out blogs on Microsoft’s web site.

Best Wishes
Robert

Microsoft Office and Subversion (Part 1)

Tuesday, October 9th, 2007

Prerequisites

  • Good knowledge about Microsoft Windows and Windows Explorer
  • Intermediate to good knowledge about Microsoft Office
  • Access to an existing Subversion server instance with Autoversioning Commit enabled
  • Optional: TortoiseSVN has been installed on your computer

General

Subversion is the perfect storage for Microsoft Office documents

  • Accessing your storage runs either through http (https) or through nice Windows Explorer extension TortoiseSVN
  • Binary formats are handled very well and efficiently
  • Triggers released by your activities on Subversion allow defined and controlled way to disseminate information about changes
  • Each document or the folder containing these documents keeps arbitrary number of properties to store meta data about your document
  • Version numbers of your document could be projected directly into your document

In the subsequent blogs we will have a look on each of these topics more in detail.
With this blog we have a look how you work with Microsoft Office and Subversion.

Accessing Your Subversion Instance

“Straight”

This way to work with documents located in a Subversion repository is the easiest one you can imagine.
Just drop a URL into the open file dialogue which starts with “http://…” pointing you directly to a document in Subversion and start your work.
Each save will generate a new revision in Subversion. Please use this option sparsely especially if you are working in a network where bandwidth is a valuable resource.

lookmaanurl.gif

Check In/Out

By using TortoiseSVN you keep local copies on your desktop or laptop computer. If you are often offline or prefer workplaces outside office, this is your choice. Before you start please ask your project manager or system administrator for URL of your project.

Also make sure that you have installed TortoiseSVN on your computer. You can check this briefly by right clicking in the Microsoft Windows’ Desktop. See context menu on the right hand side highlighting the two menu entries to check presence of TortoiseSVN.

svnmenu.gif

 

Now browse to a folder where you like to put your documents into downloaded from your Subversion server and right-click on the folder which should be empty. Select “SVN Checkout…” and enter rhe URL provided by your system administrator or project manager identifying the location of your documents in the Subversion repository. Now Subversion uploads all data into the selected destination on your local hard disc and you are ready to start your work.

svncheckout.gif

 

Preparing Your Documents for Exposure of Subversion

Select all your documents in your local workspace. Right-click and select “Properties” in the bottom of the context menu. Select the “Subversion” tab. Now you see a lot of data related to Subversion. For the moment we are only interested in the button in the bottom labeled “Properties”. That is next stop of our journey. Click on it and you see a dialogue which let you add some meta data for your document.
svnproperties.gif

 

With the help of this dialogue box we add Subversion meta data to selected documents. This could be any kind of tag/value combination.

Subversion itself uses special keywords which let you influence Subversion’s behavior on the server or locally. If your organization is considering Subversion as document repository use these Subversion properties to store additional data which should not be kept in the document itself. In a later blog we will show to expose such kind arbitrary data in your Microsoft Office documents.

Now let us move on and prepare us for the next part of this blog.

 

In the properties dialogue click on “Add…” button opening a windows which let you add your tag/value keys. TortoiseSVN offers some of the special keywords in the drop-down menu. Please select “svn:keywords”, that is the name of the property.

Now enter the property value as shown in the screen-shot, “Date Revision Author”. The sequence of these keywords is irrelevant.
Confirm and close all dialogues by pressing OK.

svneditproperties.gif

 

 

In the subsequent step you will learn how to write your changes back into the server. Another time you right-click on your working directory or if you like on single files and select the menu item “Commit…”.

Commit writes all changes back to the Subversion repository. If the transaction could not be performed Subversion’s repository reverts the full transaction and does not keep the server in an unpredictable state.

A successful commit will be acknowledged by Subversion by returning a “Revision” number. This revision number let you identify the status of your data in the timeline of your work.

Numbers like this are pretty hard to remember. Subversion also allows attaching a message to each commit. This is your log or audit trail to review changes.

 

svncommit.gif

The upcoming dialogue shows status information during data transmission back the server. If the transaction succeeds, you will see message similar to the one in the screen-shot

.svncommitfisished.gif

 

Now stay tuned for the next part in this blog series when we pull in the Subversion revision meta data, like author, revision number, commit message or date into the document each time when we commit our changes.

Best Wishes
Robert