154
edits
Changes
→Svn basic commands
You are good to go - you can start working on your task
==Start working on a project (Start start a new task)==
# If you have not already branched trunk:
#: branch/tag trunk into a sub-directory under your workspace. Use your task name/description so you can refer to it easily later.
# When done, go to the team page and set trunk's status back to committed with the same info as before.
==Continue working on a your current task on a new computer (public computer)==
# Checkout only your branch/task
# Work on your task and keep committing the changes as you go.
#: Note that you are responsible to keep you work safe. If someone gains access to your code and repository, YOU are responsible for it and its consequences.
==Continue working on a your task (everyday work)==
# Update the repository to get the most recent changes.
# (optional and only if needed:) If trunk is updated by someone else since the time you branched it, you can merge the '''updated''' trunk into your branch to get the latest additions and modifications of trunk in your branch.
# when done for the time being, commit your work and comment, noting the stage of your work.
==Release a your completed task (Submitting submit an Assignment assignment or a Releaserelease)==
# Do this when a major task is finished and it is time to present it to your professor.
#: This is not necessarily to hand in a new release. It could be at any time you feel you are one step closer to the end of the project.
#: Name the tagged directory relative to its state (i.e. name it '''R0.4''' and comment it with task name '''Text Editor''')
#: If this is a fix to a previously released trunk, add the release revision after the release number: (i.e R0.41 and comment it as '''Fixed backspace bug in Text Editor''')
# your Your prof will later update the repo on their computer and get the your Release.
=Standard svn tree structure=
==== branches ====
* '''branches''' is the common directory for all team members' workspaces.
* Each team member should create within '''branches''' their own home directory or '''workspace''' (member-id1, member-id2,...) for their own development tasks within '''branches'''. * Each team member should divide their '''workspace ''' into several sub-directories (workspaces) during the development of the project. These workspaces(Task1, Task2, ...) are usually copies of the '''trunk''' to be worked on.*: ''These sub-directories(Task1, Task2,...) are called branches of trunk. When the The word '''branch''' is used as a verb, it means copying the whole '''trunk''' into a sub-directory, in within '''branches'''.
==== tags ====
* '''tags''' is the directory that holds '''copies''' of successful stages of '''trunk''' throughout the development of the project. (''Also called as '''Milestonesmilestones''''')
* '''tags''' are never modified or edited. ''You may branch a directory of tag into branches under a workspace and then modify the branch and apply the changes back to trunk, but you should never change the contents of a tag''
*: When the word The verb '''tag''' is used as a verb, it means copying copy the whole trunk into a sub-directory, in '''tags'''.* The action of '''tag'''ing the trunk into '''tags''' is often referred to as a '''release'''.
* We use the '''tags''' directory to submit the work for marking. ''Your instructor will specify the requirements of a release.''
** A release is usually tagged by a version number like: R0.1, Prj0.2, As1_1.0
* '''trunk''' should never hold non-compiled code. Usually trunk is an exact copy (or better than) the latest version in '''tags'''.
* If the repository only contains one project, then trunk has no project level sub-directory and is the root of the project. If the repository holds more than one project, trunk is divided into several sub-directories - one for each project.
*: ''In this case, we divide '''tags''' into exactly the same project sub-directories as present in '''trunk'''''
=Svn svn basic commands=A few important facts and terminology to help clarify the basic actions:* A The purpose of a code repository is to keep track of all of the modifications done to a project by its team members. *:*In a project that is tracked by a code repository (version-controlled , or in short , versioned), you can focus on any changes change during the project's development life; such as, who modified/added/deleted what and when. You can undo work or rollback the work to any development stage of the development and much more.
* SVN is a client/server repository;
** Code is kept resides on a server and those members who have access can copy the whole or parts of the project code to their local machines, work on the whole or parts and then apply their changes back to the server.** Because the code is kept resides on a server, one member may be unaware of the changes made by another member, unless the other has applied the changes to the server and the member has update updated their local copy. **: That is why timely and often frequent communication between amongst team members is highly vital for to the project's success of the project. This can is easily be accomplished through the project wiki page (team page) and IRC* A code repository manages the merging the of modifications of different members' code. However When this may fail and as a result fails, the repository will sometimes be in a conflict state.*: * Conflicts can be easily be edited, saved , and resolved using the tools provided by SVN.* A '''Versionversion-controlled or versioned''' file is a file that is handled and being tracked by a repository.
<hr>
* For all the command lines below, note that if If the userid and password is are not set to be saved in svn, then you need to add
<big><pre>
--username stdId --password stpassword
</pre></big>
: to the end if each svn command. (userid and password '''ISare''' set to be saved by default, make . Make sure to reboot your lab computer for the uid userid and pass password to be removederased)
== checkout ==
To '''checkout''' is to download the code from a repository server as a whole, or partial, partially to a versioned directory on the client, so that you can start working on the code.
*GUI:
# Create a directory on your local machine
svn checkout svn://zenit.senecac.on.ca/repoid local_directory --username stdId --password stpassword
</pre></big>
== commit ==
* GUI
# Right click on the directory or file that you wish to which you made modifications commit and click on '''SVN Commit''' # In the Commit Dialog box write enter a short description (a few words) to explain explaining what is you have modified and is being committed are committing and then click on okOK.
* Command Line
<big><pre>svn commit locdir\branches\stdId\SomeDirectory
<big><pre>svn commit locdir\branches\stdId\SomeDirectory\somefile.cpp
-m "Added comments to foo() is somefile.cpp"</pre></big>
'''''IMPORTANT: committing as often as you can will make makes you visible and show shows that you are actively work working on your project. When working on your branch, use the commit as often as you save your work, and comment your commits as much as you can. A consistent and regular number of commits per week is the best demonstration of your commitment to the your project and work.'''''
== update ==
* GUI
* Command Line
: while in the local directory
<big><pre>svn update</pre></big>
: OR from anywhere<big><pre>svn update LocalDirecotyPathLocalDirectoryPath</pre></big>: OR for a single file<big><pre>svn update LocalDirecotyPathLocalDirectoryPath/somefile.whatever</pre></big> == branch/tag ==To '''branch'''ing or to '''tag'''ging ==To branch or tag is to '''copy''' one directory into anotheron the server. The purpose of the copying dictates calling it this action either a '''branch''' or a '''tag'''.*To '''branch''' is to '''copy''' into the '''branches''' directory or one of its sub-directories for further development*To '''tag''' is to '''copy''' into the '''tag''' to directory as a release of the next stage of your project (also called to release a milestone)
*GUI, Branching
# Right click on '''trunk''' in your local repository files and under the "TortoiseSVN" sub-menu click on "Branch/tag"
# Click on the button at right side of '''To URL''' and to browse and find your '''workspace''' under '''branches ''' directory (ie.eg. ''svn://zenit.senecac.on.ca/oop344_113repXX/branches/stdId'') and select itthat '''workspace'''.# Add the branch task name (that is usually the name of the task to do) to the end of the selected path: ''svn://zenit.senecac.on.ca/oop344_113repXX/branches/stdId/'''nameOfTask'''''# In '''Log message''' type ''"Branching to do what ever task that is to be donenameOfTask"''# Leave the rest of the options to remain as they are and click on okOK.#: This will make a copy of trunk under your within '''workspace/nameOfTask''' on the server.
*GUI, Tagging
# Right click on '''trunk''' in your local repository files and under the "TortoiseSVN" sub-menu click on "Branch/tag"
# Click on the button at right side of '''To URL''' and to browse and find your the '''tags''' directory (ie.eg. ''svn://zenit.senecac.on.ca/oop344_113repXX/tags'') and select itthat '''workspace'''.# Add the tag name (that is usually a release id like R0.6) to the end of the selected path: ''svn://zenit.senecac.on.ca/oop344_113repXX/tags/'''R0.X'''''
# In '''Log message''' type ''"Tagging release whatever"''
# Leave the rest of the options to remain as they are and click on okOK.#: This will make a copy of trunk under your within '''tags/R0.X''' on the server.'''''Note that this will happen on the server; therefore to actually have this applied your local copy, you should update your repository (for this see [[#update|Update]])
* Command Line, Branching
<big><pre>svn copy svn://zenit.senecac.on.ca/oop344_113repXX/trunk
svn://zenit.senecac.on.ca/oop344_113repXX/branches/stdId/nameOfTask
-m "Branching to work on whatever tasknameOfTask"</pre></big>#* Note that the : This type of branching we use in here is called a [http://svnbook.red-bean.com/en/1.5/svn-book.html#svn.branchmerge.commonpatterns.feature Feature Branch]
* Command Line, Tagging
<big><pre>svn copy svn://zenit.senecac.on.ca/oop344_113repXX/trunk
svn://zenit.senecac.on.ca/oop344_113repXX/tags/R0.6
-m "R0.6 is released"</pre></big>
'''''Note that branching or tagging occurs on the server. Therefore to have this action applied to your local copy, you need to update your repository (for this see [[#update|Update]]) == Merge merge ==To '''merge, ''' is to merge back integrate the changes made in a branch in the '''branches''' directory back in the '''trunk''' directory.
*GUI
# First [[#update|updateUpdate]] the whole repository.# Right click on '''trunk ''' and then in '''TortoiseSVN''' sub-menu click on '''merge'''# In merge options, select the second one that is '''Reintegrate a branch''' and then click on next# In '''From Url''' browse and find the branch you just sub-directory under '''branches''' with your completed your task on and then click on nextNext. (ie.eg. svn://zenit.senecac.on.ca/oop344_113repXX/branches/stdId/nameOfTask)#: If browsing is not available you can use the '''repo browser''' to find the path to the branch sub-directory and copy and paste it.# Before merging you can click on test merge to run a simulation and see if the merge is successfulsucceeds# click Click on merge to merge the branch back into trunk. #: note that the merging is happening occurs on your local copy of the code and not in the repositoryon the server
# Edit and resolve possible conflicts
# Compile and test the merged trunk# communicate Communicate with other team members and to make sure that no one else is committing to the trunk.# '''[[#commit|commitCommit]]''' the your changes to trunk # Note others Notify other team members that the you have finished your commit is done!
*Command line
#Follow all the precautionary steps stated above and then:
<big><pre>
cd locdir
svn merge --reintegrate
svn://zenit.senecac.on.ca/oop344_113repXX/branches/stdId/nameOfTask
-m "merging back the comments nameOfTask to trunk"
</pre></big>
<big><pre>
svn commit -m "committing work done on the tasknameOfTask"
</pre></big>