Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert repository to older version (without sparse revlog)

Our team is using Mercurial for version control, with the central repository located on a shared network drive (i.e. we are not using a server). Our company restricts what we can install on our computers, and everyone had Hg version 4.6. One of the team members used admin rights he has to install the latest TortoiseHg (4.9). It seemingly resulted in the central repository to be converted to the newest version. Now another team member, with the old Mercurial, cannot pull from the central repository. It says

repository requires features unknown to this Mercurial: sparserevlog

I read a bit about it, and it seems that this feature is not critical for us. Would it be possible to revert the central repository to the version without sparse revlog?

like image 251
texnic Avatar asked May 16 '19 14:05

texnic


2 Answers

With 4.9, new repositories will be created using sparse-revlog by default. However existing repositories are untouched. They stay in the same format they have been created with.

Avoiding the issue at repository creation

To prevent the users who upgraded to create sparse-revlog repositories he needs to set the following in his user configuration (hg config -e)

[format]
sparse-revlog = no

Do you have global control of your users configuration?

Downgrading existing repositories

If you want to downgrade such newly created repository you do the following:

  1. add the following to the repository configuration (hg config -l)
[format]
sparse-revlog = no
  1. run hg debugupgraderepo --run (with 4.7 or newer)

Upgrading existing repositories

If you want to upgrade existing created repository, the process is similar:

  1. add the following to the repository configuration (hg config -l)
[format]
sparse-revlog = yes
  1. run hg debugupgraderepo --run (with 4.7 or newer)

Note: the page https://www.selenic.com/mercurial/hgrc.5.html#format is outdated. The website for mercurial have been https://www.mercurial-scm.org/ for a couple of years.

like image 197
Pierre-Yves David Avatar answered Sep 30 '22 09:09

Pierre-Yves David


Normally it should be possible to instruct hg during a clone operation NOT to use a specific, newer repo format.

There are specific configuration options for this, as shown in the docs:

Config option: format

usegeneraldelta

Enable or disable the "generaldelta" repository format ... Enabled by default.

dotencode

Enable or disable the "dotencode" repository format ... Enabled by default.

usefncache

Enable or disable the "fncache" repository format ... Enabled by default.

usestore

Enable or disable the "store" repository format ... Enabled by default.

However for some reason there is no option listed corresponding to the newest repo format which as noted in the question is "sparse-revlog" (documented here).

But that seems to be just a documentation oversight, so similar to the answer to another question, you should be able to re-clone using a command similar to this:

hg clone --config format.sparse-revlog=no  <source> <dest>

This will require hg to NOT utilize that format, which means the older prior format should be what you get and will be compatible with your local hg clients.

Added info/explanation from a comment by Juan: this will work if (a) your clone source & destination are not on the same filesystem or (b) you add --pull.

(By default Mercurial will try to create hard links for speed & space savings. Avoiding hard links by cloning to different filesystems or different hosts altogether or by forcing the clone to not use hard links on the same filesystem by using --pull will allow the new repo to be created without sparse-revlog.)

I guess you would have to do this to replace every existing clone that has been pulled since the central repo was accidentally upgraded. I would plan that work carefully, to make sure no local changes are lost. You could to a local pull using the same config option to transfer commits from the old to new repos.

like image 21
StayOnTarget Avatar answered Sep 30 '22 09:09

StayOnTarget