with Subversion
CPS5401 19 Sep 2013 Umayanganie Munipala
Branches allow you to have customizations that need to be kept out of the main development line. If you are working in a team, a branch is a way to develop a major feature, stay up to date with changes your colleagues make, and only add your feature to the main development
Even If you work alone, it is an easy way to synchronize between more than one machine. (You could even imagine traveling without all your files, and installing them from the repository onto a borrowed machine as the need arises.) Having a source code repository is one way to backup your work.
CPS5401 19 September 2013
Subversion (SVN)
Directory versioning Atomic commits File and directory metadata Faster network access Requires less network access Branching and tagging are cheap
Repository remembers every change ever written to it: every change to every file, and even changes to the directory tree itself, such as the addition, deletion, and rearrangement of files and directories.
CPS5401 19 September 2013 8
Get a working copy Make changes in your copy Test them locally Integrate them with any changes made to the Repository Commit them back to the Repository Repeat these steps until a release is ready Tag the release Start making changes again for next CPS5401 19 September 2013 10 release
How to start
Subversion client is distributed as command-line tool and can be downloaded at:
http://subversion.tigris.org
For development more convenient is to use Subclipse plugin for Eclipse/Netbeans. Subclipse can be installed and updated from within :
http://subclipse.tigris.org/install.html
11
Netbeans SVN
URL of server that hosts svn
12
Netbeans SVN
Directory on server Side to check out (blank for whole Repository) Directory to place The files on your host
13
15
4.
To compare local and remote files double click on file CPS5401 19 September 2013
16
Resolving Conflicts
Once in a while, you will get a conflict when you update your files from the repository Subversion places conflict markersspecial strings of text which delimit the sides of the conflict - into the file to demonstrate the overlapping areas For every conflicted file Subversion places three additional files in directory:
filename.ext.mine - your file as it existed in your working copy before you updated your working copy - without conflict markers. This file has <<<<<<< filename your latest changes in it. your changes filename.ext.rOLDREV - the file that was the BASE revision before ======= you updated your working copy. It is the file that you checked out before you made your latest edits. code merged from repository filename.ext.rNEWREV - the file that your Subversion client just >>>>>>> revision received from the server when you updated your working copy. This file corresponds to the HEAD revision of the repository.
Directories are versioned items Deletes and moves are recorded Copy sources are remembered
CPS5401 19 September 2013 18
Revisions
Each time the repository accepts a commit, this creates a new state of the file system tree, called a revision.
Metadata
Any file or directory can store properties Properties are name/value pairs Some standard properties exist
svn:ignore svn:mime-type svn:eol-style
etc.
21
Subversion Hosting
When you decided to use Subversion in your project, then you will need a server where to place your code Our research group server is here: http://repository.cs.utep.edu/svn/hpcs List of sites that offer Subversion hosting:
http://subversion.tigris.org/links.html#hosting
22
23
References
Subversion home
http://svn.subversion.com/
Exercises
svn info
URL of the repository and the revision number Make sure its the working directory
svn co svn add svn status svn commit m xxx svn update
Exercises (conflicts)
how do deal with conflicting edits by two users of the same repository.? %% emacs firstfile # make some change %% svn commit -m "another edit to the first file" Sending firstfile svn: Commit failed (details follow): svn: Out of date: firstfile in transaction 5-1
26
Exercises (conflicts)
The solution is to get the other edit, and commit again. After the update, svn reports that it has resolved a conflict successfully.
%% svn update G firstfile Updated to revision 5. %% svn commit -m "another edit to the first file" Sending firstfile Transmitting file data . Committed revision 6.
G at the start of the line indicates that svn has resolved a conflicting edit.
CPS5401 19 September 2013 27
Exercises (conflicts)
If both students make edits on the same part of the file, svn can no longer resolve the conflicts. If both students make edits on the same part of the file, svn can no longer resolve the conflicts. %% svn commit -m "another edit to the first file" svn: Commit failed (details follow): type e to open the file in an editor Or type p for postpone and edit it later. After editing and resolving conflict commit the file
%% svn resolved firstfile Resolved conflicted state of firstfile %% svn commit -m "another edit to the first file"
CPS5401 19 September 2013 28
Conflict Options
- change merged file in an editor - show all changes made to merged file
(r) resolved
(dc) display-conflict - show all conflicts (ignoring merged version) (mc) mine-conflict - accept my version for all conflicts (same) (tc) theirs-conflict - accept their version for all conflicts (same) (mf) mine-full (tf) theirs-full - accept my version of entire file (even non-conflicts) - accept their version of entire file (same)
(p) postpone
(l) launch (s) show all
29
To see differences in various revisions of individual files First Update the svn svn diff firstfile
30
Create a file somefile and commit it to the repository. Then do rm somefile svn status
svn revert
deleted : brought back from repositary undo any local edits
When you are done editing, the branch edits can be added back to the trunk.
svn co file://pwd/repository/trunk mycleanproject
33