2

I have two versions of my code I want to alternate between. If I run

svn checkout -r 5 file:///path.to.svn.repo

and the current version in the target directory is higher than 5, I can't go back. To my understanding, this is intentional, and I should use merge instead. Merge update the latest version, and I don't want that. Is there an easy way to alternate?

I suppose I could split the code into two projects, but I'm not sure this is the right solution.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Yotam
  • 10,295
  • 30
  • 88
  • 128
  • why not use some svn client like tortoise-svn,smart-svn or subclipse (which I am using) if you are using eclipse. They will definitely make your life simpler. – Amit Dec 15 '11 at 12:48
  • Why do you need two versions? If you have two versions, say Production and Development, you need to keep track of Branching or Labeling would be better choices to manual checkouts. – AlG Dec 15 '11 at 12:50
  • I want to alternate between the two versions because they work a little bit differently. All the code I write is for my Ph.D. projects and I want to be able and alternate between different versions of the code easily. – Yotam Dec 15 '11 at 13:46
  • use up, not co. Full duplicate of [How can I checkout a specific file from svn?](http://stackoverflow.com/questions/8523023/how-can-i-checkout-a-specific-file-from-svn) – Lazy Badger Dec 15 '11 at 17:06
  • I'm too lazy repeat my answer, so - [link to answer in duplicate question](http://stackoverflow.com/a/8523849/960558) of OP. OP - **don't write dupes!!!** – Lazy Badger Dec 15 '11 at 17:09

2 Answers2

3

Why not check out the old code into a different folder?

e.g.

c:\MySource\
c:\MyOlderSource\

However, if you want only one folder then merge is the correct way to do it. I don't know what you mean that merge will "update the latest version". It will update your working copy (the BASE version) but not the repository copy (the HEAD version), but that is exactly the behaviour you want.

RB.
  • 36,301
  • 12
  • 91
  • 131
  • Thanks. This is kinda my solution. I simply delete the local src folder and recreate it. Is there a way to checkout a specific file in a specific version? Is there a way to give this file version an intuitive name (such as runner, debugger etc.)? – Yotam Dec 15 '11 at 13:45
1

From my understanding I believe that you would want to create at least one branch (maybe two if you want a development and a release branch)

So svn cp -r5 file:///path.to.repo/trunk file:///path.to.repo/branches/development would be a typical way of creating a branch from an old version of you code.

This basically copies how the trunk directory looked at revision 5 and puts that into a new location "branches/development"

Now I'm assuming that you setup your repository in the standard svn way (with trunk, branches and tags), regardless of this setup it is still possible to use this command.

You may also be interested in the svn switch command which allows you to switch your working copy from one area of the repository to another. Alternatively you could just checkout 2 workings copies (depends on how much disk space you require I guess)

Take a look at svn redbook for more information on commands etc. in svn: http://svnbook.red-bean.com/

kickbackjack
  • 257
  • 3
  • 9