Tip of the Week Blog

Page 2 of 7

Subversion Tip of the Week

Intro to Automatic Properties 

Properties are a powerful and useful feature of Apache Subversion, but they can be easily overlooked. If you’re regularly using properties in your project, it’s a good idea to configure Subversion to add properties to new files automatically.

Subversion already sets some properties automatically: whenever you add a new file, it sets a value for the MIME type and decides whether the file is executable. You can extend this by leveraging Subversion’s automatic property setting feature “svn:auto-props.” With auto-props enabled, you can perform tasks such as automatically inserting keywords into text files and ensuring every file has EOLs that are consistent with the OS.

To enable auto-props:

1) Locate and open the config file on your local machine.

2) Scroll down to the [miscellany] section and uncomment the following line:

# enable-auto-props = yes

auto props

3) Just below this line, edit the ‘Section for configuring automatic properties’ text according to the properties you want to apply to your files.

Subversion Tip of the Week

Deleting a Branch

When something is deleted from Apache Subversion, it only disappears from the revision where it was deleted and all subsequent revisions. Deleting branches in Subversion has no effect on repository size, as it still exists in all previous revisions and can be viewed or recovered at any time. So, the question is why would you ever delete a branch?

1) House-keeping – regularly deleting branches reduces the clutter in the branches directory, and makes browsing the repository less confusing. When all abandoned branches are routinely deleted, a quick glance at the branches directory can tell you which branches are still active.

2) Following a merge – in some situations where you’ve finished working on a branch and merged the changes into the trunk, the branch may become completely redundant and you should consider deleting the branch to reduce clutter in the repository.

3) Following reintegration – the ‘–reintegrate’ command allows merging from a branch to the trunk, by replicating only the changes that are unique to that branch. A ‘–reintegrate’ merge uses Subversion’s merge-tracking features to calculate the correct revision ranges to use, and checks to ensure the branch is truly up-to-date with the latest changes in the trunk. These checks ensure the reintegration will not override work other team members have committed to the trunk.

Once a ‘–reintegration’ merge has been performed, the branch shouldn’t be used for development as any future reintegration will be interpreted as a trunk change by Subversion’s merge tracking. This will trigger an attempt to merge the branch-to-trunk merge back into the branch. To avoid this, the reintegrated branch should be deleted.

How to Delete a Branch

To delete a branch, run the ‘svn delete’ command alongside the URL of the branch and an appropriate log message. In this example, we are deleting the ‘bug fix branch.’

delete branch

Subversion Tip of the Week

Performing Shallow Checkouts

A standard Apache Subversion checkout includes the whole file and directory content of a specified repository. If you don’t require this level of content, you can perform a ‘shallow checkout’ that prevents Subversion from descending recursively through the repository, by restricting the depth of the checkout.

This is achieved by running the ‘svn checkout’ command as normal, but with an additional command:

  • –depth immediates: checkout the target and any of its immediate file or children. Note that the children themselves will be empty.
  • –depth files: checkout the target and any of its immediate file children.
  • –depth empty: checkout the target only. None of its file or children will be included in the operation.

In this example we are performing a shallow checkout on a ‘bug fix branch’ located within the branches folder, and specifying that only the immediate file children should be included (–depth files):

depth files

If you’re using SmartSVN, the cross-platform graphical client for Subversion you can set the checkout depth from the drop down menu when performing your checkout.

smartsvn depth

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

Subversion Tip of the Week

Solving Conflicts with SmartSVN

Conflicts can be tricky for Apache Subversion users, but SmartSVN comes with a dedicated ‘Conflict Solver’ that takes the pain out of resolving them. SmartSVN’s built-in Conflict Solver combines the freedom of a general, three-way-merge with the ability to detect and resolve any conflicts that occur during the development lifecycle.

To access this conflict solver, open the ‘Query’ menu and select ‘Conflict solver.’

conflict solver

The contents of the two conflicted files are displayed on the right and left text areas, and the differences between the left and right content is highlighted by coloured regions within the text views.

Once you have finished editing your files, open the ‘Modify’ menu and select ‘Mark Resolved’ to mark the conflicting file(s) as resolved. In this dialog, you can also opt to:

  • Leave as is – apply no further modifications to the resolved file.
  • Take old – accept the version in the working copy, as it was before the update or merge  was performed.
  • Take new – the pristine copy after the update or merge was performed.
  • Take working copy – the pristine copy before the update or merge was performed.

If you’re working with conflicted directories, you have the option to ‘Resolve files and subdirectories recursively.’  If selected, all conflicting files and directories within the selected directory will be resolved.

Note, you must resolve all the conflicts before you can commit the file(s)/directories.

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

Subversion Tip of the Week

Getting More Out of SVN Log

Apache Subversion‘s ‘SVN log’ is a useful command, allowing you to view the entire history of a directory, including who made changes to the directory, at what revision, the exact time, and any accompanying log messages.

In it’s most basic form, a simple ‘SVN log’ command will give you a printout of everything that’s changed in your entire directory, across all revisions:

svn log

However, there’s plenty of options if you need to tailor ‘SVN log’s output. If this is far too much information, you can specify a particular revision:

svn log -r14

svn log 2

Or, if you’re after all the available information about this particular revision, add the verbose option to your command:

svn log -r14 -v

svn log 3

Alternatively, if you do not need to review the log message, you can add the quiet option to suppress this piece of information:

svn log -r14 -q

svn log 4

Of course, both of these options can also be applied to an entire directory:

svn log -q
svn log -v

When the two options are combined, ‘svn log’ prints just the file names:

svn log -q -v

svn log 5

Looking for an easy-to-use cross platform Subversion client? Claim your free 30 day trial of SmartSVN Professional by visiting: www.smartsvn.com/download

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

Intro to Branching in Subversion

For developers who aren’t familiar with version control, getting to grips with Apache Subversion’s branching functionality can be daunting. But, when used correctly, branching can be one of Subversion’s most powerful and useful features.

What is a Branch?

Put simply, a branch is a line of development that exists independently of another line.

intro to branching

 

Every project is different, but there are some common reasons why developers might choose to create a branch:

  • To isolate development – This is often called a ‘concurrent development branch,’ and is the most common reason to create a branch.
  • To experiment with new technology – Branches can be used to test a new technology that might not necessarily become a part of the main branch. If the experiment works out, the new code can easily be merged into the trunk.
  • To tag a project and keep track of released code – This is often called a ‘release branch.’ Upon completing a release, it is a good idea to create a branch and tag it with a name that is meaningful to that release (for example, “release-2.0.”) This serves as an easy-to-retrieve record of how your code looked, in a certain release.
  • To fulfil a particular customer’s need – This is often called a ‘custom branch,’ and is useful when you need to modify your project for a particular customer’s requirements.

Creating Your First Branch

To create a new branch, use the ‘svn copy’ command followed by a log message (-m) and the URL of both the resource being branched, and the location where you want to create your new branch:

svn copy -m “Creating a new branch” folder-being-branched location-of-new-branch

In this example, we are creating a new branch called ‘bug fix branch’ inside the ‘branches’ folder, that will contain all the files in the trunk:

branching-from-the-command-line

Looking for a cross-platform graphical client for Apache Subversion? 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 HOUR DOM MONTH DOW
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