Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fossil SCM - Revert to a specific revision like Mercurial

While using Mercurial if I want to change the current working copy with a specific revision I just do:

$> hg revert good_revision
$> hg commit -m "Now I'm in the good revision"

Then I can see that all my files are int the good_revision state and can start working on it.

So far on fossil I can do a revert but only on specific files, not the entire repository, and update or checkout don't seem to work as I would expect.

How can fossil revert my entire repository to a certain revision?

like image 746
Timoteo Ponce Avatar asked Dec 20 '22 13:12

Timoteo Ponce


1 Answers

I'm not sure I quite follow but I think what you want is to be able to create a "multiple heads on one branch" sutuation in Fossil. If yes, then Fossil does support this, just it calls branch's heads "leaves", and this process is called "forking".

To do that, you

fossil update good_revision

and then

fossil commit --allow-fork

You may now spawn fossil ui, navigate to your branch and see it having two leaves.

You now may close the then-current leaf.

Note that, while supported, this does not appear to be a recommended practice. Instead, Fossil recommends a rather peculiar approach for throwing away changes:

  1. Rename the branch at the "bad" leaf to "mistake" (or create that branch if it doesn't yet exist). By doing this you effectively "mark" the resulting subleaf as a mistake.

    Note that the name "mistake" name is just a convention; this branch does not exist in a freshly created repository.

  2. Close the "bad" leaf.

  3. Return to the last-good state using fossil update, continue hacking.

    Since that "last-good" commit still inherits the branch tag of its parent commit, the next commit you record will also inherit it and won't be on the branch "mistake".

For an example, see how it looks in the SQLite repo—there's a bunch of assorted short chains of commits on this branch. See also this.

like image 82
kostix Avatar answered Jan 31 '23 22:01

kostix