Writing software is complex task. In every microcontroller program you usually try to reuse previously written libraries, downloaded code and other data that is being updated. What if you are developing something in team? How to keep track of everything? Storing project files in directories eventually get messy – eventually you loose track of whats done. For instance some time you have written LCD library and used in several microcontroller projects. But eventually you found a bug, or optimized code. Normally you would have to copy new library files in every project to keep updated. This is hard when you already have dozens of projects. There is one way to stay organized by using version control software. In this case we will talk about SVN.
Subversion (SVN) is an open source system that allows controlling files and folders, keep track of changes made during time. Simply speaking SVN is a virtual file system that keeps track of every change in files, directories. It’s a smart way of storing project files either you are working alone or in team. Using this system smart you will always have things organized and never loose version of your files gain.
TortoiseSVN your repository tool
TortoiseSVN is popular tool to work with SVN system. You can download it from project site here. We won’t be discussing on how to install it on your machine as it is well described in documentation you can download here. So Assume you already downloaded installed one that fits to your operating system. For instance if you have 64-bit Windows – download TortoiseSVN-220.127.116.1159-x64-svn-1.7.7.msi or later release if its already there. After installation click right mouse button on any folder and you should see new menu items:
This means that installation went smooth and you can continue further. Before we begin there are couple terms to be remembered. Repository and working copy (WC).
Repository is a SVN itself where file structure is stored. It also keeps all changes since project creation. Every change is assigned with revision number to keep track. Each revision can be accessed ans used when needed. Changes cannot be made inside repository for this a local working copy is used. All changes are made here and then they are fixed in repository with new revision number.
Repo-browser gives us access to projects stored in repository. Using this tool we can create, import new projects, copy project to working copy and do other things. Let’s go by example to make it simpler. Create directory somewhere in your hard drive. For instance D:\SVN. Click right mouse button on it and select TortoiseSVN->Create repository here. What happens here is that folder becomes a place for repository where all necessary structure is created to hold your projects. If you open Repo-broser you will see that empty repository named file:///D:/SVN is created.
Now you can create or add your projects here. First of all create project folder where your project will be. Name it as you would name your next project. For instance AVRLCD:
And then in this folder create three additional folders named branch, tags and trunk. You should see this in Repo-browser:
So why these three weird folders? Each of them have special purpose. In trunk folder is stored your main project files. So its place for current project. Branch folder is used when your project evolves in to several related projects that have same history. Tag folder holds releases of project. So when we create new project or import existing one we always store it in trunk folder.
Now lets import existing project in to repository. To do so locate project folder in your hard drive, click right click on it and select TortoiseSNV->Import. A dialog window will pop up asking where to import project:
Obviously we tell to import project in to trunk folder of our AVRLCD project by writing URL: . file:///D:/SVN/AVRLCD/trunk. Be sure on each action to write short messages of your actions. This helps to keep track of whats done. After confirmation an import window opens where you can see what files were imported:
It automatically adds revision number to project. Don’t afraid if import fails. You can delete project in Repo-browser and start over. Note that import can be performed by simply dragging files in to directory. Once you have successfully imported or created project later actions with project files must be done using Working Copy of project.
We recommend EasyEDA for circuit design and PCB prototype
Using Working Copy
So lets say our project already sits in repository and we want to do some coding, adding new files and so on. We need to import project files to working directory. Simply create new folder in your desired place. For our project we can name it WC. Then go to Repository browser, click on your projects trunk folder right mouse button and select Checkout…
select Checkout directory your WC directory and click OK. Files from trunk folder is then copied to working directory.
Now you can go to WC directory and do your necessary changes, writing code, creating new files or deleting some.
Simple actions required in working copy
There are some rules you need to follow when working with working copy. Since working copy now holds some hidden information (in .svn folder) that keeps track of files, all file actions like craetion, or deletion must be done through TortoiseSVN menu. For instance if we need to delete some file, we must select it and delete with menu item from mouse right click: TortoiseSVN->Delete
Same situation with adding new files to working copy. Say you are creating new C file in your project named test.c. Create it and you will see difference in list:
Id doesnt have check mark what means SVN doesn’t know its here. To make it happen click on file right mouse button and select menu TortoiseSVN->Add. A small plus sign appears on file icon meaning that it will be added to repository on next commit.
If you edit existing files you don’t have to do additional actions. SVN will track changes automatically. Once you save edited file – a note mark will appear near file icon:
So say you are done for today and want to store current changes to repository. Just click on WC directory right mouse button and select SVN Commit. In next window you will see a list of files that will be changed in repository. Some of them will be modified, some of them will be deleted or added. In message window be sure to add brief note on whats changed.
Once you click OK changes will be made to repository:
As you can see revision number of project increased. As we mentioned SVN repository keeps all files from beginning of project creation. So you can always reverse back to earlier revision if needed. This can be done by changing revision number in repository browser. This is it for now. Next time we will see more cool features of SVN.