3

I am using SVN as my source control with ANKH and TortoiseSVN. I am writing a huge change in a project, and it takes a few days to make the change, but in the meantime I still want to commit once in a while for backup. But if I commit other team members will get updated with my unfinished work.

Is there a way that I can "commit for backup" without changing the revision (so other won't get updated with my changes)?

Thanks!

7
  • Someone has to say it. :) This is a good reason to consider using a distributed version control system like Mercurial. Commit as often as you want, push when you're ready. Jan 9, 2011 at 7:12
  • 1
    @Matthew: commit-for-backup without pushing wouldn't work in Mercurial either, since it would only commit locally.
    – Avi
    Jan 9, 2011 at 7:16
  • @Avi, my understanding is he wants to only commit locally. Then he eventually wants to push (all the changes he committed) when he considers the sequence of changesets ready to share. Jan 9, 2011 at 7:22
  • @Avi: local back-up is still a form of back-up. It's just only back-up against things like accidental deletions or mistaken modification rather than back-up against hard-drive crashes. Jan 9, 2011 at 7:23
  • @Keith, true. Of course, he can could also copy a hg repo to an external backup drive, either manually or with hg clone/push. Jan 9, 2011 at 7:27

5 Answers 5

5

This sounds like a classic case to use feature branches. This keeps your work separate, but allows all the other benefits of Subversion to continue.

1
  • Sounds pretty close to what I was looking for! :-) Thanks!
    – TCS
    Jan 9, 2011 at 8:29
3

To elaborate on iconik's comment:

One of the great features of SVN is the ability to branch a solution. When you create a branch, you're essentially creating a new repository by copying the existing code from the trunk.

While working on that branch, you can do anything to the code and it won't effect the trunk. When you're done with all the changes, you can merge the branch back into the trunk.

However, it is possible for other people to on the same branch you made (although rare), but you can ask them not to and they shouldn't have an issue with it.

More details can be found by reading this SVN book

5
  • its svn's great feature? try Git dude and you will see what branches should work like. Svn branches are hard to merge and heavyweight. Plus its CVS feature that was stoled by svn.
    – IAdapter
    Jan 9, 2011 at 7:43
  • 1
    It's still a great feature of SVN regardless where they stole it from. And I know how flexible git is, but discussing it in my answer wouldn't answer the question.
    – Omar
    Jan 9, 2011 at 8:24
  • Thanks! :-) I was hoping there is a better way than branching 'cause branching could be quite painful! Guess there isn't! :-) thanks again!
    – TCS
    Jan 9, 2011 at 8:26
  • 1
    I think you have your definitions mixed up. A branch is not "a new repository". A branch is always inside the same repository as the ancestor it was copied from.
    – Wim Coenen
    Jan 9, 2011 at 9:43
  • Branches in Subversion are not heavyweight, they are cheap copies. Merging back shouldn't be harder then in git, if you ensure that your working copy is up to date and at a single revision. The latter is where Subversion differs from git, in Subversion you can have a mixed revision working copy. Also git enforces that you don't have uncommited changes, whereas Subversion allows this. Again, it's best to make sure you don't have local changes before merging. Also, merging into a mixed revision working copy could lead to more conflicts. Jan 9, 2011 at 18:21
1

The comments above are reasonable answers. You can create a separate branch for your changes which people know won't be correct (possibly not even building) and then merge the branches back together. Be warned that this can be a painful process.

Really, this sort of thing is not well served by Subversion. One of the big advantages of distributed version control systems like git, mercurial and bazaar is that they allow you to make a local commit for back-up purposes without sending it to the main repository immediately. So one option would be to double-manage this by also installing a DVCS client locally and use that to make local commits for back-up purposes. Most DVCS clients work fine without a central server being set-up so you can use it without it causing conflicts with your Subversion server. This is actually a pretty common practice among developers who want the benefits of distributed version control but who work at a company which is using centralized version control.

1

It is quite useful to "lock" the branch for a certain period of time so that other cannot make commits. For e.g. while making a build for a software release and you want to have a known version etc. Subversion provides "hook" mechanism.

http://svnbook.red-bean.com/en/1.1/ch05s02.html

You can write "post" or "pre" commit hooks and enable/disable the commits along with various other tasks.

2
  • If you're not on a branch, it means you're locking trunk, and thus stopping all other developers on your team from working on that project. Sounds like a counter productive solution to me Jan 9, 2011 at 18:17
  • Yes - it could be counter productive if not used judiciously. As they say "with great powers comes great responsibility" :) Feb 7, 2011 at 13:56
0

Yes, use a branch (using svn copy). The part he left out is that using one svn merge command, you can take all the changes made in the branch, and apply it to the trunk (assuming all merges can be done without conflict). I've used SVN for web content this way. I had a devel branch (svn copy) I did all the web work in, and when we were ready to go live, I would do an svn merge to trunk (live) then deploy the trunk to the server.

There is a big advantage of doing this over using one of the distributed repository systems like Mercurial (though it is a fine product), which is that your branch is on the server, which has more reliable hard drives and more frequent backups. If you commit to your local Mercurial repository and your desktop computer dies, your work is lost. It also means if you do want to collaborate with a select group of people (hopefully you'll have some QA involved before you push the code to trunk!!!), you can do so by pointing them to your branch.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.