doing the warmup in Mercurial / Hg

December 31, 2008

S:\Hg\test>hg addremove -s 100 -v –time
adding ABC.txt
adding AC.txt
Time: real 0.316 secs (user 0.094+0.000 sys 0.141+0.000)

S:\Hg\test>hg status
A ABC.txt
A AC.txt

S:\Hg\test>hg commit -m “version A”

S:\Hg\test>hg status

S:\Hg\test>dir
 Volume in drive S is DATAPART1
 Volume Serial Number is EA76-AC34

 Directory of S:\Hg\test

31/12/2008  17:14    <DIR>          .
31/12/2008  17:14    <DIR>          ..
31/12/2008  17:14    <DIR>          .hg
26/12/2008  11:06                 3 ABC.txt
26/12/2008  11:07                 2 AC.txt
               2 File(s)              5 bytes
               3 Dir(s)  68,576,161,792 bytes free

S:\Hg\test>hg addremove -s 100 -v -n –time
removing AC.txt
adding BC.txt
Time: real 0.138 secs (user 0.047+0.000 sys 0.063+0.000)

S:\Hg\test>hg addremove -s 100 -v -n
removing AC.txt
adding BC.txt

S:\Hg\test>hg addremove -s 100  -n
removing AC.txt
adding BC.txt

S:\Hg\test>hg addremove -s 100
removing AC.txt
adding BC.txt

S:\Hg\test>hg status
A BC.txt
R AC.txt

S:\Hg\test>dir
 Volume in drive S is DATAPART1
 Volume Serial Number is EA76-AC34

 Directory of S:\Hg\test

31/12/2008  17:15    <DIR>          .
31/12/2008  17:15    <DIR>          ..
31/12/2008  17:15    <DIR>          .hg
26/12/2008  11:06                 3 ABC.txt
26/12/2008  11:07                 2 BC.txt
               2 File(s)              5 bytes
               3 Dir(s)  68,576,161,792 bytes free

S:\Hg\test>hg commit -m “version B”

S:\Hg\test>dir
 Volume in drive S is DATAPART1
 Volume Serial Number is EA76-AC34

 Directory of S:\Hg\test

31/12/2008  17:16    <DIR>          .
31/12/2008  17:16    <DIR>          ..
31/12/2008  17:16    <DIR>          .hg
26/12/2008  11:06                 3 ABC.txt
26/12/2008  11:07                 2 BC.txt
               2 File(s)              5 bytes
               3 Dir(s)  68,576,161,792 bytes free

S:\Hg\test>rm *.*
‘rm’ is not recognized as an internal or external command,
operable program or batch file.

S:\Hg\test>del *c*.*

S:\Hg\test>dir
 Volume in drive S is DATAPART1
 Volume Serial Number is EA76-AC34

 Directory of S:\Hg\test

31/12/2008  17:16    <DIR>          .
31/12/2008  17:16    <DIR>          ..
31/12/2008  17:16    <DIR>          .hg
               0 File(s)              0 bytes
               3 Dir(s)  68,576,161,792 bytes free

S:\Hg\test>hg addremove -s 100 -v -n
adding AC.txt
adding C.txt

S:\Hg\test>hg addremove -s 100  -n
adding AC.txt
adding C.txt

S:\Hg\test>hg status
? AC.txt
? C.txt

S:\Hg\test>dir
 Volume in drive S is DATAPART1
 Volume Serial Number is EA76-AC34

 Directory of S:\Hg\test

31/12/2008  17:16    <DIR>          .
31/12/2008  17:16    <DIR>          ..
31/12/2008  17:16    <DIR>          .hg
26/12/2008  11:06                 3 ABC.txt
26/12/2008  11:07                 2 AC.txt
26/12/2008  11:07                 2 BC.txt
26/12/2008  11:07                 1 C.txt
               4 File(s)              8 bytes
               3 Dir(s)  68,576,161,792 bytes free

S:\Hg\test>hg addremove -s 100
adding AC.txt
adding C.txt

S:\Hg\test>hg status
A AC.txt
A C.txt

S:\Hg\test>hg commit -m “version C”

S:\Hg\test>hg status

S:\Hg\test>hg log
changeset:   2:abdb2197ace7
tag:         tip
user:        Conor Rafferty <cr@altmore.co.uk>
date:        Wed Dec 31 17:18:27 2008 +0000
summary:     version C

changeset:   1:5923d44d8871
user:        Conor Rafferty <cr@altmore.co.uk>
date:        Wed Dec 31 17:16:17 2008 +0000
summary:     version B

changeset:   0:dab6ac36cf73
user:        Conor Rafferty <cr@altmore.co.uk>
date:        Wed Dec 31 17:14:08 2008 +0000
summary:     version A
S:\Hg\test>dir
 Volume in drive S is DATAPART1
 Volume Serial Number is EA76-AC34

 Directory of S:\Hg\test

31/12/2008  17:18    <DIR>          .
31/12/2008  17:18    <DIR>          ..
31/12/2008  17:18    <DIR>          .hg
26/12/2008  11:06                 3 ABC.txt
26/12/2008  11:07                 2 AC.txt
26/12/2008  11:07                 2 BC.txt
26/12/2008  11:07                 1 C.txt
               4 File(s)              8 bytes
               3 Dir(s)  68,576,157,696 bytes free

S:\Hg\test>del *c*.*

S:\Hg\test>dir
 Volume in drive S is DATAPART1
 Volume Serial Number is EA76-AC34

 Directory of S:\Hg\test

31/12/2008  17:19    <DIR>          .
31/12/2008  17:19    <DIR>          ..
31/12/2008  17:18    <DIR>          .hg
               0 File(s)              0 bytes
               3 Dir(s)  68,576,157,696 bytes free

S:\Hg\test>hg addremove -s 100
removing ABC.txt
removing AC.txt
removing BC.txt
removing C.txt

S:\Hg\test>hg status
R ABC.txt
R AC.txt
R BC.txt
R C.txt

S:\Hg\test>hg commit -m “version D”

S:\Hg\test>dir
 Volume in drive S is DATAPART1
 Volume Serial Number is EA76-AC34

 Directory of S:\Hg\test

31/12/2008  17:19    <DIR>          .
31/12/2008  17:19    <DIR>          ..
31/12/2008  17:19    <DIR>          .hg
               0 File(s)              0 bytes
               3 Dir(s)  68,576,153,600 bytes free

S:\Hg\test>hg status

S:\Hg\test>hg update -C -r0
2 files updated, 0 files merged, 0 files removed, 0 files unresolved

S:\Hg\test>dir
 Volume in drive S is DATAPART1
 Volume Serial Number is EA76-AC34

 Directory of S:\Hg\test

31/12/2008  17:20    <DIR>          .
31/12/2008  17:20    <DIR>          ..
31/12/2008  17:20    <DIR>          .hg
31/12/2008  17:20                 3 ABC.txt
31/12/2008  17:20                 2 AC.txt
               2 File(s)              5 bytes
               3 Dir(s)  68,576,153,600 bytes free

S:\Hg\test>hg update -C -r1
1 files updated, 0 files merged, 1 files removed, 0 files unresolved

S:\Hg\test>dir
 Volume in drive S is DATAPART1
 Volume Serial Number is EA76-AC34

 Directory of S:\Hg\test

31/12/2008  17:20    <DIR>          .
31/12/2008  17:20    <DIR>          ..
31/12/2008  17:20    <DIR>          .hg
31/12/2008  17:20                 3 ABC.txt
31/12/2008  17:20                 2 BC.txt
               2 File(s)              5 bytes
               3 Dir(s)  68,576,153,600 bytes free

S:\Hg\test>hg update -C -r2
2 files updated, 0 files merged, 0 files removed, 0 files unresolved

S:\Hg\test>dir
 Volume in drive S is DATAPART1
 Volume Serial Number is EA76-AC34

 Directory of S:\Hg\test

31/12/2008  17:20    <DIR>          .
31/12/2008  17:20    <DIR>          ..
31/12/2008  17:20    <DIR>          .hg
31/12/2008  17:20                 3 ABC.txt
31/12/2008  17:20                 2 AC.txt
31/12/2008  17:20                 2 BC.txt
31/12/2008  17:20                 1 C.txt
               4 File(s)              8 bytes
               3 Dir(s)  68,576,153,600 bytes free

S:\Hg\test>hg update -C -r3
0 files updated, 0 files merged, 4 files removed, 0 files unresolved

S:\Hg\test>dir
 Volume in drive S is DATAPART1
 Volume Serial Number is EA76-AC34

 Directory of S:\Hg\test

31/12/2008  17:20    <DIR>          .
31/12/2008  17:20    <DIR>          ..
31/12/2008  17:20    <DIR>          .hg
               0 File(s)              0 bytes
               3 Dir(s)  68,576,153,600 bytes free

S:\Hg\test>

Taming the wild mustang that is GIT

December 30, 2008
Believe it or not, I had budgeted half a day for getting git installed, learned, and all the versions safely stowed away.
That was on Xmas eve (24th Dec.)
 
I’ve been on this every day since – gawd, its becoming an Odyssey.
 
SCM is a support to my software development, which is a support to my business (a user business, not technology based) and in a normal year (not like this current one) software dev would be <10% of our effort. I can sense the beauty of git, but A WEEK ! to get close to making the first LIVE COMMIT.
 
I’m going to assert that a large number of possible users will not be interested, or how shall I put it better, they’l be very interested in git, but that’s where it will stay. The blogosphere is littered with the burnt bodies of those who have tried to ride this dragon. Gawd its tempting to give up and install CVS, Mercurial or something, the only thing keeping me going is that I HATE quitting !
 
What is it about this stuff ? I am not unintelligent but struggling with this.
 
It seems like to do something simple you have to understand EVERYTHING –
its not like other systems with a clear set of “basic”, “intermediate” and “advanced” commands that are fairly standalone.
 
everything in git seems so interleaved – its like relativity, or nuclear physics !
I’m sure git nirvana is coming sometime for me,
gawd please may it be in this lifetime!
 🙂

Git on Windows / Git Tutorial / Git “warmup”

December 27, 2008

Here is a little exercise / tutorial / warm-up for someone starting out with Git. If you’re anyting like me you may find the tutorials etc. on git.or.cz a bit daunting. I recommend you try this after reading the user manual but before tearing your hair out trying to follow all the examples in the user manual. After you’ve followed this simple workflow, then go back to the more advanced stuff  in the tutorials and user manuals (like cloning repositories and creating and merging branches).

I created this exercise to try and model our workflow and what we wanted to use git for = tracking a project with multiple files where the filebase might change frequently from one version to the next. (For more on my first engagement with Git, see previous blog entry!)

Although Git has a Windows GUI, most of the documentation is aimed at the command line, so I recommend you dive in there. A smattering of basic Unix commands will help.

I’m a windows user and this is aimed at others like me, but I guess since its using the command line, a lot of it is relevant to Unix users too… just ignore any windows references if that’s you !

Setup your pretend project files

Create a folders called eg. swproj and swproj_files in some temp area (e.g. Desktop/Temp)

in swproj_files create:
ABC.txt
AC.txt
BC.txt
C.txt
content is simply name (with or without .txt, doens’t matter)

This is your test data, and you copy some or all of these into swproj as and when required (context will tell you)

Imagine a project that you are going to take through 4 progressively more recent versions labelled versionA through versionD. Each version will be made up of various subsets of the four files:

ABC.txt will be in versions A,B,C
AC.txt will be in versions A & C only
etc. etc.

Instead of changing the content and keeping the containers (i.e. files) static (which is quite trivial, even in git) here we are going to keep the file content static, but change the container arrangement for every version. This is the one thing I try when learning a new SCM, as SCM behaviour isn’t always what people might expect. Also, it closely models what I wanted git to do in real life, so that’s why we’re going this way.

A further exercise would be to try creating four versions of a project with the content changing but not the containers. I’ll leave that to the reader.

Setup a git repository in the project directory

