[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Confused about branches and partial switches

From: BRM <bm_witness_at_yahoo.com>
Date: Thu, 9 Jul 2009 17:34:27 -0700 (PDT)

I think you got the process wrong, possibly due to a mis-understanding - most likely of the use of svn switch as it relates.

If I am not mistaken, you are branching from below trunk - e.g. http://svn/svn/project/trunk/a/b/mystuff
That is okay to do, but not if you are working from a working copy of http://svn/svn/project/trunk/a/b - check it out to a separate directory.
You only use 'svn switch' for your entire working copy, and on URLs that should be identical. It sounds like you've done something that violates that; so SVN is trying to get the working copy to the state it thinks its it.
Also, svn makes it really easy to branch from a working copy - even if you haven't committed the changes to the current tree location. I've found this very useful, especially when I made changes I didn't want to commit to that tree but wasn't sure I wanted to toss out yet - just do 'svn copy . http://svn/svn/project/branches/brett/branch-name' (not the period beween 'copy' and 'http').

If you can't compile in that form, then branch the trunk.

And per the error message, I'm not 100% sure, but 'svn cleanup' may resolve part of the issue.

This should resolve the problems you described.

Now, as per merging -

No, you don't need to delete the branch and then re-create it every time. It's an easy thing to do, and if the changes are great enough, then you may want to. You can also do a two way merge - merge changes from 'trunk' to your branch, and at least personally I find this useful to do before merging the branch back to the mainline trunk as it means there will typically be less work in getting trunk back to a working state after your changes are applied (since you theoretically did it in your branch) - only a downfall if trunk changes too fast, but then there would likely be other problems...

Any how...here's what I recommend:

1) Branch trunk to your branch area (svn copy http://svn/svn/project/trunk http://svn/svn/project/branches/brett/branch-name)
** I added another layer in case you want multiple branches, I find it helpful at least **
2) Do you work in your branch.
3) Update your branch to include changes from trunk (svn merge -r <start rev>:<end rev> http://svn/svn/project/trunk), and fix anything that broke - this is in your working copy
4) Merge your changes back to trunk (svn merge -r <start rev>:<end rev> http://svn/svn/project/branches/brett/branch-name) - this is in a working copy of trunk - and fix anything that breaks.

Supposing you didn't have to fix anything more, your commit at the end of #4 and your commit at the end of #3 should yield identical branches.

Now, svn 1.5.x and 1.6.x have some extra merge support functionality to help with integrating branches, so there may be a few better commands for doing this. (I'm using a 1.4.x server, so I don't get that benefit and can't speak as to the syntax.)So others may chime in with a better way to do the same thing, but that's the gist of it.

HTH,

Ben

________________________________
From: Brett Coon <brett.coon_at_gmail.com>
To: users_at_subversion.tigris.org
Sent: Thursday, July 9, 2009 6:14:30 PM
Subject: Confused about branches and partial switches

I'm relatively new to subversion, having started using it with version 1.6.2 just a few weeks ago. I have prior experience with CVS, Perforce, and a bit with AccuRev. So I'm not new to SCM.

Today I tried using svn branches for the second time, and once again it seems to be ending badly. Very frustrating. But maybe with some help I can make things work.

I'm working on one part of our source tree, several directories below the top. My desire is to do my development in a private branch so that I can do frequent commits without messing up the trunk. Whenever I have code worth sharing, I'll merge those changes into the trunk. Since I'm the only one working on these files, the merges should be one-way and painless. I'd like to continue working in the branch, merging back to trunk as needed.

So I created a branch of the tree, and then tried to "switch" my work subdirectory to the branch. Apparently I got the switch syntax horribly wrong, because it started checking out a whole new tree below my subdirectory, and left my work area in a confused state when I interrupted it with ^C. Now it claims some of my files have conflicts and "local edit, incoming delete upon switch". It won't let me update because mysterious subdirectories it somehow believes should be present are missing. Luckily I backed up all modified files before trying the dangerous svn switch command, so I'm now in the process of starting over with a clean checkout.

My first question is why doesn't svn switch support the --dry-run option? Is there something comparable? I now fear that command.

My second question is what exactly is the correct syntax for switching a subdirectory to a branch?

For the sake of argument, let's say the trunk path is http://svn/svn/project/trunk, my branch is http://svn/svn/project/branches/brett, and I'm working in the subdirectory whose URL is http://svn/svn/project/trunk/a/b/mystuff

What I tried, while in the a/b/mystuff directory of my workarea, was "svn switch ^/branches/brett"
Apparently that's wrong. Very, very wrong. I've been searching docs, and it seems all the examples reference the top of tree.

My last question is do I really need to delete and recreate my branch after each merge to trunk? This seems to be the prevailing wisdom on the articles I've found, but I find it's often hard to tell whether or not svn branching advice applies to svn 1.6 or only earlier versions with more primitive branching support.

I really like the AccuRev concept of lightweight private branches so you can do frequent private commits ("keep" in accurev) without breaking the trunk. svn branches seem to be almost capable of this kind of usage model, but my experience so far has been, uh, unsatisfactory.

All help and advice appreciated!

-Brett

-- 
Brett Coon - brett.coon@gmail.com - http://brettcoon.smugmug.com
------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=2369543
To unsubscribe from this discussion, e-mail: [users-unsubscribe_at_subversion.tigris.org].
Received on 2009-07-10 02:35:59 CEST

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.