In Mercurial, can obsolete changesets be forced to become not obsolete?

I have come up with the following bash function - a hack and likely dependents on mercurial version but has been working well for years. Takes revset as parameter.

function hg_unhide() {
  for i in $(hg --hidden  log --template '{node}\n' -r "$1"); do
    hg --hidden debugobsolete --index | grep $i | awk '{ print $1;}' | \
      xargs -r hg --hidden debugobsolete --delete
  done
}

You can't unmark a change as obsolete, but you can bring it back to life using "hg touch <rev> --hidden", where touch is a new command that is part of the evolve extension.

FWIW. It's also possible to rebase the obsolete change, but you'll probably get fewer complications if you use touch.


Yes! you can remove obsolescence markers now. Perhaps it wasn't possible in 2015, when the question was asked.

The solution is in the Apr 18, 2018 answer from user377178: hg --hidden debugobsolete --delete <revindex>

Note that you do not use a changeset ID. You must use an index number (at least, with Mercurial 4.1.3). Run hg --hidden debugobsolete --index to get a list of changesets with obsolescence markers. Find the index of the changeset that you want to become non-obsolete, then run hg --hidden debugobsolete --delete <revindex> with the index substituted for revindex. Then your obsolete changeset is no longer obsolete. (It might be in the list multiple times--I have not thoroughly investigated.)

The debugobsolete command is currently not listed in the evolve user guide, even in the section on recovering obsolete changesets. However, it is listed in the Evolve How To guide.

Many thanks to user377178.

Tags:

Mercurial