[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: Brett Coon <brett.coon_at_gmail.com>
Date: Thu, 9 Jul 2009 22:41:01 -0700

On Thu, Jul 9, 2009 at 5:34 PM, BRM <bm_witness_at_yahoo.com> wrote:

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

Likely.

> If I am not mistaken, you are branching from below trunk - e.g.
> http://svn/svn/project/trunk/a/b/mystuff

Not entirely sure what you mean by "branching from below trunk", but I don't
think so.
  I branched the whole tree, exactly like the example from the book, e.g.
svn copy .../trunk .../branches/brett

> 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.

I was working in the trunk, but really wanted to check in some files before
making more changes. So my plan was to "switch" my current trunk directory
to its sibling in my branch, so I could commit the changes.

> You only use 'svn switch' for your entire working copy,

Hmm, the book explicitly says "You can switch just part of your working copy
to a branch if you don't want to switch your entire working
copy<http://svnbook.red-bean.com/nightly/en/svn.ref.svn.c.switch.html>
."
Unfortunately, that's all they have to say about that.

> and on URLs that should be identical. It sounds like you've done something
> that violates that;

So after checking out *another *copy of the trunk, I was able to do what I
wanted. The key part seems to be "URLs that should be identical": the
winning svn switch invocation provided the path to the same subdirectory in
both the branch URL and my work area, like this:

cd ...my work area.../trunk/a/b
svn switch http://svn/svn/project/branches/brett/a/b/subdir subdir

It would be nice if "svn switch" would check to make sure the paths match,
and at least warn you if they don't, since in my experience it's "bad" when
they don't.

I suppose the benefit of this feature is that I can make branches of only a
subdirectory, rather than branching the whole tree, and still use switch to
swap just the subdir between trunk and branch.

> 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').

Thanks, this is a neat trick.

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

No, svn still thinks that subdirectory is different than what I intended,
though at least now I think I know what happened. Apparently I told svn to
switch the subdirectory of my work area with the top-of-tree of the branch.

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 **

Good idea.

> 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.
>

Thanks for the tips. I got some other advice off-list via email. I was
trying to rely on the extra merge support in svn 1.6.x, but I may be asking
too much of it. I'm going to look into the svnmerge.py script, and between
that and doing manual merge tracking, it seems there's a way to make this
work.

-Brett

>
>
>
>
>
> ________________________________
> 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
>
>

-- 
Brett Coon - brett.coon@gmail.com - http://brettcoon.smugmug.com
------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=2369577
To unsubscribe from this discussion, e-mail: [users-unsubscribe_at_subversion.tigris.org].
Received on 2009-07-10 07:46:07 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.