Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SVN: renaming in the Repo-browser while keeping Working Copy in sync

I've renamed a branch in the repo and carelessly kept working with the same working copy (that was checked out from that branch before the rename). When I later tried to commit, I've noticed the working copy is still targeting the old path. I want to commit the changes to the new path in the repo, while of course keeping history etc...

Do SVN has an elegant way around this?

I read about commands Switch and Relocate but I'm not sure any of them completely suits my problem (the scenarios described are different), and I've always been a bit frightened about trying out commands in the SVN... Does anyone has experience with these commands?

I guess I can go around the problem by, for example, checkout the renamed project to another working copy and then overwrite it with the changes (all besides the SVN metadata). I can also write some script that finds all occurrences of the old path and brutally change them to the new paths but I figured there must be some kind of SVN command for this.

Thanks!

like image 956
myDisplayName Avatar asked Apr 22 '12 11:04

myDisplayName


1 Answers

If the repository URL changes, you need to relocate your working copy. The switch command is used to change the branch your working copy points to. The concepts themselves are quite clear.

But you talk about project and I guess that's the problem you are facing: you won't find any reference to projects in the Subversion documentation because that isn't a Subversion concept.

There're two basic ways to implement projects in Subversion:

  1. Create a repository per project:

    • https://example.com/svn/foo/trunk
    • https://example.com/svn/bar/trunk
  2. Create a branch per project within the same repository:

    • https://example.com/svn/projects/foo/trunk
    • https://example.com/svn/projects/bar/trunk

So when you say "rename a project" you mean either "rename a repository" (#1) or "rename a branch" (#2) and the solution is:

  1. svn relocate to link your working copy again with the repository
  2. Either svn update to bring the changes to your working copy (if the change is within the working copy directory tree) or svn switch to change the branch your working copy points to (if you effectively removed current branch).

Update: My advice so far is that you start from scratch. Rename your current working copy, check out a fresh one and reapply pending changes with a regular file compare tool like WinMerge or Kdiff3 (or TortoiseMerge). There's no benefit in trying to find out what exact changes you did if they're not evident from the log.

For the future... You don't need to learn the complete Subversion book by heart but you should get to know the basic concepts, esp. when they've proven to be an issue in your daily work.

like image 98
Álvaro González Avatar answered Oct 04 '22 22:10

Álvaro González