mercoledì 8 febbraio 2017

How to destroy my fossil repository in one step!

Fossil and Git are two great softwares, and I use them day by day.
Unluckily the former has less support by integrated environment, IDE, and this makes a little easier to deal with Git when working with mainstream development frameworks. But luckily, Fossil has a way to export to Git and, much more itneresting, to do a bidirectional import/export that is to export and re-import a git repository. In other words, you can work on a repository with both git and fossil pretty much at the same time.

Today I decided to realign my fossil repo to a git one, so to have the same logs and timeline available both from command like (i.e., fossil) and IDE tools. But I messed up everything:

fossil export 
  --git 
 --export-marks /sviluppo/fossil/luca.fossil.marks 
  /sviluppo/fossil/luca.fossil
  | git fast-import 
    --export-marks=/sviluppo/fossil/luca.fossil

Who catch the error?
Well, the git mark points to the fossil repository file, not the mark file!
Boom!
A whole repository destroyed in a few seconds.

The only thing that can save in such a situation is a backup, but, shame on me, I didn't have a fully recent one, so I lost part of the history.
Lesson learned: always do a backup before acting on a repository, even if you are supposed to only read from it (as in an export phase).
Lesson learned: do not trust the shell to complete paths and filenames for you.

Nessun commento: