Net-SNMP SVN Usage Page

From Net-SNMP Wiki
Revision as of 15:56, 3 March 2010 by Jsafranek (Talk | contribs) (Add SVN 1.5 way of partial checkout.)

Jump to: navigation, search

External documentation:

Basic Operations

Checking out the main-line code base:

 svn co https://net-snmp.svn.sourceforge.net/svnroot/net-snmp/trunk/net-snmp net-snmp

Checking out a branch (e.g. V5-4-patches):

 svn co https://net-snmp.svn.sourceforge.net/svnroot/net-snmp/branches/V5-4-patches/net-snmp net-snmp

Updating/Merging to the current repository version:

 svn update

Development related commands

Seeing if your local checkout has modifications:

 svn status

Seeing if your local checkout is up-to-date (without updating it):

 svn -u status

Comparing your local file to the repository file:

 svn diff FILE

Committing your changes (requires write access)

 svn commit FILE

Repository analysis Commands

Listing what's available in the remote repository:

 svn list https://net-snmp.svn.sourceforge.net/svnroot/net-snmp/tags/

Figuring out who modified a line in a file (cvs annotate):

 svn blame FILE

Tagging and branching

Creating a tag:

 svn copy https://net-snmp.svn.sourceforge.net/svnroot/net-snmp/trunk/net-snmp https://net-snmp.svn.sourceforge.net/svnroot/net-snmp/tags/Ext-5-5/net-snmp

Creating a branch:

 svn copy https://net-snmp.svn.sourceforge.net/svnroot/net-snmp/trunk/net-snmp https://net-snmp.svn.sourceforge.net/svnroot/net-snmp/branches/V5-5-patches/net-snmp

Tricks and Tips

Creating a partial checkout (top down approach)

(this was found on the GCC SVN setup page):

Start by checking out the svn repository:

 svn co https://net-snmp.svn.sourceforge.net/svnroot/net-snmp/

Then replace any unneeded parts with some nice and fairly empty directory:

 svn switch https://net-snmp.svn.sourceforge.net/svnroot/net-snmp/trunk/net-snmp/win32/bin net-snmp/historic
 svn switch https://net-snmp.svn.sourceforge.net/svnroot/net-snmp/trunk/net-snmp/win32/bin net-snmp/tags

The main disadvantage of this approach is that it involves downloading the full SVN repository (which is fairly large!), before removing the unwanted elements

This disadvantage can be somewhat worked around by noting that nothing prevents you from aborting the checkout of unwanted parts before they are complete, switch them away without ever downloading them, and then continue the checkout.

Creating a partial checkout (bottom up approach)

Alternatively, check out the portions that you're actually interested in:

 svn co https://net-snmp.svn.sourceforge.net/svnroot/net-snmp/trunk
 svn co https://net-snmp.svn.sourceforge.net/svnroot/net-snmp/branches

then create a suitable top-level SVN configuration. The simplest way to do this is to copy an existing '.svn' directory:

 cd trunk
 tar cf - .svn | (cd .. ; tar xf -)
 cd ..

Then tweak this top-level copy as follows:

 edit the file '.svn/all-wcprops' and delete the string "/trunk"
 edit the file '.svn/entries', delete the string "/trunk",
    replace the string "module-templates" with "trunk",
    replace the string "net-snmp" with "branches",
    delete the section referring to "htdocs"

Always lie to your computer - make sure it knows who's the boss!

-- darix: NEVER EVER EDIT FILES IN THE ".svn" DIRECTORY.

Creating partial checkout using externals

svn externals can be easily used to create partial checkouts.

with dummy local repo

Within a local repository (or any repository you have write access to, really):

   svnadmin create /srv/svn/repos/net-snmp-dummy
   svn co file:///srv/svn/repos/net-snmp-dummy net-snmp
   svn propedit svn:externals net-snmp
   5.1  https://net-snmp.svn.sourceforge.net/svnroot/net-snmp/branches/V5-1-patches/net-snmp/
   5.2  https://net-snmp.svn.sourceforge.net/svnroot/net-snmp/branches/V5-2-patches/net-snmp/
   5.3  https://net-snmp.svn.sourceforge.net/svnroot/net-snmp/branches/V5-3-patches/net-snmp/
   5.4  https://net-snmp.svn.sourceforge.net/svnroot/net-snmp/branches/V5-4-patches/net-snmp/
   trunk https://net-snmp.svn.sourceforge.net/svnroot/net-snmp/trunk/net-snmp/
   svn ci -m 'add externals' net-snmp
   svn up net-snmp

Note that if you have existing checkouts, you can simply copy them into the local repo net-snmp checkout, instead of downloading them again.

With remote repo

Preparation:

   svn mkdir https://net-snmp.svn.sourceforge.net/svnroot/net-snmp/workspaces/

Per user:

   svn mkdir https://net-snmp.svn.sourceforge.net/svnroot/net-snmp/workspaces/username
   svn co https://net-snmp.svn.sourceforge.net/svnroot/net-snmp/workspaces/username/ net-snmp
   svn propedit svn:externals net-snmp
   5.1  https://net-snmp.svn.sourceforge.net/svnroot/net-snmp/branches/V5-1-patches/net-snmp/
   5.2  https://net-snmp.svn.sourceforge.net/svnroot/net-snmp/branches/V5-2-patches/net-snmp/
   5.3  https://net-snmp.svn.sourceforge.net/svnroot/net-snmp/branches/V5-3-patches/net-snmp/
   5.4  https://net-snmp.svn.sourceforge.net/svnroot/net-snmp/branches/V5-4-patches/net-snmp/
   trunk https://net-snmp.svn.sourceforge.net/svnroot/net-snmp/trunk/net-snmp/

Afterwards you can run

   svn up net-snmp

and get the desired subset.

Creating partial checkout with SVN 1.5

Following commands create new checkout with trunk and 5.5 branch with SVN 1.5 or later.

Check out bare net-snmp directory:

   svn co --depth empty https://net-snmp.svn.sourceforge.net/svnroot/net-snmp

Check out full trunk:

   svn up --set-depth infinity net-snmp/trunk

For branches, let's check out just 'branches' directory, without subdirectories:

   svn up --set-depth immediates net-snmp/branches

And check out only the branches you want:

   svn up --set-depth infinity net-snmp/branches/V5-5-patches

You do not need to use --set-depth commands after this initial checkout. All SVN commands work there without any limitation, no hacking around is needed.