Difference between revisions of "Svn practices"

From Apache OpenOffice Wiki
Jump to: navigation, search
(replaced links to incubator pages)
 
(34 intermediate revisions by 2 users not shown)
Line 3: Line 3:
 
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.
 
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.
+
SVN Client 1.7 is recommanded to use for AOO development. It's strongly recommended use alternative name for svn's subcommand, like co-checkout, ci-commit, up-update, di-diff, and so on.
  
 
__TOC__
 
__TOC__
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
<nowiki>svn co https://svn.apache.org/repos/asf/incubator/ooo/trunk ooo</nowiki>
 
  
*Grab a branche
+
<source lang="bash">
 +
svn co https://svn.apache.org/repos/asf/openoffice/trunk aoo
 +
</source>
  
<nowiki>svn co https://svn.apache.org/repos/asf/incubator/ooo/branches/AOO34/main/sw sw</nowiki>
+
*Grab a branch
This get the source code for writer module from AOO34 branche
+
  
*Get the latest changes into your working copy
+
<source lang="bash">
 +
svn co https://svn.apache.org/repos/asf/openoffice/branches/AOO410 aoo410
 +
</source>
  
execute 'svn update' in working directory. It is ooo or sw for above cases.
+
*Grab a specific directory from a branch
 +
 
 +
<source lang="bash">
 +
svn co https://svn.apache.org/repos/asf/openoffice/branches/AOO410/main/sw sw
 +
</source>
 +
 
 +
This gets the source code for Writer module (named "sw") from the AOO410 branch
 +
 
 +
*Get the latest changes into your working copy
  
This command will attempt to merge the public changes with the local changes if any.
+
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
 
*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 filename
svn log -r m<br />
+
svn log filename<br />
+
  
*Check changes & Create patch for specific revision
+
Also show information about the paths that were changed in each displayed revision.
 +
svn log -v
  
svn diff -r m:n > n.patch
+
Show for specific revision.
 +
svn log -r m
 +
 
 +
*Organize logical changes by changelist
 +
Use cl instead of changelist for convenience.
 +
 
 +
svn changelist tocload-feature filename1 filename2 ...
 +
 
 +
*Check changes and create a patch from local changes
 +
When creating patch, combine all your changes into a patch.
 +
 
 +
The path in patch should at least start in "main" or top directory.
 +
 
 +
svn diff filename1 filename2 > n.patch
 +
 
 +
*Create 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.
 +
 
 +
*Discard local changes and revert to unmodified state
 +
 
 +
svn revert
  
 
==Write access==
 
==Write access==
*Commit your changes
+
*Apply patch when review other's code change
Change can be comitted in by
+
Make sure current directory is consistent with path in patch, like "main".
svn commit -m "comment"  
+
However, this is not recommended if you are commit a patch. Since it is lack of information for contributors and may also cause unwanted changes.
+
  
*Check changes before commit
+
svn patch n.patch
  
svn status
+
Reverse patch:
  
*Specify in the command line a list of the files/dirs that are changed to avoid accidentally committing unwanted changes.
+
svn patch --reverse-diff n.patch
  
svn commit change1 change2
+
*Check changes before committing them
  
*Template for the log files should be used
+
svn status
 +
and / or
 +
svn diff
 +
svn diff --changelist tocload-feature
 +
 
 +
*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]
 +
svn commit -m "comment" --changelist tocload-feature
 +
 
 +
*Committing a patch
 +
Prepare a commit-comment file (e.g. mychangelog.txt) by using the relevant parts of this template:
  
 
   Patch by:
 
   Patch by:
Line 57: Line 104:
 
   Found by:
 
   Found by:
 
   Review by:
 
   Review by:
 +
  Tested by:
  
svn commit -F ../mychangelog.txt change1 change2
+
and then commit it by running either
 +
svn commit -F mychangelog.txt [filenames]
 +
svn commit -F mychangelog.txt --changelist tocload-feature
  