open up git bash in swproj (right click on swproj in Explorer | Exporer Bar)

At the prompt

$ git init

creates the repository in a directory called .git under your working dir
have a look round .git to see whats inside, this will be added to as we go through the exercise
(I recommend you read the man pages as for each new command as I introduce it $ git help <command> will open the relevant man page in a new browser)

Create version A

Next, copy the .txt files into swproj

Now, lets create version A

$ git add *a*.txt

..puts all files with A in them in a temporary staging area of the repository, called the index, ready to be committed to versionA

$ git status

demonstrates what is in the index, and what is being left out

$ git commit -m “version A”

This creates the first version, and clears the index
need the -m bit otherwise it goes into a crappy editor we can’t get out of !!

$ git log

confirms that a commit has taken place and give the SHA1 identifier for the commit

$ git tag versionA <SHA1code>

is optional at this point to give the commit a human name, easier for doing rollbacks/resets to it later etc.
BTW only need enuff chars from the (very long) SHA1 hex codes to uniquely identify the commit in this repo – in small ones its as few as 4 chars.

But optional as can refer to commits by SHA1 also (again, as few chars as id it uniquely in the repo)
 $ git tag -l
will catalog all tags

Create version B

This should contain only ABC.txt and BC.txt. Version A had ABC.txt and AC.txt, so BC.txt has to be added to the index, and AC.txt has to be removed from the index.

$ git add BC.txt

$ git rm AC.txt

(NB when no wildcard, exact case is important !)
…prepares staging for version B
check what is being added/removed from the index by $git status again)

$ git commit -m “version B”

$ git tag versionB <sha1>

Create version C

$ git add *c*.txt
or
$ git add C.txt AC.txt

(puts C.txt and AC.txt into version C)

$ git commit -m “version C”

$ git tag versionC <sha1>

Create version D

None of the files are in version D, its empty

$ rm *.txt

$ git commit -a -m “version D”

commit -a detects that files have been deleted, and takes them out of the index !
could also have used $ git rm <specific files> and then $ git commit ..

$ git tag versionD <sha1>

Rollback to each of the versions, starting with version A

now for rollback – imagine we need to go back to various versions, e.g. someone asks us for a versionA

confirm dir is empty (delete files out of swproj)

$ git checkout versionA .

Is telling git to copy into the working tree all the files given by <path> parameter “.” 
This should produce ABC.txt and AC.txt in the folder, the two files we added to versionA

$ git checkout versionB .

will do the same for versionB, but don’t forget to clear the directory first of any files from versionA, as if they are not in version B, they will not be removed by default, and you could hand over a corrupted version.

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Another useful scenario:
You had a well defined version in your working tree but now you’ve hacked away at some files (e..g to learn how it works etc.) but want to go back to the last version

$ git reset –hard HEAD
or
$ git reset –hard
(HEAD is implicit if no other <commit> is given)

Will basically discard all your changes and bring you back to the “last known good”

To go back further to a particular version and delete all commits since then:

delete all files

$ git reset –hard versionA  

should produce ABC.txt and AC.txt in the folder, the two files we added to versionA
(NB need 2x ‘-‘ before hard – not sure if its showing up in this format, which looks like it blends them into one long hypen.)

$ git reset –hard versionB

should produce ABC.txt and BC.txt ONLY in the folder
NB the file NOT in this version was auto-removed !!

$ git reset –hard versionC

should produce ABC.txt, AC.txt, C.txt

$ git reset –hard versionD

should produce empty directory

NB git does not necessarily clear the directory and reinstate all the files every time you hard git-reset to a previous commit (git speak for “previous version”), however if a particular commit HAD FILES BEING REMOVED as part of the difference (i.e. if they were logged into staging as deletions) then the deletions will take place when hard git-resetting, which is why AC.txt disappeared as we moved from the hard reset of versionA to versionB, and why all files disappeared when versionD was hard git-reset

happy gitting !!

The hunt for an SCM tool – leads to GIT !

December 27, 2008

So there I was on Christmas Eve hacking away at a website’s code, having made an edit to about the 50th file over a three month period.

