开发者

Is the SVN Book Inconsistent about "Switching a Working Copy"?

The SVN Book chapter on "Switching a Working Copy" seems to say both that performing a switch 1) makes your working copy identical to the branch switched to (as if one had done a fresh checkout) and 2) preserves edits to your working copy (so that you could commit them to the branch switched to.) This sounds inconsistent to me, because if the switch makes it like a fresh checkout, then your edits can't be preserved. Can anyone please explain?

Here are the relevant quotes:

After “switching” to the branch, your working copy is no different than what you would get from doing a fresh checkout of the directory.

...

For example, suppose you have a working copy of /calc/trunk and make a number of changes to it. Then you suddenly realize that you meant to make the开发者_StackOverflow社区 changes to a branch instead. No problem! When you svn switch your working copy to the branch, the local changes will remain. You can then test and commit them to the branch.

TIA


Check out the box on that page called "Switches and Updates":

Have you noticed that the output of svn switch and svn update look the same? The switch command is actually a superset of the update command.

When you run svn update, you're asking the repository to compare two trees. The repository does so, and then sends a description of the differences back to the client. The only difference between svn switch and svn update is that the update command always compares two identical paths.

That is, if your working copy is a mirror of /calc/trunk, then svn update will automatically compare your working copy of /calc/trunk to /calc/trunk in the HEAD revision. If you're switching your working copy to a branch, then svn switch will compare your working copy of /calc/trunk to some other branch-directory in the HEAD revision.

In other words, an update moves your working copy through time. A switch moves your working copy through time and space.

Basically, think of the "switch" command as telling SVN, "hey, back my working copy by this new repository URL, then update my working copy to the latest version of that new URL".

So, the comment that "switch" makes your working copy look like a fresh checkout of the new URL is correct if you have no local modifications to your working copy. It is not accurate if you have local modifications. In that case, your working copy would look like a fresh checkout of the new URL, with your modifications merged in.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