Update bugzilla with revision information for cross reference when you are done with the commit
+
*Update Bugzilla
 +
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 branche.
+
There at least two situations that you need to work with a branch.
Change you will made is complicated or you want to share it with others during development.
+
* If the changes you are about to make are complicated or you want to share them with others during development.
  
You may also need work with brache created by others. For example, after AOO 3.4 is released, a branch for AOO 3.4.1 was created.  
+
* 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' twice, 'svn merge' should be used if you get a fix need be submitted to both the 3.4.1 branch and main line.
+
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 branche
+
*How to create a branch
  
<nowiki>svn copy https://svn.apache.org/repos/asf/incubator/ooo/trunk  \
+
<source lang="bash">
           https://svn.apache.org/repos/asf/incubator/ooo/branches/tocloading \
+
svn copy https://svn.apache.org/repos/asf/openoffice/trunk  \
       -m "Creating a private branch for toc loading of word document."</nowiki>
+
           https://svn.apache.org/repos/asf/openoffice/branches/tocloading \
 +
       -m "Creating a private branch for toc loading of word document."
 +
</source>
  
*Keep a branche in sync
+
*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
  
$ svn merge ^/ooo/trunk
+
*Reintegrate a branch
 
+
*Reintegrate a branche
+
 
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 branche
+
*Remove a branch
Once a branche is integrated back. It is useless and can be removed.
+
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"
+
  
 +
$ svn delete ^/ooo/branches/tocloading -m "Remove branch of toc loading"
  
 
==Reference==
 
==Reference==
 +
SVN Basics
 +
http://openoffice.apache.org/svn-basics.html
 +
 
A guide for new committers:
 
A guide for new committers:
 
http://www.apache.org/dev/new-committers-guide.html
 
http://www.apache.org/dev/new-committers-guide.html
Line 111: Line 165:
 
SVN Best Practices
 
SVN Best Practices
 
http://svn.apache.org/repos/asf/subversion/trunk/doc/user/svn-best-practices.html
 
http://svn.apache.org/repos/asf/subversion/trunk/doc/user/svn-best-practices.html
 +
 
[[Category:Documentation]]
 
[[Category:Documentation]]

Latest revision as of 13:37, 24 March 2014

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. It's strongly recommended use alternative name for svn's subcommand, like co-checkout, ci-commit, up-update, di-diff, and so on.

Read-only access

  • Grab the whole source code from main trunk
svn co https://svn.apache.org/repos/asf/openoffice/trunk aoo
  • Grab a branch
svn co https://svn.apache.org/repos/asf/openoffice/branches/AOO410 aoo410
  • Grab a specific directory from a branch
svn co https://svn.apache.org/repos/asf/openoffice/branches/AOO410/main/sw sw

This gets the source code for Writer module (named "sw") from the AOO410 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 filename

Also show information about the paths that were changed in each displayed revision.

svn log -v

Show for specific revision.

svn log -r m
  • Organize logical changes by changelist

Use cl instead of changelist for convenience.

svn changelist tocload-feature filename1 filename2 ...
  • Check changes and create a patch from local changes

When creating patch, combine all your changes into a patch.

The path in patch should at least start in "main" or top directory.

svn diff filename1 filename2 > n.patch
  • Create 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.

  • Discard local changes and revert to unmodified state
svn revert

Write access

  • Apply patch when review other's code change

Make sure current directory is consistent with path in patch, like "main".

svn patch n.patch

Reverse patch:

svn patch --reverse-diff n.patch
  • Check changes before committing them
svn status

and / or

svn diff
svn diff --changelist tocload-feature
  • 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]
svn commit -m "comment" --changelist tocload-feature
  • 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]
svn commit -F mychangelog.txt --changelist tocload-feature
  • 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 to 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/openoffice/trunk  \
           https://svn.apache.org/repos/asf/openoffice/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 branch of toc loading"

Reference

SVN Basics http://openoffice.apache.org/svn-basics.html

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

Personal tools