Tags:
create new tag
view all tags
---+ Subversion -- Copying Changes Between Branches Copying specific changes between branches is covered well in [[http://svnbook.red-bean.com/en/1.4/svn.branchmerge.copychanges.html#svn.branchmerge.copychanges.specific][Chapter 4 of Version Control With Subversion]], but I thought a real-life example might be helpful to some people. I use version control for mantaining the PHP code for the Computational Lingustics database. I made a small, cosmetic change to the table-generating code in a file called searchcorpus.php, in the trunk branch. I wanted to backport it to release-2.2. Here is the sequence I used. Throughout this procedure my current directory was inside my working copy of release-2.2. ---++ Step 1: Locate the correct revision number. <verbatim> $ svn log svn://lemur.ling.washington.edu/admin/compling-database/trunk/searchcorpus.php ------------------------------------------------------------------------ r196 | brodbd | 2007-10-25 15:31:05 -0700 (Thu, 25 Oct 2007) | 1 line searchcorpus.php: Improve look of tables by inserting instead of empty fields. ------------------------------------------------------------------------ r106 | brodbd | 2007-10-16 16:38:04 -0700 (Tue, 16 Oct 2007) | 1 line ... </verbatim> Now I know I want revision 196. ---++ Step 2: Merge in the change. <verbatim> $ svn merge -c 196 svn://lemur.ling.washington.edu/admin/compling-database/trunk/searchcorpus.php U searchcorpus.php </verbatim> This pulled in the changes to searchcorpus.php from revision 196 (and only revision 196) of trunk and applied them to my working copy. I then ran =svn diff searchcorpus.php= to make sure the merge did what I wanted. If not, I could have used =svn revert= to back out the changes. ---++ Step 3: Commit the change. <verbatim> $ svn commit -m "searchcorpus.php: Backport cosmetic fixes from trunk r196." Sending searchcorpus.php Transmitting file data . Committed revision 197. </verbatim> Notice that my commit message indicates I'm importing changes from a specific revision number of another branch. This kind of bookkeeping is important in a complex project to make sure you don't accidentally merge the same change twice. While this case is a simple one involving only one file, this same concept works for revisions that encompass multiple files or even whole directory trees, including file additions or deletions. This gives =svn merge= a bit of an edge over =svn diff= followed by =patch= when porting complicated changes. -- Main.DavidBrodbeck - 25 Oct 2007
E
dit
|
A
ttach
|
Watch
|
P
rint version
|
H
istory
: r1
|
B
acklinks
|
V
iew topic
|
Ra
w
edit
|
M
ore topic actions
Topic revision: r1 - 2007-10-25
-
DavidBrodbeck
Home
Site map
Main web
Sandbox web
TWiki web
Main Web
Users
Groups
Index
Search
Changes
Notifications
RSS Feed
Statistics
Preferences
View
Raw View
Print version
Find backlinks
History
More topic actions
Edit
Raw edit
Attach file or image
Edit topic preference settings
Set new parent
More topic actions
Account
Log In
E
dit
A
ttach
Copyright © 2008-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback