Importing legacy code from Subversion to Git

Atlassian has a very good tutorial on this. I suggest you read it first. Here is a simple example.

Install git-svn

A modern git installation may not include git-svn by default. On Ubuntu you can easily install it:

sudo apt-get install git-svn

Authors text file

To preserve the history readably, you’ll need to tell git svn the real names of the authors. There are tools to generate authors.txt, but for a small-ish team it might be easier to create it manually. Here’s a sample.

sarah = Sarah Woodall <sarah.woodall@mycompany.com>
otheruser = Other User <other.user@mycompany.com>

Subtree import recipe

This is how I imported a subdirectory of an old Subversion repo as a subtree of an existing Git repo, bringing in all relevant history with it. This assumes we want to import to the target repo’s default branch.

  1. Use git svn to create a temporary local git repo containing the data you want from Subversion
  2. Move the files into their own subdirectory
  3. Tag it: we’ll use this tag to define what gets exported
  4. Separately, clone the target Git repo, and move into it to do the rest
  5. Make a new subdirectory within it, as a home for the new subtree
  6. Export the files as they stand today (no history, just the files) from the temporary repo into the new subdirectory of the target repo
  7. Add and commit these new files to Git locally
  8. Bring in just the history, without affecting the files, by using git pull -s ours
  9. Finally, push the result
git svn clone --authors-file=authors.txt --trunk=mysubtree/ http://svnrepolocationURL/svn/mysvnrepo/
cd mysvnrepo
mkdir mysubtree
mv *.cpp *.hpp .cproject .project mysubtree
git commit -m"Moved mysubtree into own directory"
git tag -m"Tag current state of mysubtree ready for migration" MIGRATION_MYSUBTREE
cd ..
git clone https://myuser@myrepolocationURL/mytargetrepo.git
cd mytargetrepo
mkdir mysubtree
cd mysubtree
(cd ../../mysvnrepo && git archive MIGRATION_MYSUBTREE) | tar -xf -
cd ..
git add mysubtree
git commit -m"Initial commit of mysubtree, no history"
git pull -s ours ../mysvnrepo MIGRATION_MYSUBTREE
git push

Snag

My first go at the above (before I added Step 2) produced an error mesage from Git about unrelated history, at the “pull” stage. I attempted to force the issue by using “–allow-unrelated-histories”. This got the job done, but Git didn’t see the new files and the old ones as being the same, so the history, although present in the repo and browsable using Sourcetree, isn’t relatecd to the files (so “git log <filename>” doesn’t show what it should).

Old front page

It’s time to remove the word cloud from the front page, if only to stop people asking why Downham Market is so important to me (actually it isn’t, it’s just a place I passed though on a long walk more than ten years ago). Here it is, for nostalgia’s sake.

Words from my blog
See my blog for details

[Word cloud made using Wordle.]

Register to vote leaflets

It’s urgent to get people registered to vote before the election. Here are some leaflet designs that I’ve modified to add the important deadline dates. The originals were copied from https://twitter.com/sazmeister88 (I hope she doesn’t mind). I’m not proud of my edits, which were done in haste, but time is of the essence, so here they are in case anyone else can make use of them.

Register to Vote Leaflet page 1
Register to Vote Leaflet page 2

A plea to LibDems in Cambridge

Your publicity says that Brexit is the most important issue facing the country. I agree wholeheartedly. I have been campaigning with you against it.

Here in Cambridge we are sure to get a passionately pro-EU MP. The only realistic candidates are both of that opinion. I think the better choice is Daniel Zeichner MP because he’s a voice of reason within the Labour Party, and as an MP he can have the most influence on the leadership. You prefer your own man. OK.

But given the scale of the disaster facing the country, the question of who gets to be MP for Cambridge is just not that important. What matters is to win as many seats as we can from the parties who are set on steering us towards the edge of the precipice. We can all do that best by directing our efforts to other constituencies.

As a Labour Party member with experience of the party’s organizational techniques, I can be most useful in a place where there is a straight, winnable fight between Labour and the forces of darkness. The obvious choice for me therefore is Peterborough. So today I have contacted the secretary of Peterborough Labour Party and volunteered my services.

I urge you to do likewise: go outside the city and direct your efforts where you can make a real difference on the most important issue. Please give it some serious thought.

Update: the excellent Get Voting tactical voting dashboard from Best for Britain supports my view. It recommends “either Labour or Lib Dem” in Cambridge (and it notes the “current Labour MP’s excellent record on Europe in Parliament”). Meanwhile for Peterborough it urges a Labour vote, and in both South Cambs and South-East Cambs it recommends Lib Dem.

A drawing a day for 2019

I don’t draw enough, so I made a resolution to do one a day this year. I’m curious to see how the drawings change with practice. Here are the first five. I’ve put them on Instagram as well. Not sure whether I’ll publish the whole lot: scanning and uploading seems to be more fuss than just doing the drawings.

Fairphone 2 proximity sensor

I’ve learned the solution to an annoyance with the otherwise lovely Fairphone 2.

The proximity sensor wasn’t working properly for me. The problem seemed to get worse after I replaced the top module for a camera upgrade, but it had never been good. Taking a call almost always resulted in unpredictable weirdness—menu settings changing at random as I accidentally touched the screen, which should have been disabled, but wasn’t. Several goes at calibrating the sensor didn’t fix it.

A conversation with another user (there are other users!) gave me the solution. He pointed out that I was holding my phone in my left hand. Doesn’t every right-handed person? Apparently not. I’ve been holding phones in my non-dominant hand all my life, using the other to write notes or whatever, but it seems I’m not typical, and the proximity sensor on the phone is asymmetrically placed, at the top left corner of the phone screen.

So I have retrained myself to hold this phone in my right hand. Problem solved—it now works reliably.

In Cambridge, Vote Labour

Furious, yesterday evening, to see Lib Dems all over the streets of Chesterton like a rash, throwing huge efforts into — what? Into trying to unseat a passionately pro-European MP! One who is a voice of reason in the Labour Party nationally, one who cares about all the best things they care about (electoral reform, green issues, refugees, …).

Just a few miles outside this city in any direction are Tory-held constituencies where the only possible contender is a Lib Dem, and where huge swathes of the population voted Remain — where there is some chance that they could use their energies to achieve something worth achieving, to help in some small way to avert the coming national disaster.

Well, I guess they’ve achieved one small thing: they’ve prompted a moment of clarity in this muddle-headed and dithering erstwhile Labour activist. At last I have seen one thing clearly enough to know which side of the fence I’m on. Daniel Zeichner in Parliament is an indisputable force for good. If the election nationally turns out the way the polls suggest, his presence in the PLP will be even more important than it is already. We need him to help pick up the pieces and rebuild a credible opposition. Don’t mess that up, please! In Cambridge, vote Labour.