subversion-howto
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
subversion-howto [2009/06/18 12:13] – created bp | subversion-howto [2010/11/20 12:38] (current) – Added note about cheap copies when branching. bp | ||
---|---|---|---|
Line 123: | Line 123: | ||
svn cp trunk branches/ | svn cp trunk branches/ | ||
</ | </ | ||
- | Of course, this will include the full OOFEM, but there' | + | Of course, this will include the full OOFEM, but there' |
- | Creating | + | |
You can also create the branch directly without having a checked-out working copy: | You can also create the branch directly without having a checked-out working copy: | ||
Line 161: | Line 160: | ||
How do I merge the latest patches added to the trunk in my development branch? | How do I merge the latest patches added to the trunk in my development branch? | ||
- | Suppose that you want to synchronize | + | First, always remember |
- | < | + | If you've merged into a working copy that already |
- | $ pwd | + | |
- | / | + | |
- | $ svn merge http:// | + | |
- | --- Merging r345 through r356 into ' | + | It's time to use the svn merge command. This command, it turns out, is a very close cousin to the svn diff command (which you read about in Chapter 2, Basic Usage). Both commands are able to compare any two objects in the repository and describe the differences. The svn merge command is almost exactly the same. Instead of printing the differences to your terminal, however, it applies them directly to your working copy as local modifications. |
- | U button.c | + | |
- | U integer.c | + | **But which two trees should be compared? At first glance, the answer may seem obvious: just compare the latest trunk tree with your latest branch tree. But beware—this assumption is wrong, and has burned many a new user! Since svn merge operates like svn diff, comparing the latest trunk and branch trees will not merely describe the set of changes you made to your branch. Such a comparison shows too many changes: it would not only show the addition of your branch changes, but also the removal |
+ | ** | ||
+ | |||
+ | To express only the changes that happened on your branch, you need to compare the initial state of your branch to its final state. Using svn log on your branch, you can see that your branch was created in revision 341. And the final state of your branch is simply a matter of using the HEAD revision. That means you want to compare revisions 341 and HEAD of your branch directory, and apply those differences to a working copy of the trunk. | ||
+ | |||
+ | A nice way of finding the revision in which a branch was created (the “base” of the branch) is to use the --stop-on-copy option to svn log. The log subcommand will normally show every change ever made to the branch, including tracing back through the copy which created the branch. So normally, you'll see history from the trunk as well. The --stop-on-copy will halt log output as soon as svn log detects that its target was copied or renamed. | ||
+ | |||
+ | So in our continuing example, | ||
+ | < | ||
+ | $ svn log -v --stop-on-copy \ | ||
+ | | ||
+ | … | ||
+ | ------------------------------------------------------------------------ | ||
+ | r341 | user | 2002-11-03 15:27:56 -0600 (Thu, 07 Nov 2002) | 2 lines | ||
+ | Changed paths: | ||
+ | A / | ||
+ | $ | ||
</ | </ | ||
- | This basic syntax—svn merge URL—tells Subversion to merge all recent changes from the URL to the current working directory (which is typically the root of your working copy). After running | + | As expected, |
+ | Here' | ||
< | < | ||
+ | $ cd my-branch | ||
+ | $ svn update | ||
+ | At revision 405. | ||
+ | |||
+ | $ svn merge -r 341:405 http:// | ||
+ | U | ||
+ | U | ||
+ | U | ||
+ | |||
$ svn status | $ svn status | ||
- | M | + | M integer.c |
- | M button.c | + | M |
- | M integer.c | + | M Makefile |
+ | |||
+ | # ...examine the diffs, compile, test, etc... | ||
+ | |||
+ | $ svn commit -m " | ||
+ | Sending | ||
+ | Sending | ||
+ | Sending | ||
+ | Transmitting file data ... | ||
+ | Committed revision 406. | ||
</ | </ | ||
- | At this point, the wise thing to do is look at the changes carefully with svn diff, and then build and test your branch. Notice that the current working directory (“.”) has also been modified; the svn diff will show that its svn: | ||
- | After performing | + | **Notice that the commit log message very specifically mentions the range of changes that was merged into the trunk. Always remember to do this, because it's critical information |
+ | ** | ||
+ | For example, suppose you decide | ||
+ | |||
+ | The first step is to run svn log on the trunk, and look for a log message about the last time you merged from the branch: | ||
< | < | ||
- | $ svn commit | + | $ cd my-branch |
- | Sending | + | $ svn log |
- | Sending | + | … |
+ | ------------------------------------------------------------------------ | ||
+ | r406 | user | 2004-02-08 11:17:26 -0600 (Sun, 08 Feb 2004) | 1 line | ||
+ | |||
+ | Merged | ||
+ | ------------------------------------------------------------------------ | ||
+ | … | ||
+ | </ | ||
+ | |||
+ | Aha! Since all branch-changes | ||
+ | < | ||
+ | $ cd my-branch | ||
+ | $ svn update | ||
+ | At revision 480. | ||
+ | </ | ||
+ | # We notice that HEAD is currently 480, so we use it to do the merge: | ||
+ | |||
+ | < | ||
+ | $ svn merge -r 406:480 http://www.oofem.trunk/ | ||
+ | U | ||
+ | U button.c | ||
+ | U | ||
+ | |||
+ | $ svn commit -m " | ||
Sending | Sending | ||
- | Transmitting file data .. | + | Sending |
- | Committed revision | + | Sending |
+ | Transmitting file data ... | ||
+ | Committed revision | ||
</ | </ | ||
- | At this point, your private | + | |
+ | |||
+ | Now the trunk contains the complete second wave of changes made to the branch. | ||
+ | |||
+ | === Merging a branch to the trunk === | ||
+ | At some point, you'll be ready to merge the “synchronized” feature branch back to the trunk. To do this, begin by doing a final merge of the latest trunk changes | ||
+ | < | ||
+ | $ cd trunk-working-copy | ||
+ | |||
+ | $ svn update | ||
+ | At revision 1910. | ||
+ | |||
+ | $ svn merge http:// | ||
+ | http:// | ||
+ | U real.c | ||
+ | U integer.c | ||
+ | A newdirectory | ||
+ | A newdirectory/ | ||
+ | … | ||
+ | </ | ||
+ | By comparing the HEAD revision of the trunk with the HEAD revision of the branch, you' | ||
Line 205: | Line 285: | ||
--- src/ | --- src/ | ||
+++ src/ | +++ src/ | ||
- | @@ -6,7 +6,7 @@ | + | @@ -76,8 +76,9 @@ |
- | MODDIR | + | .... |
- | MODDIRS | + | |
# | # | ||
+#ifndef __ENABLE_COMPONENT_LABELS | +#ifndef __ENABLE_COMPONENT_LABELS | ||
Line 245: | Line 323: | ||
When you run "svn update", | When you run "svn update", | ||
- | How to avoid seeing generated files? | ||
Line 263: | Line 340: | ||
- | The definite information can be found on the Subversion project page http:// | + | The definite information can be found on the Subversion project page http:// |
subversion-howto.1245320026.txt.gz · Last modified: 2009/06/18 12:13 by bp