Tag Archive for 'tip of the week'

Page 2 of 7

Subversion Tip of the Week

Intro to Subversion Switch

When working with branches, Apache Subversion provides a useful shortcut for switching your current working copy to a new branch’s location, without the overhead of checking out a fresh working copy containing the targeted branch. Leveraging this functionality, it’s possible to build a working copy that contains data from a range of repository locations, although these locations must originate from the same repository.

To achieve this, enter the ‘svn switch’ command, followed by the URL you wish to switch to:

svn switch repository-URL

svn switch

Users of SmartSVN, the cross-platform graphical client for SVN, can perform a switch simply by opening the ‘Modify’ menu and selecting the ‘Switch…’ option.

svn switch 2

In the subsequent dialog, enter the new URL – or select the ‘Browse’ option to view the different branches – and specify whether you’re switching to the latest revision (HEAD) or a particular revision number.

svn switch 3

Tip. Use the ‘Select…’ button to view more information about the different revisions.

Not yet started with SmartSVN? Claim your free 30 day trial at www.smartsvn.com/download



Subversion Tip of the Week

Backing up Your Subversion Data

No matter how clued up you are on Apache Subversion, disasters do happen, so it’s important to make regular backups of your repository data. There are several options for creating a backup:

1) Incremental backup – creates a copy of all the changes that occurred since the last backup. To perform an incremental backup, you must specify a “starting_revision” revision number:

svnadmin dump {repository} -r {starting_revision} -incremental.

This creates a dump file with information about the revisions that took place between the “starting_revision” and the latest revision.

2) Full Backup – this is essentially a copy of the entire repository, and it can be performed by running the following command:

svnadmin hotcopy {repository} {destination}

Alternatively, a full dump can be performed using the ‘hot backup’ script located in the tools/backup directory:

The hot-backup.py {repository} {destination}

3) Backing up with SmartSVN

If you’re using SmartSVN, the popular, cross-platform graphical client, the built-in ‘Export Backup’ functionality makes it quick and easy to create a backup of your files and directories.

1) To create a backup, select the ‘Export’ option from the ‘Query’ menu. This will open the ‘Export Backup’ dialog.

In this dialog, ‘Relative To’ is the common root of all files to be exported. Depending on the selection of files or directories, the ‘Export’ option will either display the number of files being exported or a ‘All files and directories’ message.

2) You can choose to export into either ‘zip-file’ or ‘Into directory.’ In both instances, you must specify the location where the backup will be created.

3) Optionally, you can decide to ‘Include Ignored files’ and ‘Include Ignored Directories.’ Note, the second option includes all the items in the ignored directories.

4) Once you are happy with the information you have entered, click ‘Export’ to create your backup.

Remember, you can claim your 30 day free trial of SmartSVN Professional now.


Subversion Tip of the Week

Polling Subversion with Jenkins

There are many advantages Jenkins can offer Apache Subversion users, one of which is the option of automatically polling Subversion repositories for changes, and creating a new build whenever changes are detected. In this week’s tip, we’ll show you how to configure Jenkins to automatically poll an uberSVN repository.

(Note, this tutorial requires Jenkins to be installed in uberSVN. See Getting Started with Jenkins in uberSVN for a step-by-step guide to getting Jenkins up and running.)

1. Open the ‘Jenkins’ tab and select the ‘New Job’ option from the left-hand menu.

2. Enter a Name for your job and indicate whether you are wanting to Copy Existing Job. Click ‘Ok.’

3. You will be taken to the ‘Configure’ screen. Enter a description for your job and select ‘Subversion’ as the source code management option. You will then be asked to enter the URL of the repository you wish to link the job to.

4. Under ‘Build Triggers’ select ‘Poll SCM.’ In the ‘Schedule’ text box, enter how often you want Jenkins to poll the repository. You can specify the frequency that Jenkins will poll Subversion, using the following format:

MINUTE: Minutes within the hour (0-59)
HOUR: The hour of the day (0-23)
DOM: The day of the month (1-31)
MONTH: The month (1-12)
DOW: The day of the week (0-7) where 0 and 7 are Sunday.

@annually, @yearly, @monthly, @weekly, @daily, @midnight, and @hourly are also supported.

