Difference between revisions of "Subversion"

From Embedded Xinu
Jump to navigation Jump to search
(Marked page as historical (due to switch to git))
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
[[w:Subversion (software)|Subversion]] is the [[w:Revision Control|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.
+
{{Historical}}
  
== Common Commands ==
+
A [http://acm.mscs.mu.edu/wiki/Subversion general use guide] is now available on the [http://acm.mscs.mu.edu/ Student ACM Wiki].  Also there is a posting of commands in the Cudahy 310 Computer Lab.
  
''If you ever forget a command, there is a list posted in CU 310.''
+
Xinu specific information about the repository is available in the [[trac:Subversion|trac wiki]].
 
 
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>.
 
 
 
=== <code>checkout</code> ===
 
 
 
''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 one of the following commands:
 
 
 
svn checkout https://xinu.mscs.mu.edu/svn/mips/trunk ~/xinu
 
svn checkout svn+ssh://svn@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:
 
 
 
svn update
 
 
 
Once the update is complete you should be "at revision 1428."
 
 
 
=== <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
 
 
 
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>propset</code> ===
 
 
 
''This command is aliased with <code>svn pset</code> and <code>svn ps</code>.''
 
 
 
In <code>mips/trunk/</code> all files should have the <code>svn:keywords "Id"</code> property set on them.  This will automatically fill in the <code>$Id$</code> tag.  At some point there may be a pre-commit hook on the subversion repository to enforce this rule, but for the time being the following command can be used:
 
 
 
svn propset svn:keywords "Id" <list of files>
 
 
 
This will set the property on every file in the list of files.  If you perform a <code>svn status</code> after this there should be a <code>M</code> in the second column of files you've set the property  on.
 
 
 
=== <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
 
 
 
=== <code>add</code> & <code>remove</code> ===
 
 
 
''The <code>remove</code> command is aliased with <code>svn delete</code>, <code>svn del</code>, and <code>svn rm</code>.''
 
 
 
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:
 
 
 
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 ==
 
 
 
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.
 
 
 
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.
 
 
 
Here a few (slightly less common) subversion commands
 
 
 
=== <code>revert</code> ===
 
 
 
Sometimes you'll make changes to a file and later decide it was a waste (or more likely you changed a file to get XINU running and don't want to commit that file).  You could carefully undo every change you've made to the file, but that seems not elegant and downright tedious.  Thus we have the <code>revert</code> command that will rollback the changes to the most recently checked out version.  The command is simple:
 
 
 
svn revert path/to/file
 
 
 
Followed by text that will confirm the reverted files (you can revert multiple files with the same command).
 
 
 
=== <code>copy</code> ===
 
''This command is aliased with <code>svn cp</code>.''
 
 
 
Largely this command is used for creating branches or tags in the repository.  Subversion does lightweight copies so this is typically a quick operation.  This example will create a <code>test</code> branch under <code>mips/branches</code> that was copied from <code>trunk</code> at creation time.
 
 
 
svn copy https://xinu.mscs.mu.edu/mips/trunk https://xinu.mscs.mu.edu/mips/branches/test
 
 
 
After which you will be prompted for a log message.  You could also append a <code>-m "- created branch for testing purposes"</code> which will use that text as the log message.
 
 
 
== Repository Layout ==
 
 
 
Note that not everyone will have full (read and write) access to the entire repository, however read access is granted to the majority of folders.  A grammar that describes the repository follows:
 
 
 
          URI ::= svn+ssh://svn@xinu.mscs.mu.edu/<repo>
 
                | http[s]://xinu.mscs.mu.edu/svn/<repo>
 
 
        <repo> ::= mips/<svn-dir>
 
                | intel/<svn-dir>
 
                | ppc/<svn-dir>
 
                | debugger/<svn-dir>
 
                | tools/<tool-dir>
 
                | projects/<project-dir>
 
                | <math>\epsilon</math>
 
 
    <tool-dir> ::= console/<console-dir>
 
                | debugger/<svn-dir>
 
                | firmware/
 
                | uboot-img
 
                | <math>\epsilon</math>
 
 
<console-dir> ::= unix/<svn-dir>
 
                | windows/<svn-dir>
 
 
 
    <svn-dir> ::= trunk | branches | tags | <math>\epsilon</math>
 
 
    <proj-dir> ::= rebooter
 
                | windows-tools
 
                | cosc198-netaa
 
                | cosc198-netpj
 
                | cosc198-mempj
 
                | <math>\epsilon</math>
 
 
 
The <proj-dir> is the most unstable directory of XINU since various team projects come and go throughout the year.
 

Latest revision as of 22:00, 11 September 2013

✘ This page is currently inactive and is retained primarily for historical interest.
A historical page is usually one that is no longer maintained or no longer relevant.

A general use guide is now available on the Student ACM Wiki. Also there is a posting of commands in the Cudahy 310 Computer Lab.

Xinu specific information about the repository is available in the trac wiki.