11.07.2015 Views

Version Control with Subversion - Login

Version Control with Subversion - Login

Version Control with Subversion - Login

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Branching and Mergingchanges by running svn revert . -R (which will undo all local modifications) and starta long “what's going on?” discussion <strong>with</strong> your collaborators. If things look good, however,you can submit these changes into the repository:$ svn commit -m "Merged latest trunk changes to my-calc-branch."Sending .Sending button.cSending integer.cTransmitting file data ..Committed revision 357.At this point, your private branch is now “in sync” <strong>with</strong> the trunk, so you can rest easierknowing that as you continue to work in isolation, you're not drifting too far away from whateveryone else is doing.Why Not Use Patches Instead?A question may be on your mind, especially if you're a Unix user: why bother to usesvn merge at all? Why not simply use the operating system's patch command to accomplishthe same job? For example:$ cd my-calc-branch$ svn diff -r 341:HEAD ^/trunk > patchfile$ patch -p0 < patchfilePatching file integer.c using Plan A...Hunk #1 succeeded at 147.Hunk #2 succeeded at 164.Hunk #3 succeeded at 241.Hunk #4 succeeded at 249.doneIn this particular example, there really isn't much difference. But svn merge has specialabilities that surpass the patch program. The file format used by patch is quitelimited; it's able to tweak file contents only. There's no way to represent changes totrees, such as the addition, removal, or renaming of files and directories. Nor can thepatch program notice changes to properties. If Sally's change had, say, added a newdirectory, the output of svn diff wouldn't have mentioned it at all. svn diff outputsonly the limited patch format, so there are some ideas it simply can't express.The svn merge command, however, can express changes in tree structure and propertiesby directly applying them to your working copy. Even more important, this commandrecords the changes that have been duplicated to your branch so that <strong>Subversion</strong>is aware of exactly which changes exist in each location (see the section called“Mergeinfo and Previews”.) This is a critical feature that makes branch managementusable; <strong>with</strong>out it, users would have to manually keep notes on which sets of changeshave or haven't been merged yet.Suppose that another week has passed. You've committed more changes to your branch,and your comrades have continued to improve the trunk as well. Once again, you'd like toreplicate the latest trunk changes to your branch and bring yourself in sync. Just run thesame merge command again!$ svn merge ^/trunk--- Merging r357 through r380 into '.':U integer.cU MakefileA README93

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!