5. Click ‘Save’ and Jenkins will begin automatically polling your Subversion repository at the specified intervals.

Not yet started with uberSVN? It’s free to download and free to use. Visit http://www.ubersvn.com/ now to get started.

Subversion Tip of the Week

SmartSVN Quickstart

In Apache Subversion, the basic workcycle follows the ‘checkout-edit-update-commit’ format.

In this week’s tip, we get you off to a flying start with SmartSVN, the popular graphical client for Subversion, by covering the entire workcycle in three simple steps.

Step One: Perform a Checkout

1) Open the ‘Project’ menu and select ‘Check Out…’

2) Enter the URL of the repository you wish to checkout. Select ‘Next.’

3) Select the directory to checkout. If you want to checkout a revision other than Head, select the ‘Show Revision’ button and specify a revision number.

4) When you are happy with the information you’ve entered, select ‘Next.’

5) In the subsequent dialog, enter the local directory where you’ll store your working copy. Select the checkout depth, and click ‘Next.’

6) Choose whether to checkout a working copy or export files only. Select ‘Finish.’

7) SmartSVN will perform the checkout. You can now work on the files and folders in your newly-created working copy using SmartSVN.

Step Two: Perform an Update

Before you commit your changes back to the repository, it’s good practice to perform an ‘SVN Update.’ This is made easy with SmartSVN, simply press the ‘update’ button in the toolbar to get started.

In the subsequent dialog, specify which revision you wish to update to (default is the Head) and confirm the update.

Step Three: Perform Your Commit

Perform a commit by selecting the ‘Commit’ button from the toolbar.

Enter an appropriate log message and confirm the commit.

Looking for a cross-platform graphical client for your Subversion project? A free 30 day trial of SmartSVN Professional is available now. Find out more about SmartSVN at www.smartsvn.com

Subversion Tip of the Week

Advanced Subversion Polling with Jenkins

It’s common practice to work on different projects simultaneously, but with so much going on it’s easy to lose track of where files originated, and what version is being used by which project. Thankfully, Jenkins supports file fingerprinting, which allows you to see exactly when and where your files are being produced and used. Once you’ve configured a Jenkins job to poll Subversion, setting up file fingerprinting is made easy with uberSVN.

1. Select the ‘Jenkins’ tab, followed by the Jenkins job you previously setup to poll Subversion.

2. Select the ‘Configure’ option.

