5. Subversion Primer

New committers are assumed to already be familiar with the basic operation of Subversion. If not, start by reading the Subversion Book.

5.1. Introduction

The FreeBSD source repository switched from CVS to Subversion on May 31st, 2008. The first real SVN commit is r179447.

The FreeBSD doc/www repository switched from CVS to Subversion on May 19th, 2012. The first real SVN commit is r38821.

The FreeBSD ports repository switched from CVS to Subversion on July 14th, 2012. The first real SVN commit is r300894.

Subversion can be installed from the FreeBSD Ports Collection by issuing these commands:

# pkg install subversion

5.2. Getting Started

There are a few ways to obtain a working copy of the tree from Subversion. This section will explain them.

5.2.1. Direct Checkout

The first is to check out directly from the main repository. For the src tree, use:

% svn checkout svn+ssh://repo.freebsd.org/base/head /usr/src

For the doc tree, use:

% svn checkout svn+ssh://repo.freebsd.org/doc/head /usr/doc

For the ports tree, use:

% svn checkout svn+ssh://repo.freebsd.org/ports/head /usr/ports

Note:

Though the remaining examples in this document are written with the workflow of working with the src tree in mind, the underlying concepts are the same for working with the doc and the ports tree. Ports related Subversion operations are listed in Section 20, “Ports Specific FAQ”.

The above command will check out a CURRENT source tree as /usr/src/, which can be any target directory on the local filesystem. Omitting the final argument of that command causes the working copy, in this case, to be named head, but that can be renamed safely.

svn+ssh means the SVN protocol tunnelled over SSH. The name of the server is repo.freebsd.org, base is the path to the repository, and head is the subdirectory within the repository.

