wiki:FAQ_UpDownloadSrc

Uploading and Downloading Your Code

In order to upload your code into nanoHUB, you'll need to use Subversion. If you're new to Subversion, check out this tutorial to get an overview of how it works. Once you upload your code into Subversion, you can download it onto any machine for further editing, and then commit your changes back to the repository.

Each of the nanoHUB projects has the following directory structure:

your-project/
    -> branches/
    -> tags/
    -> trunk/
        -> bin/
        -> doc/
        -> examples/
        -> middleware/
        -> rappture/
        -> src/

The most interesting directories are those under your-project/trunk. In particular your-project/trunk/rappture and your-project/trunk/src. If you are checking in your code for the first time, you'll want to separate your code into files related to the rappture gui and files that make up the science source.

The files related to the rappture gui should be placed into your-project/trunk/rappture. These generally include the tool.xml file and wrapper scripts used to process data before sending it to the science code. Most projects do not have any wrapper scripts and this is alright.

The files related to the science source should be placed into your-project/trunk/src. These tend to include any Makefiles and sources related to the science portion of your project.

Downloading The Repository

Before you can upload your source code into the repository, you need to download the repository to your computer. For this you'll need a Subversion client. You may already have one on your computer. Look around on your system, or type svn at the command prompt and see if it works. If not, then you can download the svn client.

Next checkout the repository that we've created for your project. Your starting repository has the basic directory structure described above. All you have to do is add your files.

On command-line clients, you can use the following command:

% svn checkout https://nanohub.org/tools/your-project/svn/trunk your-project

Be sure to change your-project to the name of your project. This will download all directories and code under the trunk directory, from the repository server to your local repository. The command will create a directory called your-project in the same directory you ran the command in. This is the directory that holds your local copy of the repository.

You can have as many local copies of a repository as you would like. The repository server at nanohub.org keeps track of all changes.

Adding Your Files

Before you add your files to the repository, you will need to make sure the files are located in your local copy of the repository that you just downloaded in the previous section.

Using subversion to upload your code is easy! The general formula for uploading new code is as follows:

  1. Use the add command to schedule your files to be added to the repository
  2. Use the commit command to send the changes to the repository

Here's an example of a new project that contains the following:

  1. 1 C++ source file, named mycppsrc.cc
  2. 1 Makefile
  3. 1 tool.xml
  4. 1 directory called examples

In this example the user has all of the above files in a directory named old_project_home.

The first thing you will want to do is move the files to their proper directories in the local copy of your new source code repository. The C++ source file, mycppsrc.cc, and the Makefile should be placed into the src directory. The tool.xml file and examples directory should be placed into the rappture directory.

% cd old_project_home
% cp mycppsrc.cc ~/your-project/src/.
% cp Makefile ~/your-project/src/.
% cp tool.xml ~/your-project/rappture/.
% cp -r examples ~/your-project/rappture/.
% cd ../

Because you just moved the locations of files, you should check to make sure file paths are still correct. All file paths should be relative, absolute file paths will lead to broken projects.

Next you need to tell svn to add these files to the local copy of the repository, and finally commit the changes to the repository server so everyone else can see your new files. If you do not commit your changes to the repository server, no one will be able to see the changes you have made.

% cd your-project
% svn add src/mycppsrc.cc src/Makefile rappture/tool.xml rappture/examples
% svn commit

The add command schedules the files to be added to the repository and the commit command actually sends them to the repository server. Note that when you added rappture/examples, you added all of the files under the examples directory as well. The add command adds files recursively. After issuing the commit command, you will be prompted to add a commit message, using your favorite text editor. Be sure to add a commit message this will help you figure out your last working version if you happen to commit a version of the code that breaks something.

Uploading In General

In general, after making changes to your code and testing those changes, you will want to upload the new version of your code to the repository server. To do this, just execute the commands:

% cd your-project
% svn commit

This will go through all of the directories under the directory your-project, gather any files that have changed, and send them to the repository server. Be sure to add a commit message this will help you figure out your last working version if you happen to commit a version of the code that breaks something.

Back to Frequently Asked Questions

Last modified 15 years ago Last modified on Apr 12, 2009 2:17:18 PM