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

Re: Possible BUG?: partial commit after switch, not possible to switch back

From: Bradford Smith <bradford.carl.smith_at_gmail.com>
Date: 2007-03-15 15:23:44 CET

I cannot comment on whether the behavior you are seeing is a bug or not, but
I do think you're probably making life a lot harder for yourself than you
need to. The subversion switching feature is nice, but easily overused and
abused. I think you'll find it much easier to avoid problems both now and
in the future if you follow these self-imposed rules:

1. Commits and checkouts are always done on the ENTIRE trunk or branch.

Individually checking in files or subdirectories is just going to give you
headaches in the long run. It's easiest if you think of the entire tree a
unit and treat it that way.

2. Never switch portions of a directory tree.

I know the SVN book talks about doing some nice tricks by switching parts of
your directory to different branches, but this way lies madness. It's too
easy to forget that you've done things like this. Also, it makes crazy
things happen when following rule 1.

3. Commit logically separate changes separately.

It looks like you were trying to follow this rule, which is good. It will
help you lots in the long run when you need to merge some, but not all,
changes from one branch to another.

I suspect you ran into the problem you describe because you got part way
through making some changes on the trunk and discovered a bug you needed to
fix on both the trunk and a branch. The following procedure would serve you
much better:

1. check out a fresh copy of the trunk in another working directory.
2. Fix the bug there and check it in with appropriate comments.
3. switch the new working directory to the branch.
4. merge in the change you just made to the trunk and check in the branch.
5. either delete the new branch directory or leave it around for convenient
use later.
6. go back to your original trunk working directory.
7. do svn update to get the changes you just checked in.
8. resolve any conflicts and continue with your original work.

HTH,

Bradford C. Smith

On 3/15/07, Reinhard Brandstaedter <Reinhard.Brandstaedter@jku.at> wrote:
>
> Hello!
>
> I'm trying to work out a procedure how to do partial commits of changes
> in a (multiple) switched WC. Maybe it's easier to describe this in an
> example:
>
> What I'm trying to do:
> 1. check out trunk
> 2. _modify_ some files in this working copy
> 3. switch the working copy to a branch
> (the local modified files are kept even if they are not in the
> branch at all - good and I expected that)
> 4. _add_ and _commit_ some (not all!) of the modified files to the
> branch
> 5. switch the working copy back to trunk
> 6. commit the rest of the modified files (the ones I changed and did
> not commit into the branch) to trunk
> 7. merge the files (changes) I committed into the branch back into the
> trunk working copy
>
> Steps 1.-4. works fine 5.-7. cause problems/are not possible.
>
> This are the steps in detail:
>
> reinhard@redchili /wkpkg-test $ ls
> 1.txt 3.txt
> reinhard@redchili /wkpkg-test $ echo "change" > 1.txt
> reinhard@redchili /wkpkg-test $ echo "change" > 3.txt
> reinhard@redchili /wkpkg-test $ cd ..
> reinhard@redchili /development $ cd wkpkg-test2/
> reinhard@redchili /wkpkg-test2 $ echo "change" > a.txt
> reinhard@redchili /wkpkg-test2 $ echo "change" > c.txt
> reinhard@redchili /wkpkg-test2 $ cd ..
> reinhard@redchili /development $ svn status
> M wkpkg-test/3.txt
> M wkpkg-test/1.txt
> M wkpkg-test2/c.txt
> M wkpkg-test2/a.txt
>
> reinhard@redchili /development $ svn info
> Path: .
> URL: https://svn-zid.zid.jku.at/svn/sandbox/trunk/sandbox/development
> Repository Root: https://svn-zid.zid.jku.at/svn/sandbox
> Repository UUID: 38bd993a-0a1f-0410-be6b-c865c14f2943
> Revision: 96
> Node Kind: directory
> Schedule: normal
> Last Changed Author: rbrand
> Last Changed Rev: 93
> Last Changed Date: 2007-03-15 12:59:27 +0100 (Thu, 15 Mar 2007)
>
> reinhard@redchili /development $ svn switch
> https://svn-zid.zid.jku.at/svn/sandbox/branches/release/development
> D wkpkg-test/3.txt
> A wkpkg-test/2.txt
> D wkpkg-test2/c.txt
> A wkpkg-test2/b.txt
> D wkpkg-test3/III.txt
> A wkpkg-test3/II.txt
> Updated to revision 98.
>
> reinhard@redchili /development $ svn status
> ? wkpkg-test/3.txt
> M wkpkg-test/1.txt
> ? wkpkg-test2/c.txt
> M wkpkg-test2/a.txt
>
> reinhard@redchili /development $ svn diff wkpkg-test/1.txt
> Index: wkpkg-test/1.txt
> ===================================================================
> --- wkpkg-test/1.txt (revision 98)
> +++ wkpkg-test/1.txt (working copy)
> @@ -0,0 +1 @@
> +change
>
> reinhard@redchili /development $ svn diff wkpkg-test2/a.txt
> Index: wkpkg-test2/a.txt
> ===================================================================
> --- wkpkg-test2/a.txt (revision 98)
> +++ wkpkg-test2/a.txt (working copy)
> @@ -0,0 +1 @@
> +change
>
> reinhard@redchili /development $ svn commit -m "local changes made while
> in trunk, then switch and commit them to branch"
> Sending wkpkg-test/1.txt
> Sending wkpkg-test2/a.txt
> Transmitting file data ..
> Committed revision 99.
>
> reinhard@redchili /development $ svn switch
> https://svn-zid.zid.jku.at/svn/sandbox/trunk/sandbox/development
> U wkpkg-test/1.txt
> D wkpkg-test/2.txt
> svn: Failed to add file 'wkpkg-test/3.txt': object of the same name
> already exists
>
> reinhard@redchili /development $ svn status
> ! .
> ? wkpkg-test/3.txt
> ! wkpkg-test
> ? wkpkg-test2/c.txt
> S wkpkg-test2
> S wkpkg-test3
> S wkpkg-cake
> S wkpkg-test4
> S wkpkg-test5
> S local.properties
> S wkpkg-sand
> S wkpkg-kitchen2
>
> So the switch back to trunk fails because there is already a file 3.txt
> in the working copy (which seems to be unversioned now).
> As the switch command is a superset of the update I'd expect the same
> behavior as with the update command: the switch to trunk should work
> fine and should leave the files in a conflicted state (because there was
> a local change and the file in the repository differs).
> Maybe the SVN client has to track somewhere if 3.txt was a versioned
> file before the switch so it can be set back to that safely after
> switching back (like a switch history for the working copy).
>
> I think this scenario I'm describing here is not so uncommon. Actually
> it isn't my personal requirement to do things like that but I have
> developers that need to switch back and forth and maybe have 100 files
> modified in their working copy when switching and want only a few of
> them in the branch and the rest in the trunk.
>
> Maybe I'm completely wrong in my approach how to do this. But please
> tell me how I could work-around this problem?
>
> Thanks,
> Reinhard
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
> For additional commands, e-mail: users-help@subversion.tigris.org
>
>
Received on Thu Mar 15 15:24:28 2007

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.