3. Select the ‘Record fingerprints of files to track usage’ option and specify which files to track in the ‘Files to fingerprint’ text box. In this example, trunk/*.zip will track all .zip files in the trunk.

5. Make some changes to the files earmarked for fingerprinting, and commit those changes as normal.

6. Open the build report in Jenkins and select ‘See Fingerprints.’

7. This screen will display some basic details about the tracked files. To drill down into the information on any file, select the ‘more details’ link.

uberSVN is free to download and free to use. Visit http://www.ubersvn.com/ now to download your copy.

Subversion Tip of the Week

Updating to a Particular Revision From the Command Line

When updating your working copy in Apache Subversion, you usually run the ‘SVN Update’ command and update to the HEAD revision. However, in some instances you may need to update your working copy to a particular revision – or even revert to a previous revision. This is achieved by running the ‘SVN Update’ command and specifying your target revision with the -r command:

svn update -r revision-number

You working copy will now be at the specified revision! In addition, there are several commands that you may find useful when targeting a particular, non-HEAD revision:

1) Find out which revision you’re currently at:

svn log -q -r BASE

2) Find out which revision is the HEAD:

svn log -q -r HEAD

3) See what’s changed between your working copy revision and HEAD:

svn log -r BASE:HEAD

Subversion Tip of the Week

Creating Your First Apache Subversion Branch

The concept of branching can strike fear into the hearts of Apache Subversion users, but when used correctly Subversion’s branching functionality is a powerful tool. In this week’s tip, we provide an intro to branching, by showing you how to create your first branch.

There are several ways to create a branch, but the ‘svn copy’ command is useful as it retains the folder’s history prior to the branch being created.

Tip. While it is possible to manually create a new file, copy your files over by hand and then commit this to the repository, this new branch will have no history prior to its creation.

To create your first branch in Subversion, use the ‘svn copy’ command followed by the file(s) you want to copy to the branch, and the location and filename of the branch you wish to create:

svn copy (working-copy-path/trunk) (working-copy-path/branches/name-of-branch)

In this example, we are copying all the contents of the trunk into a branch called ‘bugfix branch 1’

Now when you explore your working copy, you will notice a new file has been created – this is your new branch!

Tip. In Subversion branches and tags are effectively the same thing – a copy of an existing folder and its contents, in a new location within the same repository. The difference is all in the way you handle branches and tags, so it’s important to work out a sane project structure before you start branching.

Subversion Tip of the Week

Locking Files from the Subversion Command Line

Apache Subversion is built around the ‘copy-modify-merge’ model, but you can enforce a ‘lock-modify-unlock’ model if necessary. This can be useful when you’re editing files that cannot be easily merged, for example image files or large binary files.

Creating a Lock

To create a lock, use the ‘svn lock’ command followed by the location and name of the file you wish to lock:

svn lock (working-copy-path/filename)

Keep your colleagues in the loop by adding a log message explaining why you have locked the file. Log messages can be added using the -m switch:

svn lock (working-copy-path/filename) -m “log message”

In this example, we are locking an image file called ‘Logo’ with the log message “Working on logo.”

You can now make changes to the file on your local machine, confident that no one else is committing changes to the repository. Once you have finished modifying the file, you can unlock it using the ‘svn unlock’ command:

svn unlock (working-copy-path/filename)

In this example, we are unlocking the ‘Logo’ file from earlier:

Tip: when you commit back to the repository all locks are automatically released as part of the commit transaction. If you wish to commit without releasing any locks you can use the ‘–no-unlock’ switch to explicitly tell Subversion to maintain the locks:

svn commit –no-unlock (working-copy-path) -m “log message”

In this example we are committing to the repository without lifting the lock, and with the log message “initial draft of logo.”

Subversion Tip of the Week

The ‘SVN Diff’ Command

‘SVN Diff’ is a command for highlighting the differences between two paths. This is useful in a number of common scenarios:

1) Comparing versions of the same file, in different locations

Your project may contain different versions of the same file, for example one version in the trunk and one in a branch. To flag up the differences between the two versions, use the following command:

svn diff (repository-URL/trunk/filename) (repository-URL/branches/filename)

In this example, we are comparing a file called ‘Admin Guide’ that appears in both the trunk and in a branch called ‘Admin Text.’

This will list information such as the revision the file is at in both the trunk and the branch, alongside a print-out of the differences.

Tip. If you see the following error message when entering the ‘svn diff’ command:

OPTIONS of (repository URL) 200 OK (repository URL)

It usually means you entered the repository URL incorrectly – go back and check for typos!

2) Comparing your project/files at different revisions

As Apache Subversion remembers every change committed to the repository, it is possible to compare specific files, or even your whole project, at different revisions.

To compare two revisions of your project, the following command can be used:

svn diff (repository-URL) -r(Revision):(Revision)

In this example, we are comparing revision 5 of our repository with the head revision.

If you want to compare the differences between two revisions of a specific file, you simply add the location of the file and the filename to your command:

svn diff (repository-URL/file-path/filename) -r(Revision):(Revision)

In this example, we’re comparing revisions 8 and 10 of a text file named ‘Notes,’ which is located in the trunk:

Tip. The ‘SVN Diff’ command ignores the ancestry of files by default, to alter this add the ‘–notice-ancestry’ switch.

Subversion Tip of the Week

In the world of the busy software developer, it’s easy to lose track of what you’ve been working on. In this week’s tip, we’ll share some useful commands for getting more information on your Apache Subversion project.

  • Current state of your SVN installation

The ‘svn –version’ command is useful for viewing information about the current state of your Apache Subversion installation. When entered, it lists the version number of your installation, and all the repository access modules.

Tip. If you just want to double-check what version of Subversion you’re running, the –quiet switch can be used to suppress information about repository access modules.

  •  View the entire project’s history

Log messages are an easy way to get an overview of your project. The ‘SVN log’ command, followed by the working copy’s location, brings up the entire history of your log messages.

Tip. The –verbose switch can be used to print the affected paths of each log message:

Remember that the latest Apache Subversion binaries can be downloaded at http://www.wandisco.com/subversion/download