Hello, fellow fossilers,

A few minutes ago i made a horrible mistake in a fossil repo and felt
compelled to post a minor warning/gotcha for other developers out there. The
solution to the mistake also points out a nice side-effect of the
single-file _FOSSIL_ metadata approach (as opposed to using subdirs for repo
metadata).

(To be clear, the problem here was all my fault, not fossil's.)

i was doing some "old-school-style" refactoring, something like:

~> perl -i -pe 's|WHIO_ENABLE_ZLIB|WHIO_CONFIG_ENABLE_ZLIB|g' $(find . -type
f | xargs grep -l WHIO_ENABLE_ZLIB)

In english: that replaces WHIO_ENABLE_ZLIB which WHIO_CONFIG_ENABLE_ZLIB in
all files under the current dir (including subdirs).

After doing so i wanted to see what files had been modified:

~> fossil status
fossil: not within an open checkout

Doh!

After a moment it was clear what i had done - a text replace in _FOSSIL_,
which of course corrupted it.

For a fossil repo, there is a trivial workaround:

~> mkdir foo
~> cd foo
~> fossil open /path/to/original.fossil
~> mv _FOSSIL_ ..
~> cd ..
~> rm -fr foo

(By sheer cosmic coincidence, i didn't even lose my un-pushed wiki changes
because i had exported them beforehand so that the wiki would be included in
the search/replace operation.)

On a Subversion repo, or most other system where SCM metadata is stored in
multiple subdirectories, this recovery would have been a lot more difficult
(and would have required online access to the repo). (Yeah,
i've also screwed up such repos via this same mistake before.)

So the lessons are:

a) Don't screw up your _FOSSIL_ file. This is a no-brainer, obviously, but
sometimes we act as if we have no brains and we do something like i
demonstrated at the top of this post.
b) If you do screw up _FOSSIL_, recovery is trivial. At most you'll lose any
un-pushed wiki/ticket/etc changes.

Happy fossiling!

-- 
----- stephan beal
http://wanderinghorse.net/home/stephan/
_______________________________________________
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users

Reply via email to