If your FreeBSD login name is different from the login name used on the local machine, either include it in the URL (for example svn+ssh://jarjar@repo.freebsd.org/base/head), or add an entry to ~/.ssh/config in the form:

Host repo.freebsd.org
	User jarjar

This is the simplest method, but it is hard to tell just yet how much load it will place on the repository.

Note:

The svn diff does not require access to the server as SVN stores a reference copy of every file in the working copy. This, however, means that Subversion working copies are very large in size.

5.2.2. RELENG_* Branches and General Layout

In svn+ssh://repo.freebsd.org/base, base refers to the source tree. Similarly, ports refers to the ports tree, and so on. These are separate repositories with their own change number sequences, access controls and commit mail.

For the base repository, HEAD refers to the -CURRENT tree. For example, head/bin/ls is what would go into /usr/src/bin/ls in a release. Some key locations are:

  • /head/ which corresponds to HEAD, also known as -CURRENT.

  • /stable/n which corresponds to RELENG_n.

  • /releng/n.n which corresponds to RELENG_n_n.

  • /release/n.n.n which corresponds to RELENG_n_n_n_RELEASE.

  • /vendor* is the vendor branch import work area. This directory itself does not contain branches, however its subdirectories do. This contrasts with the stable, releng and release directories.

  • /projects and /user feature a branch work area. As above, the /user directory does not contain branches itself.

5.2.3. FreeBSD Documentation Project Branches and Layout

In svn+ssh://repo.freebsd.org/doc, doc refers to the repository root of the source tree.

In general, most FreeBSD Documentation Project work will be done within the head/ branch of the documentation source tree.

FreeBSD documentation is written and/or translated to various languages, each in a separate directory in the head/ branch.

Each translation set contains several subdirectories for the various parts of the FreeBSD Documentation Project. A few noteworthy directories are:

  • /articles/ contains the source code for articles written by various FreeBSD contributors.

  • /books/ contains the source code for the different books, such as the FreeBSD Handbook.

  • /htdocs/ contains the source code for the FreeBSD website.

5.2.4. FreeBSD Ports Tree Branches and Layout

In svn+ssh://repo.freebsd.org/ports, ports refers to the repository root of the ports tree.

In general, most FreeBSD port work will be done within the head/ branch of the ports tree which is the actual ports tree used to install software. Some other key locations are:

  • /branches/RELENG_n_n_n which corresponds to RELENG_n_n_n is used to merge back security updates in preparation for a release.

  • /tags/RELEASE_n_n_n which corresponds to RELEASE_n_n_n represents a release tag of the ports tree.

  • /tags/RELEASE_n_EOL represents the end of life tag of a specific FreeBSD branch.

5.3. Daily Use

This section will explain how to perform common day-to-day operations with Subversion.

5.3.1. Help

SVN has built in help documentation. It can be accessed by typing:

% svn help

Additional information can be found in the Subversion Book.

5.3.2. Checkout

As seen earlier, to check out the FreeBSD head branch:

% svn checkout svn+ssh://repo.freebsd.org/base/head /usr/src

At some point, more than just HEAD will probably be useful, for instance when merging changes to stable/7. Therefore, it may be useful to have a partial checkout of the complete tree (a full checkout would be very painful).

To do this, first check out the root of the repository:

% svn checkout --depth=immediates svn+ssh://repo.freebsd.org/base

This will give base with all the files it contains (at the time of writing, just ROADMAP.txt) and empty subdirectories for head, stable, vendor and so on.

Expanding the working copy is possible. Just change the depth of the various subdirectories:

% svn up --set-depth=infinity base/head
% svn up --set-depth=immediates base/release base/releng base/stable

The above command will pull down a full copy of head, plus empty copies of every release tag, every releng branch, and every stable branch.

If at a later date merging to 7-STABLE is required, expand the working copy:

% svn up --set-depth=infinity base/stable/7

Subtrees do not have to be expanded completely. For instance, expanding only stable/7/sys and then later expand the rest of stable/7:

% svn up --set-depth=infinity base/stable/7/sys
% svn up --set-depth=infinity base/stable/7

Updating the tree with svn update will only update what was previously asked for (in this case, head and stable/7; it will not pull down the whole tree.

5.3.3. Anonymous Checkout

It is possible to anonymously check out the FreeBSD repository with Subversion. This will give access to a read-only tree that can be updated, but not committed back to the main repository. To do this, use:

% svn co https://svn.FreeBSD.org/base/head /usr/src

More details on using Subversion this way can be found in Using Subversion.

5.3.4. Updating the Tree

To update a working copy to either the latest revision, or a specific revision:

% svn update
% svn update -r12345

5.3.5. Status

To view the local changes that have been made to the working copy:

% svn status

To show local changes and files that are out-of-date do:

% svn status --show-updates

5.3.6. Editing and Committing

SVN does not need to be told in advance about file editing.

To commit all changes in the current directory and all subdirectories:

% svn commit

To commit all changes in, for example, lib/libfetch/ and usr/bin/fetch/ in a single operation:

% svn commit lib/libfetch usr/bin/fetch

There is also a commit wrapper for the ports tree to handle the properties and sanity checking the changes:

% /usr/ports/Tools/scripts/psvn commit

5.3.7. Adding and Removing Files

Note:

Before adding files, get a copy of auto-props.txt (there is also a ports tree specific version) and add it to ~/.subversion/config according to the instructions in the file. If you added something before reading this, use svn rm --keep-local for just added files, fix your config file and re-add them again. The initial config file is created when you first run a svn command, even something as simple as svn help.

Files are added to a SVN repository with svn add. To add a file named foo, edit it, then:

% svn add foo

Note:

Most new source files should include a $FreeBSD$ string near the start of the file. On commit, svn will expand the $FreeBSD$ string, adding the file path, revision number, date and time of commit, and the username of the committer. Files which cannot be modified may be committed without the $FreeBSD$ string.

Files can be removed with svn remove:

% svn remove foo

Subversion does not require deleting the file before using svn rm, and indeed complains if that happens.

It is possible to add directories with svn add:

% mkdir bar
% svn add bar

Although svn mkdir makes this easier by combining the creation of the directory and the adding of it:

% svn mkdir bar

Like files, directories are removed with svn rm. There is no separate command specifically for removing directories.

% svn rm bar

5.3.8. Copying and Moving Files

This command creates a copy of foo.c named bar.c, with the new file also under version control and with the full history of foo.c:

% svn copy foo.c bar.c

This is usually preferred to copying the file with cp and adding it to the repository with svn add because this way the new file does not inherit the original one's history.

To move and rename a file:

% svn move foo.c bar.c

5.3.9. Log and Annotate

svn log shows revisions and commit messages, most recent first, for files or directories. When used on a directory, all revisions that affected the directory and files within that directory are shown.

svn annotate, or equally svn praise or svn blame, shows the most recent revision number and who committed that revision for each line of a file.

5.3.10. Diffs

svn diff displays changes to the working copy. Diffs generated by SVN are unified and include new files by default in the diff output.

svn diff can show the changes between two revisions of the same file:

% svn diff -r179453:179454 ROADMAP.txt

It can also show all changes for a specific changeset. This command shows what changes were made to the current directory and all subdirectories in changeset 179454:

% svn diff -c179454 .

5.3.11. Reverting

Local changes (including additions and deletions) can be reverted using svn revert. It does not update out-of-date files, but just replaces them with pristine copies of the original version.

5.3.12. Conflicts

If an svn update resulted in a merge conflict, Subversion will remember which files have conflicts and refuse to commit any changes to those files until explicitly told that the conflicts have been resolved. The simple, not yet deprecated procedure is:

% svn resolved foo

However, the preferred procedure is:

% svn resolve --accept=working foo

The two examples are equivalent. Possible values for --accept are:

  • working: use the version in your working directory (which one presumes has been edited to resolve the conflicts).

  • base: use a pristine copy of the version you had before svn update, discarding your own changes, the conflicting changes, and possibly other intervening changes as well.

  • mine-full: use what you had before svn update, including your own changes, but discarding the conflicting changes, and possibly other intervening changes as well.

  • theirs-full: use the version that was retrieved when you did svn update, discarding your own changes.

5.4. Advanced Use

5.4.1. Sparse Checkouts

SVN allows sparse, or partial checkouts of a directory by adding --depth to a svn checkout.

Valid arguments to --depth are:

  • empty: the directory itself without any of its contents.

  • files: the directory and any files it contains.

  • immediates: the directory and any files and directories it contains, but none of the subdirectories' contents.

  • infinity: anything.

The --depth option applies to many other commands, including svn commit, svn revert, and svn diff.

Since --depth is sticky, there is a --set-depth option for svn update that will change the selected depth. Thus, given the working copy produced by the previous example:

% cd ~/freebsd
% svn update --set-depth=immediates .

The above command will populate the working copy in ~/freebsd with ROADMAP.txt and empty subdirectories, and nothing will happen when svn update is executed on the subdirectories. However, this command will set the depth for head (in this case) to infinity, and fully populate it:

% svn update --set-depth=infinity head

5.4.2. Direct Operation

Certain operations can be performed directly on the repository without touching the working copy. Specifically, this applies to any operation that does not require editing a file, including:

  • log, diff

  • mkdir

  • remove, copy, rename

  • propset, propedit, propdel

  • merge

Branching is very fast. This command would be used to branch RELENG_8:

% svn copy svn+ssh://repo.freebsd.org/base/head svn+ssh://repo.freebsd.org/base/stable/8

This is equivalent to these commands which take minutes and hours as opposed to seconds, depending on your network connection:

% svn checkout --depth=immediates svn+ssh://repo.freebsd.org/base
% cd base
% svn update --set-depth=infinity head
% svn copy head stable/8
% svn commit stable/8

5.4.3. Merging with SVN

This section deals with merging code from one branch to another (typically, from head to a stable branch).

Note:

In all examples below, $FSVN refers to the location of the FreeBSD Subversion repository, svn+ssh://repo.freebsd.org/base/.

5.4.3.1. About Merge Tracking

From the user's perspective, merge tracking information (or mergeinfo) is stored in a property called svn:mergeinfo, which is a comma-separated list of revisions and ranges of revisions that have been merged. When set on a file, it applies only to that file. When set on a directory, it applies to that directory and its descendants (files and directories) except for those that have their own svn:mergeinfo.

It is not inherited. For instance, stable/6/contrib/openpam/ does not implicitly inherit mergeinfo from stable/6/, or stable/6/contrib/. Doing so would make partial checkouts very hard to manage. Instead, mergeinfo is explicitly propagated down the tree. For merging something into branch/foo/bar/, these rules apply:

  1. If branch/foo/bar/ does not already have a mergeinfo record, but a direct ancestor (for instance, branch/foo/) does, then that record will be propagated down to branch/foo/bar/ before information about the current merge is recorded.

  2. Information about the current merge will not be propagated back up that ancestor.

  3. If a direct descendant of branch/foo/bar/ (for instance, branch/foo/bar/baz/) already has a mergeinfo record, information about the current merge will be propagated down to it.

If you consider the case where a revision changes several separate parts of the tree (for example, branch/foo/bar/ and branch/foo/quux/), but you only want to merge some of it (for example, branch/foo/bar/), you will see that these rules make sense. If mergeinfo was propagated up, it would seem like that revision had also been merged to branch/foo/quux/, when in fact it had not been.

5.4.3.2. Selecting the Source and Target Branch When Merging

Merging to stable/ branches should originate from head/. For example:

% svn merge -c r123456 ^/head/ stable/11
% svn commit stable/11

Merges to releng/ branches should always originate from the corresponding stable/ branch. For example:

% svn merge -c r123456 ^/stable/11  releng/11.0
% svn commit releng/11.0

Note:

Committers are only permitted to commit to the releng/ branches during a release cycle after receiving approval from the Release Engineering Team, after which only the Security Officer may commit to a releng/ branch for a Security Advisory or Errata Notice.

All merges are merged to and committed from the root of the branch. All merges look like:

% svn merge -c r123456 ^/head/ checkout
% svn commit checkout

Note that checkout must be a complete checkout of the branch to which the merge occurs.

% svn merge -c r123456 ^/stable/10 releng/10.0
5.4.3.3. Preparing the Merge Target

Due to the mergeinfo propagation issues described earlier, it is very important to never merge changes into a sparse working copy. Always use a full checkout of the branch being merged into. For instance, when merging from HEAD to 7, use a full checkout of stable/7:

% cd stable/7
% svn up --set-depth=infinity

The target directory must also be up-to-date and must not contain any uncommitted changes or stray files.

5.4.3.4. Identifying Revisions

Identifying revisions to be merged is a must. If the target already has complete mergeinfo, ask SVN for a list:

% cd stable/6/contrib/openpam
% svn mergeinfo --show-revs=eligible $FSVN/head/contrib/openpam

If the target does not have complete mergeinfo, check the log for the merge source.

5.4.3.5. Merging

Now, let us start merging!

5.4.3.5.1. The Principles

For example, To merge:

  • revision $R

  • in directory $target in stable branch $B

  • from directory $source in head

  • $FSVN is svn+ssh://repo.freebsd.org/base

Assuming that revisions $P and $Q have already been merged, and that the current directory is an up-to-date working copy of stable/$B, the existing mergeinfo looks like this:

% svn propget svn:mergeinfo -R $target
$target - /head/$source:$P,$Q

Merging is done like so:

% svn merge -c$R $FSVN/head/$source $target

Checking the results of this is possible with svn diff.

The svn:mergeinfo now looks like:

% svn propget svn:mergeinfo -R $target
$target - head/$source:$P,$Q,$R

If the results are not exactly as shown, assistance may be required before committing as mistakes may have been made, or there may be something wrong with the existing mergeinfo, or there may be a bug in Subversion.

5.4.3.5.2. Practical Example

As a practical example, consider this scenario. The changes to netmap.4 in r238987 are to be merged from CURRENT to 9-STABLE. The file resides in head/share/man/man4. According to Section 5.4.3, “Merging with SVN, this is also where to do the merge. Note that in this example all paths are relative to the top of the svn repository. For more information on the directory layout, see Section 5.2.2, “RELENG_* Branches and General Layout”.

The first step is to inspect the existing mergeinfo.

% svn propget svn:mergeinfo -R stable/9/share/man/man4

Take a quick note of how it looks before moving on to the next step; doing the actual merge:

% svn merge -c r238987 svn+ssh://repo.freebsd.org/base/head/share/man/man4 stable/9/share/man/man4
--- Merging r238987 into 'stable/9/share/man/man4':
U    stable/9/share/man/man4/netmap.4
--- Recording mergeinfo for merge of r238987 into
'stable/9/share/man/man4':
 U   stable/9/share/man/man4

Check that the revision number of the merged revision has been added. Once this is verified, the only thing left is the actual commit.

% svn commit stable/9/share/man/man4
5.4.3.6. Precautions Before Committing

As always, build world (or appropriate parts of it).

Check the changes with svn diff and svn stat. Make sure all the files that should have been added or deleted were in fact added or deleted.

Take a closer look at any property change (marked by a M in the second column of svn stat). Normally, no svn:mergeinfo properties should be anywhere except the target directory (or directories).

If something looks fishy, ask for help.

5.4.3.7. Committing

Make sure to commit a top level directory to have the mergeinfo included as well. Do not specify individual files on the command line. For more information about committing files in general, see the relevant section of this primer.

5.4.4. Vendor Imports with SVN

Important:

Please read this entire section before starting a vendor import.

Note:

Patches to vendor code fall into two categories:

  • Vendor patches: these are patches that have been issued by the vendor, or that have been extracted from the vendor's version control system, which address issues which cannot wait until the next vendor release.

  • FreeBSD patches: these are patches that modify the vendor code to address FreeBSD-specific issues.

The nature of a patch dictates where it should be committed:

  • Vendor patches must be committed to the vendor branch, and merged from there to head. If the patch addresses an issue in a new release that is currently being imported, it must not be committed along with the new release: the release must be imported and tagged first, then the patch can be applied and committed. There is no need to re-tag the vendor sources after committing the patch.

  • FreeBSD patches are committed directly to head.

5.4.4.1. Preparing the Tree

If importing for the first time after the switch to Subversion, flattening and cleaning up the vendor tree is necessary, as well as bootstrapping the merge history in the main tree.

5.4.4.1.1. Flattening

During the conversion from CVS to Subversion, vendor branches were imported with the same layout as the main tree. This means that the pf vendor sources ended up in vendor/pf/dist/contrib/pf. The vendor source is best directly in vendor/pf/dist.

To flatten the pf tree:

% cd vendor/pf/dist/contrib/pf
% svn mv $(svn list) ../..
% cd ../..
% svn rm contrib
% svn propdel -R svn:mergeinfo .
% svn commit

The propdel bit is necessary because starting with 1.5, Subversion will automatically add svn:mergeinfo to any directory that is copied or moved. In this case, as nothing is being merged from the deleted tree, they just get in the way.

Tags may be flattened as well (3, 4, 3.5 etc.); the procedure is exactly the same, only changing dist to 3.5 or similar, and putting the svn commit off until the end of the process.

5.4.4.1.2. Cleaning Up

The dist tree can be cleaned up as necessary. Disabling keyword expansion is recommended, as it makes no sense on unmodified vendor code and in some cases it can even be harmful. OpenSSH, for example, includes two files that originated with FreeBSD and still contain the original version tags. To do this:

% svn propdel svn:keywords -R .
% svn commit
5.4.4.1.3. Bootstrapping Merge History

If importing for the first time after the switch to Subversion, bootstrap svn:mergeinfo on the target directory in the main tree to the revision that corresponds to the last related change to the vendor tree, prior to importing new sources:

% cd head/contrib/pf
% svn merge --record-only svn+ssh://repo.freebsd.org/base/vendor/pf/dist@180876 .
% svn commit
5.4.4.2. Importing New Sources

With two commits—one for the import itself and one for the tag—this step can optionally be repeated for every upstream release between the last import and the current import.

5.4.4.2.1. Preparing the Vendor Sources

Subversion is able to store a full distribution in the vendor tree. So, import everything, but merge only what is required.

A svn add is required to add any files that were added since the last vendor import, and svn rm is required to remove any that were removed since. Preparing sorted lists of the contents of the vendor tree and of the sources that are about to be imported is recommended, to facilitate the process.

% cd vendor/pf/dist
% svn list -R | grep -v '/$' | sort >../old
% cd ../pf-4.3
% find . -type f | cut -c 3- | sort >../new

With these two files, comm -23 ../old ../new will list removed files (files only in old), while comm -13 ../old ../new will list added files only in new.

5.4.4.2.2. Importing into the Vendor Tree

Now, the sources must be copied into dist and the svn add and svn rm commands are used as needed:

% cd vendor/pf/pf-4.3
% tar cf - . | tar xf - -C ../dist
% cd ../dist
% comm -23 ../old ../new | xargs svn rm
% comm -13 ../old ../new | xargs svn add --parents

If any directories were removed, they will have to be svn rmed manually. Nothing will break if they are not, but they will remain in the tree.

Check properties on any new files. All text files should have svn:eol-style set to native. All binary files should have svn:mime-type set to application/octet-stream unless there is a more appropriate media type. Executable files should have svn:executable set to *. No other properties should exist on any file in the tree.

Committing is now possible. However, it is good practice to make sure that everything is okay by using the svn stat and svn diff commands.

5.4.4.2.3. Tagging

Once committed, vendor releases are tagged for future reference. The best and quickest way to do this is directly in the repository:

% svn cp svn+ssh://repo.freebsd.org/base/vendor/pf/dist svn+ssh://repo.freebsd.org/base/vendor/pf/4.3

Once that is complete, svn up the working copy of vendor/pf to get the new tag, although this is rarely needed.

If creating the tag in the working copy of the tree, svn:mergeinfo results must be removed:

% cd	vendor/pf
% svn cp dist 4.3
% svn propdel svn:mergeinfo -R 4.3
5.4.4.3. Merging to Head
% cd head/contrib/pf
% svn up
% svn merge --accept=postpone svn+ssh://repo.freebsd.org/base/vendor/pf/dist .

The --accept=postpone tells Subversion not to complain about merge conflicts as they will be handled manually.

Tip:

The cvs2svn changeover occurred on June 3, 2008. When performing vendor merges for packages which were already present and converted by the cvs2svn process, the command used to merge /vendor/package_name/dist to /head/package_location (for example, head/contrib/sendmail) must use -c REV to indicate the revision to merge from the /vendor tree. For example:

% svn checkout svn+ssh://repo.freebsd.org/base/head/contrib/sendmail
% cd sendmail
% svn merge -c r261190 '^/vendor/sendmail/dist' .

^ is an alias for the repository path.

Note:

If using the Zsh shell, the ^ must be escaped with \ or quoted.

It is necessary to resolve any merge conflicts.

Make sure that any files that were added or removed in the vendor tree have been properly added or removed in the main tree. To check diffs against the vendor branch:

% svn diff --no-diff-deleted --old=svn+ssh://repo.freebsd.org/base/vendor/pf/dist --new=.

The --no-diff-deleted tells Subversion not to complain about files that are in the vendor tree but not in the main tree. Things that would have previously been removed before the vendor import, like the vendor's makefiles and configure scripts.

Using CVS, once a file was off the vendor branch, it was not able to be put back. With Subversion, there is no concept of on or off the vendor branch. If a file that previously had local modifications, to make it not show up in diffs in the vendor tree, all that has to be done is remove any left-over cruft like FreeBSD version tags, which is much easier.

If any changes are required for the world to build with the new sources, make them now, and keep testing until everything builds and runs perfectly.

5.4.4.4. Committing the Vendor Import

Committing is now possible! Everything must be committed in one go. If done properly, the tree will move from a consistent state with old code, to a consistent state with new code.

5.4.4.5. From Scratch
5.4.4.5.1. Importing into the Vendor Tree

This section is an example of importing and tagging byacc into head.

First, prepare the directory in vendor:

% svn co --depth immediates $FSVN/vendor
% cd vendor
% svn mkdir byacc
% svn mkdir byacc/dist

Now, import the sources into the dist directory. Once the files are in place, svn add the new ones, then svn commit and tag the imported version. To save time and bandwidth, direct remote committing and tagging is possible:

% svn cp -m "Tag byacc 20120115" $FSVN/vendor/byacc/dist $FSVN/vendor/byacc/20120115
5.4.4.5.2. Merging to head

Due to this being a new file, copy it for the merge:

% svn cp -m "Import byacc to contrib" $FSVN/vendor/byacc/dist $FSVN/head/contrib/byacc

Working normally on newly imported sources is still possible.

5.4.5. Reverting a Commit

Reverting a commit to a previous version is fairly easy:

% svn merge -r179454:179453 ROADMAP.txt
% svn commit

Change number syntax, with negative meaning a reverse change, can also be used:

% svn merge -c -179454 ROADMAP.txt
% svn commit

This can also be done directly in the repository:

% svn merge -r179454:179453 svn+ssh://repo.freebsd.org/base/ROADMAP.txt

Note:

It is important to ensure that the mergeinfo is correct when reverting a file to permit svn mergeinfo --eligible to work as expected.

Reverting the deletion of a file is slightly different. Copying the version of the file that predates the deletion is required. For example, to restore a file that was deleted in revision N, restore version N-1:

% svn copy svn+ssh://repo.freebsd.org/base/ROADMAP.txt@179454
% svn commit

or, equally:

% svn copy svn+ssh://repo.freebsd.org/base/ROADMAP.txt@179454 svn+ssh://repo.freebsd.org/base

Do not simply recreate the file manually and svn add it—this will cause history to be lost.

5.4.6. Fixing Mistakes

While we can do surgery in an emergency, do not plan on having mistakes fixed behind the scenes. Plan on mistakes remaining in the logs forever. Be sure to check the output of svn status and svn diff before committing.

Mistakes will happen but, they can generally be fixed without disruption.

Take a case of adding a file in the wrong location. The right thing to do is to svn move the file to the correct location and commit. This causes just a couple of lines of metadata in the repository journal, and the logs are all linked up correctly.

The wrong thing to do is to delete the file and then svn add an independent copy in the correct location. Instead of a couple of lines of text, the repository journal grows an entire new copy of the file. This is a waste.

5.4.7. Using a Subversion Mirror

There is a serious disadvantage to this method: every time something is to be committed, a svn relocate to the main repository has to be done, remembering to svn relocate back to the mirror after the commit. Also, since svn relocate only works between repositories that have the same UUID, some hacking of the local repository's UUID has to occur before it is possible to start using it.

5.4.7.1. Checkout from a Mirror

Check out a working copy from a mirror by substituting the mirror's URL for svn+ssh://repo.freebsd.org/base. This can be an official mirror or a mirror maintained by using svnsync.

5.4.7.2. Setting up a svnsync Mirror

Avoid setting up a svnsync mirror unless there is a very good reason for it. Most of the time a git mirror is a better alternative. Starting a fresh mirror from scratch takes a long time. Expect a minimum of 10 hours for high speed connectivity. If international links are involved, expect this to take four to ten times longer.

One way to limit the time required is to grab a seed file. It is large (~1GB) but will consume less network traffic and take less time to fetch than svnsync will.

Extract the file and update it:

% tar xf svnmirror-base-r261170.tar.xz
% svnsync sync file:///home/svnmirror/base

Now, set that up to run from cron(8), do checkouts locally, set up a svnserve server for local machines to talk to, etc.

The seed mirror is set to fetch from svn://svn.freebsd.org/base. The configuration for the mirror is stored in revprop 0 on the local mirror. To see the configuration, try:

% svn proplist -v --revprop -r 0 file:///home/svnmirror/base

Use svn propset to change things.

5.4.8. Committing High-ASCII Data

Files that have high-ASCII bits are considered binary files in SVN, so the pre-commit checks fail and indicate that the mime-type property should be set to application/octet-stream. However, the use of this is discouraged, so please do not set it. The best way is always avoiding high-ASCII data, so that it can be read everywhere with any text editor but if it is not avoidable, instead of changing the mime-type, set the fbsd:notbinary property with propset:

% svn propset fbsd:notbinary yes foo.data

5.4.9. Maintaining a Project Branch

A project branch is one that is synced to head (or another branch) is used to develop a project then commit it back to head. In SVN, dolphin branching is used for this. A dolphin branch is one that diverges for a while and is finally committed back to the original branch. During development code migration in one direction (from head to the branch only). No code is committed back to head until the end. After the branch is committed back at the end, it is dead (although a new branch with the same name can be created after the dead one is deleted).

As per https://people.FreeBSD.org/~peter/svn_notes.txt, work that is intended to be merged back into HEAD should be in base/projects/. If the work is beneficial to the FreeBSD community in some way but not intended to be merged directly back into HEAD then the proper location is base/user/username/. This page contains further details.

To create a project branch:

% svn copy svn+ssh://repo.freebsd.org/base/head svn+ssh://repo.freebsd.org/base/projects/spif

To merge changes from HEAD back into the project branch:

% cd copy_of_spif
% svn merge svn+ssh://repo.freebsd.org/base/head
% svn commit

It is important to resolve any merge conflicts before committing.

5.5. Some Tips

In commit logs etc., rev 179872 is spelled r179872 as per convention.

Speeding up svn is possible by adding these entries to ~/.ssh/config:

Host *
ControlPath ~/.ssh/sockets/master-%l-%r@%h:%p
ControlMaster auto
ControlPersist yes

and then typing

mkdir ~/.ssh/sockets

Checking out a working copy with a stock Subversion client without FreeBSD-specific patches (OPTIONS_SET=FREEBSD_TEMPLATE) will mean that $FreeBSD$ tags will not be expanded. Once the correct version has been installed, trick Subversion into expanding them like so:

% svn propdel -R svn:keywords .
% svn revert -R .

This will wipe out uncommitted patches.

It is possible to automatically fill the "Sponsored by" and "MFC after" commit log fields by setting "freebsd-sponsored-by" and "freebsd-mfc-after" fields in the "[miscellany]" section of the ~/.subversion/config configuration file. For example:

freebsd-sponsored-by = The FreeBSD Foundation
freebsd-mfc-after = 2 weeks

All FreeBSD documents are available for download at https://download.freebsd.org/ftp/doc/

Questions that are not answered by the documentation may be sent to <freebsd-questions@FreeBSD.org>.
Send questions about this document to <freebsd-doc@FreeBSD.org>.