Random notes about using SVN, Atmel Spaces and maybe other things

Go To Last Post
15 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

 

So I have been tinkering with some code for a new utility for creating AVR header files, details here:

 

https://www.avrfreaks.net/forum/b...

 

Several times I have made amendments and thought "rats! I should have kept that the way it was" or "I wished I'd kept a copy of the way I was doing this 3 versions ago". If this scenario sound familiar to you and the way you develop code then I'm going to suggest you may benefit from some revision control done properly. If you don't do it then in C at least you can find yourself with things like:

#ifdef OLD_VERSION_OF_CODE
void do_stuff(parms) {
#ifndef DO_IN_REVERSE
    for (int i=0 ; i < 20; i++) {
#else
    for (int i=19 ; i > 0; i) {
#endif
        PORTB = somedata[i];
    }
}
#else
void do_stuff(parms) {
    int i =0;
    while (somedata[i] != 0xA5) {
        PORTB = somedata[i++];
    }
}
#endif

If that looks complicated it's because it is - I effectively have 3 versions of the same thing there and I just enable one with some #defines. Before long things like this can get out of hand. How much clearer would it be if my "current" source code just contained:

void do_stuff(parms) {
    int i =0;
    while (somedata[i] != 0xA5) {
        PORTB = somedata[i++];
    }
}

but then I have lost the "history" of the other versions I used to use. Suppose now I think "actually this worked better in the version that counted backwards" then I need to look through a heap of source.c.last_wednesdays_version or source.c.20160403 or maybe a pile of .zip files to find the one that still had the (latest) of that old code I now want to reinstate.

 

So I decided I'd like some version control. In this case I could commit the 3 different versions as I complete them and at any time I could go back (searching either by date or descriptive label) to find what I was looking for and pull that one out. All the code would be held in a "database" (usually called a "repository" or just "repo") that has easy to access tools.

 

The code I'm actually going to version control here is actually Python, not C, and that's almost worse as you simply cannot do stuff like:

#ifdef OLD_VERSION_OF_CODE
  ...
#ifndef DO_IN_REVERSE
  ...
#else
  ...
#endif
  ...
#else
   ...
#endif

as there is no concept of a "pre processor". So unless you save a copy of the source after each and every change you cannot just "switch bits on " or "switch bits off" in a big amalgam of all your versions as you might in C. So the need for revision control here is possibly even more pressing.

 

So my next decision is "which revision system to use". There are a number of "big names": Subversion, Git, Mercurial (and others) but for a "one guy working on his own" my choice would always be Subversion as it's very easy to use. Git is extraordinarily powerful (especially teamed with Gerrit/Jenkins/etc) but it's probably overkill for the simple case of someone who just wants to manage releases and be able to cherry pick out of old code or "side experiments" etc.

 

So I choose SVN.

 

Now the way SVN (indeed most of them) work is, as I mentioned above - a core database (repository) holds images of all the files you choose to version manage and all the different versions (most systems store the base copy and then the changes each time you commit a new version) so you then have to decide where you want this repository to be held.

 

A fundamental choice is "online" or "offline". Again, if you are one guy just working alone it may well be sufficient to just hold the repository in a folder on your hard drive (perhaps on an external drive or even a memory stick?) but oyu have possibly more data security if you keep your repository "in the cloud" - that is online somewhere where it will be held on professional hard drives/servers that are maintained 24-7-52 by professionals with proper backup strategies and so on.

 

Another choice to make is how to operate SVN (or Git or whatever). Part of the reason I (personally - because this is a personal choice) would choose SVN is that in Windows there is an excellent tool called TortoiseSVN which makes it very easy to use SVN through a GUI interface.

 

I actually wanted to do this from Ubnutu Linux not Windows so I went looking for a "equivalent of TortoiseSVN for Linux" and the thing I found was:

 

http://rabbitvcs.org/

 

That's completely new to me so in part this will be a learning experience.

 

So anyway, I still have to decide whether I want to use a local (file://) or online (http://) repository for my files so I actually started by running an experiment in Linux to make sure the RabbitVCS was installed OK and to get the first idea of how to use it. To do that I didn't want to bother with the complexity of an online repository (well not yet) so I started out running an experiment to version manage a couple of files in a directory that were effectively just junk and set up a local repository on my hard drive.

 

As I say I was doing this in Linux and using Rabbit but most of what I do in the follwoing would have been very similar if I went with Tortoise and Windows.

 

(to be continued... we're in the middle of intense thunder and I want to post this before I lose what I typed so far if the power goes!)

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

PS in passing must just mention this which is what happens when thunder causes planes to divert from Stansted and fly at about 2000ft right outside my window:

 

 

I had to look that up on flightradar24.com as I couldn't believe how low it just went past!! Similarly this one:

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Anyway, back to my SVN experiments. So as a test I just started with some junk files I happened to have on my drive - my plan was to wrap some SVN revision control around these pre-existing files:

 

 

and for starters I was just going to make a local repository (gonna use the term "repo" from now on). So to do that I dropped back a directory level:

 

 

And used "Create New folder" to create a folder that would become my SVN repository. It needs to be an empty folder (because SVN will write some stuff into it) so I figured "Create new" was the easy way to start. I called it "avr-myrepo":