Not for the first time it occured to me that I needed some sort of software configuration support – indeed previously I’d read the very good SCM comparison on wikipedia (for some research on a recruitment project as it happens) and was surprised to see so many freeware/shareware/open source solutions had entered the market in the ten years or so since I’d last used one!

I’d made a mental note to go back to that list when I had some time so I guess that by Christmas Eve a combination of the stress of managing source code by hand must have reached critical mass, and that, combined with it being holiday time, gave me justification to commit the half-day or so I hoped it would take to pick out and install a decent solution.

Git seemed to score well and the more I read about it the more excited I became, especially when I read the history – conceived by one Linus Thorvald (that’s right – the inventor of Linux) to support the open source teams working on the latest versions of the Linux kernel. This stuff was coming with a fine pedigree.

There seemed to be a windows port also, and although fairly new, had become mature enough to win over a few friends for itself in the blogosphere so with their help I sat down and installed Git.

The installation was a dream, which is very rare for open source stuff, ESPECIALLY on Windows, however when I sat down to go through the tutorial and the user guide that’s when the fun started.

The tutorials were more aimed at either open source developers looking to hook into big open source projects to contribute (test and/or develope) where the projects were already well defined, or linux/c/shell heads.

The half-day got stretched and stretched, all the time it seemed I was just round the corner from enlightenment, so I kept plugging away. Plus I was desperate to get it dealt with quickly as I didn’t want to be sidetracked from the other project (itself a sidetrack) too long. All of which contributed to put me in a GIT-induced frenzy over the Christmas period. My partner, kids, parents, siblings etc. barely got a look in as I nerded away in an upstairs or faraway room somewhere. In my more lucid moments I questioned my own sanity, and in my less lucid moments I wondered if  someone had made the whole thing up as a wind-up to catch out non-hackers who wanted something for nothing.

I finally found an active forum on Git, in fact it was the definitive forum on Git, run by Junio Hamann, the guy Linus had put in charge of developing Git after he’d got the initial prototype of the ground. These guys were serious unix kernel guys and open source gurus but I was desperate to get somewhere (who knows what that feels like – hands up !) so I posted my feeble little newbie question on there just after midnight on Christmas day (or should I say Boxing Day) and switched back to the user manual.

Imagine my shock and surprise when none other than the legend himself Junio Hamano responded half an hour later! He gave me some great pointers, and over the next 24hour period with his and others’ help I finally got my head around how to do our basic workflow using Git.

As its quite complex, no sooner had I done it my little workflow mock up, than I did it again (taking my cue from Einstein, who used to derive relativity repeatedly) and then again, and then typed it all up, as the stuff is complex enough that if you didn’t use it for a while you’d be back close to square one.

I’m going to publish it now on this blog as I’m sure I’m not the only one who has / will come up against this.

Hello world!

December 27, 2008

Hello World!

Welcome to Silicon Mouth, a blog about my experiences as an IT Recruiter, IT user, IT nerd in Belfast, Northern Ireland (mainly) and some other places (occasionally).

I picked the name Silicon Mouth because I love the names Silicon Valley and Silicon Glen (in Scotland). Although Belfast is in a glen or valley, both these were taken, so I had thought “what other geographical feature”. Silicon Port, Silicon Harbour had their day – and then it came to me – Belfast is anglicised for Beal Feirste – the mouth of the (river) Farset. So mouth is the geographical feature that characterises Belfast.

Of course a mouth is also something that words come out of – and in Northern Ireland (which I’ll abbreviate a lot to NI) a “mouthpiece”, shortened to “mouth” is one who has a lot to say !

So its fitting – and so Silicon Mouth was born !

Not to give the impression that I’ve spent long hours on this – had the idea on the way back from a family trip into the city (St. George’s market and the Belfast Wheel) a few hours back, and so here it is.

Some may say that Silicon is a take on “Silly Con”, as my firstname is Conor, which sometimes gets shortened to Con (but not by me), so I’ll take the wind out of their sails by pointing that out here 🙂

Hope you enjoy my blog,

ciao