Difference between revisions of "Svn practices"
(→Write access: restructuring: review status first, then commit own change or patch, then update bugzilla (checkpoint save)) |
(separate range-diff from rev-diff, also many minor style changes) |
||
Line 9: | Line 9: | ||
==Read-only access== | ==Read-only access== | ||
*Grab the whole source code from main trunk | *Grab the whole source code from main trunk | ||
− | + | ||
+ | svn co https://svn.apache.org/repos/asf/incubator/ooo/trunk aoo | ||
*Grab a branch | *Grab a branch | ||
− | + | svn co https://svn.apache.org/repos/asf/incubator/ooo/branches/AOO34 aoo34 | |
+ | |||
+ | *Grab a specific directory from a branch | ||
+ | |||
+ | svn co https://svn.apache.org/repos/asf/incubator/ooo/branches/AOO34/main/sw sw | ||
+ | |||
This gets the source code for sw (i.e. the writer module) from the AOO34 branch | This gets the source code for sw (i.e. the writer module) from the AOO34 branch | ||
*Get the latest changes into your working copy | *Get the latest changes into your working copy | ||
− | + | Change into the working directory such as aoo or sw for the above case and run | |
− | + | svn update | |
− | This command will | + | This command will merge the public changes with the local changes if there are any. |
*Update to a specific revision | *Update to a specific revision | ||
− | svn update -r xxxx | + | svn update -r xxxx |
*Check changes history | *Check changes history | ||
− | svn log<br /> | + | svn log<br /> |
− | svn log -v<br /> | + | svn log -v<br /> |
− | svn log -r m<br /> | + | svn log -r m<br /> |
− | svn log filename<br /> | + | svn log filename<br /> |
− | *Check changes | + | *Check changes and create a patch from a specific revision |
− | svn diff -r m:n > n.patch | + | svn diff -c m > n.patch |
+ | |||
+ | *For changes consisting of many revisions n..m use | ||
+ | |||
+ | svn diff -r m:n > n.patch | ||
+ | instead. | ||
==Write access== | ==Write access== | ||
Line 62: | Line 73: | ||
*Update Bugzilla | *Update Bugzilla | ||
− | Update | + | Update [https://issues.apache.org/ooo/ bugzilla] with revision information for cross reference when you are done with the commit and know the revision numbers. |
− | == Working with branch == | + | == Working with a branch == |
− | There at least two situations that you need work with | + | There at least two situations that you need work with a branch. |
− | + | * If the changes you are about to make are complicated or you want to share them with others during development. | |
− | + | * There are interesting upstream branches created by others. For example, after AOO 3.4 is released, a branch for the AOO 3.4.x micro releases was created. | |
− | Instead of doing 'svn commit' | + | Instead of doing 'svn commit' both on trunk and the release branch use 'svn merge' if your fix needs to be submitted to both code lines. |
There are also other cases in which you don't want to commit in development mainline directly. | There are also other cases in which you don't want to commit in development mainline directly. | ||
− | *How to create a | + | *How to create a branch |
− | + | svn copy https://svn.apache.org/repos/asf/incubator/ooo/trunk \ | |
https://svn.apache.org/repos/asf/incubator/ooo/branches/tocloading \ | https://svn.apache.org/repos/asf/incubator/ooo/branches/tocloading \ | ||
− | -m "Creating a private branch for toc loading of word document." | + | -m "Creating a private branch for toc loading of word document." |
− | *Keep a | + | *Keep a branch in sync |
Subversion is aware of the history of your branch and knows when it split away from the mainline. To perform a sync merge, first make sure your working copy of the branch is “clean”—that it has no local modifications reported by 'svn status'. Then simply run: | Subversion is aware of the history of your branch and knows when it split away from the mainline. To perform a sync merge, first make sure your working copy of the branch is “clean”—that it has no local modifications reported by 'svn status'. Then simply run: | ||
− | $ pwd | + | $ pwd |
− | /home/user/tocloading | + | /home/user/tocloading |
+ | $ svn merge ^/ooo/trunk | ||
− | + | *Reintegrate a branch | |
− | + | ||
− | *Reintegrate a | + | |
When your new feature is done. It needs to be merged back to mainline. Before do that, sync the brache with mainline and commit your changes. Then | When your new feature is done. It needs to be merged back to mainline. Before do that, sync the brache with mainline and commit your changes. Then | ||
− | $ svn merge --reintegrate ^/ooo/branches/tocloading | + | $ svn merge --reintegrate ^/ooo/branches/tocloading |
and commit again | and commit again | ||
− | *Remove a | + | *Remove a branch |
− | Once a | + | Once a branch is integrated back it has become useless and can be removed. |
− | + | ||
− | + | ||
+ | $ svn delete ^/ooo/branches/tocloading -m "Remove branche of toc loading" | ||
==Reference== | ==Reference== |
Revision as of 13:56, 6 June 2012
This page is under review. This line will be removed after it is done.
This page gathered svn practices frequently used by contributors and committers. If you have any advice to this page, please feel free to update it or discuss your idea in ooo-dev mail list.
SVN Client 1.7 is recommanded to use for AOO development.
Read-only access
- Grab the whole source code from main trunk
svn co https://svn.apache.org/repos/asf/incubator/ooo/trunk aoo
- Grab a branch
svn co https://svn.apache.org/repos/asf/incubator/ooo/branches/AOO34 aoo34
- Grab a specific directory from a branch
svn co https://svn.apache.org/repos/asf/incubator/ooo/branches/AOO34/main/sw sw
This gets the source code for sw (i.e. the writer module) from the AOO34 branch
- Get the latest changes into your working copy
Change into the working directory such as aoo or sw for the above case and run
svn update
This command will merge the public changes with the local changes if there are any.
- Update to a specific revision
svn update -r xxxx
- Check changes history
svn log
svn log -v
svn log -r m
svn log filename
- Check changes and create a patch from a specific revision
svn diff -c m > n.patch
- For changes consisting of many revisions n..m use
svn diff -r m:n > n.patch
instead.
Write access
- Check changes before committing them
svn status
and / or
svn diff
- Commit your changes
Don't forget to specify the list of files/dirs that are changed to avoid accidentally committing unwanted changes.
svn commit -m "comment" [filenames]
- Committing a patch
Prepare a commit-comment file (e.g. mychangelog.txt) by using the relevant parts of this template:
Patch by: Suggested by: Found by: Review by: Tested by:
and then commit it by running either
svn commit -F mychangelog.txt [filenames]
- Update Bugzilla
Update bugzilla with revision information for cross reference when you are done with the commit and know the revision numbers.
Working with a branch
There at least two situations that you need work with a branch.
- If the changes you are about to make are complicated or you want to share them with others during development.
- There are interesting upstream branches created by others. For example, after AOO 3.4 is released, a branch for the AOO 3.4.x micro releases was created.
Instead of doing 'svn commit' both on trunk and the release branch use 'svn merge' if your fix needs to be submitted to both code lines.
There are also other cases in which you don't want to commit in development mainline directly.
- How to create a branch
svn copy https://svn.apache.org/repos/asf/incubator/ooo/trunk \ https://svn.apache.org/repos/asf/incubator/ooo/branches/tocloading \ -m "Creating a private branch for toc loading of word document."
- Keep a branch in sync
Subversion is aware of the history of your branch and knows when it split away from the mainline. To perform a sync merge, first make sure your working copy of the branch is “clean”—that it has no local modifications reported by 'svn status'. Then simply run:
$ pwd /home/user/tocloading $ svn merge ^/ooo/trunk
- Reintegrate a branch
When your new feature is done. It needs to be merged back to mainline. Before do that, sync the brache with mainline and commit your changes. Then
$ svn merge --reintegrate ^/ooo/branches/tocloading
and commit again
- Remove a branch
Once a branch is integrated back it has become useless and can be removed.
$ svn delete ^/ooo/branches/tocloading -m "Remove branche of toc loading"
Reference
A guide for new committers: http://www.apache.org/dev/new-committers-guide.html
Merge Instruction from FreeBSD: http://wiki.freebsd.org/SubversionPrimer/Merging
SVN book: http://svnbook.red-bean.com/en/1.7/svn-book.html
SVN Best Practices http://svn.apache.org/repos/asf/subversion/trunk/doc/user/svn-best-practices.html