Difference between revisions of "Subversion"

From Embedded Xinu
Jump to navigation Jump to search
m (mulug->xinu)
(Revamped to make more readable)
Line 1: Line 1:
Within the repo directory
+
[[w:Subversion (software)|Subversion]] is the source code control system that the [[XINU]] project uses to maintain its code base. All repositories are hosted by the [http://mulug.mscs.mu.edu Marquette University Linux Users Group] and are available for access by anyone who is part of the XINU team or upon special request.  Below is an explanation of how to use subversion (svn) and the layout of the repository.
  /usr/local/project/EmbeddedOS/repo
 
  
If you even forget a subversion command there are some posted in the 310 lab, or you can come here.
+
== Common Commands ==
  
To check out your branch into the directory of your choice, type
+
''If you ever forget a command, there is a list posted in CU 310.''
svn checkout svn+ssh://svn@xinu/xinu-mips/trunk ~/xinu-mips
 
of course ~/xinu-mips can be whatever directory you wish to store your code.
 
  
Now you have a private working copy of your branch in <tt>~/xinu-mips</tt>.
+
There are many subversion commands at your fingertips, but only 3-5 of them are used on a daily basis.  In this section we cover the <code>update</code>, <code>commit</code>, <code>checkout</code>, <code>add</code>, <code>remove</code>, and <code>status</code>.  All commands can be executed from any subversion checkout.  In our example we will assume our working copy is located at <tt>~/xinu</tt> and our repository is located at <tt>https://xinu.mscs.mu.edu/svn/mips/trunk</tt>.
  
Most svn commands should be executed from your working copy, so lets
+
=== <code>checkout</code> ===
  cd ~/xinu-mips
+
 
 +
''This command is aliased with <code>svn co</code>.''
 +
 
 +
Checkout will create a new working copy of a repository on your local machine.  This is done through the command:
 +
 
 +
svn checkout https://xinu.mscs.mu.edu/svn/mips/trunk ~/xinu
 +
 
 +
You may have to enter a username and password.
 +
 
 +
=== <code>update</code> ===
 +
 
 +
''This command is aliased with <code>svn up</code>.''
 +
 
 +
Update will synchronize a working copy with the most recent version stored in main repository.  While updating, all files that have been changed will display a status flag:
 +
* <tt>A</tt> -- A file was successfully added to the working copy.
 +
* <tt>D</tt> -- A file was successfully deleted to the working copy.
 +
* <tt>U</tt> -- A file was successfully updated in the working copy.
 +
* <tt>C</tt> -- Subversion failed to update the working copy to the most recent version. This must be <tt>resolved</tt>.
 +
* <tt>G</tt> -- Subversion successfully merged the working copy and the most recent version.
 +
 
 +
So, from our working copy we can type the command:
  
The first thing you will want to do before you start working is run:
 
 
  svn update
 
  svn update
or
 
svn up
 
this will update all the files any one may have changed.
 
  
Along with update, when you finish making changes you must commit
+
Once the update is complete you should be "at revision 1428."
them, this is done with
+
 
 +
=== <code>commit</code> ===
 +
 
 +
''This command is aliased with <code>svn ci</code>.''
 +
 
 +
Commit will send local changes on a working copy to the main repository.  It is greatly recommended that you <code>update</code> prior to committing, otherwise it is possible that a failure will occur.  To commit changes, use the command:
 +
 
 
  svn commit
 
  svn commit
or
 
svn ci
 
This should open up the editor of your choice (well whatever the system variable $EDITOR is set to), and you can type a log message which catalogs the changes you made.
 
  
Before you commit you should usually run
+
Optionally you can provide a list of files to commit if you do not want all your changes sent to the main repository.  Every commit has an associated log message which is written using your editor of choice after typing the command.  If you have not set an <code>$EDITOR</code> variable for you shell, you must do that (for bash this is done by <code>export EDITOR=vim</code> where <tt>vim</tt> is your editor of choice).
 +
 
 +
=== <code>status</code> ===
 +
 
 +
''This command is aliased to <code>svn st</code>.''
 +
 
 +
Status will let you see what files you have changed in your working copy as compared to the most recent version from the main repository.  The same flags are associated with the <code>status</code> command as with the  <code>update</code> command.  To view these changes, run the command:
 +
 
 
  svn status
 
  svn status
or
 
svn st
 
to see what changes are going to be made.  Each change is pre-pended with a character, usually M but sometimes it can be ?, !, A, or D (there are more, but they are less common).  ? means svn is unsure what to do, odds are you have added that file since the last update, you must tell svn to add it by running
 
svn add <file-path>
 
! similarly means that the file is missing and you probably deleted it, so
 
svn rm <file-path>
 
should do the trick, these commands will change the ? or ! into A or
 
D, respectively.
 
  
Another important letter is C, which means conflict and that you have
+
=== <code>add</code> & <code>remove</code> ===
to figure out what went wrong with the file, if you didn't make any
+
 
huge changes or don't mind losing your changes you can
+
''The <code>remove</code> command is aliased with <code>svn delete</code>, <code>svn del</code>, and <code>svn rm</code>.''
svn revert <file-path>
+
 
to revert to the latest revision you have, otherwise I suggest reading
+
After viewing a status you may face files with the flags <tt>!</tt> or <tt>?</tt>.  These mean a file is missing (<tt>!</tt>) or subversion does not know about a file (<tt>?</tt>).  Typically files with an <tt>!</tt> imply that they have been removed from the working copy, but subversion has not been informed about this change.  To do this, run:
up on it through svn help or the Internet.
+
 
 +
svn remove path/to/file
 +
 
 +
And subversion will change the status to <tt>D</tt>.  If you are removing a file using the subversion command will remove the file from the file system as well, if you remove a directory tree the tree will be removed after the commit.
 +
 
 +
Similarly, if a file has the <tt>?</tt> flag associated with it, subversion does not know it has to add the file to the working copy.  Like the remove command, this can be run by:
 +
 
 +
svn add path/to/file
 +
 
 +
If you add a directory tree, subversion will recursively add all files below the parent as well as the parent node.
 +
 
 +
Remember, none of these changes will be stored in the main repository until you <code>commit</code>!
 +
 
 +
== Other Commands ==
  
You can type svn help for a list of commands and
+
If ever you want a detailed description of a command (or just a list of commands) you can use subversions help feature.  <tt>svn help</tt> will provide a listing of the commands that are supported, while <tt>svn help <command></tt> provides a detailed description of what that command does.
svn help <command>
 
for help on a specific command.
 
  
I think that covers the majority of command to be used, if you want to
+
This should cover the majority of commands used in daily subversion usage.  If you want to know more about subversion the online [http://svnbook.red-bean.com/en/1.4/svn-book.html subversion book] is an excellent resource.
know more you can go to
 
<http://svnbook.red-bean.com/en/1.2/svn-book.html> which has
 
everything you want.
 

Revision as of 01:22, 13 May 2008

Subversion is the source code control system that the XINU project uses to maintain its code base. All repositories are hosted by the Marquette University Linux Users Group and are available for access by anyone who is part of the XINU team or upon special request. Below is an explanation of how to use subversion (svn) and the layout of the repository.

Common Commands

If you ever forget a command, there is a list posted in CU 310.

There are many subversion commands at your fingertips, but only 3-5 of them are used on a daily basis. In this section we cover the update, commit, checkout, add, remove, and status. All commands can be executed from any subversion checkout. In our example we will assume our working copy is located at ~/xinu and our repository is located at https://xinu.mscs.mu.edu/svn/mips/trunk.

checkout

This command is aliased with svn co.

Checkout will create a new working copy of a repository on your local machine. This is done through the command:

svn checkout https://xinu.mscs.mu.edu/svn/mips/trunk ~/xinu

You may have to enter a username and password.

update

This command is aliased with svn up.

Update will synchronize a working copy with the most recent version stored in main repository. While updating, all files that have been changed will display a status flag:

  • A -- A file was successfully added to the working copy.
  • D -- A file was successfully deleted to the working copy.
  • U -- A file was successfully updated in the working copy.
  • C -- Subversion failed to update the working copy to the most recent version. This must be resolved.
  • G -- Subversion successfully merged the working copy and the most recent version.

So, from our working copy we can type the command:

svn update

Once the update is complete you should be "at revision 1428."

commit

This command is aliased with svn ci.

Commit will send local changes on a working copy to the main repository. It is greatly recommended that you update prior to committing, otherwise it is possible that a failure will occur. To commit changes, use the command:

svn commit

Optionally you can provide a list of files to commit if you do not want all your changes sent to the main repository. Every commit has an associated log message which is written using your editor of choice after typing the command. If you have not set an $EDITOR variable for you shell, you must do that (for bash this is done by export EDITOR=vim where vim is your editor of choice).

status

This command is aliased to svn st.

Status will let you see what files you have changed in your working copy as compared to the most recent version from the main repository. The same flags are associated with the status command as with the update command. To view these changes, run the command:

svn status

add & remove

The remove command is aliased with svn delete, svn del, and svn rm.

After viewing a status you may face files with the flags ! or ?. These mean a file is missing (!) or subversion does not know about a file (?). Typically files with an ! imply that they have been removed from the working copy, but subversion has not been informed about this change. To do this, run:

svn remove path/to/file

And subversion will change the status to D. If you are removing a file using the subversion command will remove the file from the file system as well, if you remove a directory tree the tree will be removed after the commit.

Similarly, if a file has the ? flag associated with it, subversion does not know it has to add the file to the working copy. Like the remove command, this can be run by:

svn add path/to/file

If you add a directory tree, subversion will recursively add all files below the parent as well as the parent node.

Remember, none of these changes will be stored in the main repository until you commit!

Other Commands

If ever you want a detailed description of a command (or just a list of commands) you can use subversions help feature. svn help will provide a listing of the commands that are supported, while svn help <command> provides a detailed description of what that command does.

This should cover the majority of commands used in daily subversion usage. If you want to know more about subversion the online subversion book is an excellent resource.