Enable a mercurial extension in .hgrc only if it's present

519 Views Asked by At

I have a lot of things in my .hgrc file so I keep it in a repository and share it between computers.

I have a lot of extensions enabled in the [extensions] section, but I don't necessarily want to use all of them on all of my computers.

Unfortunately, whenever I try to use Mercurial with my shared .hgrc file on a computer where I don't have every single one of the specified extensions installed, I get a message of the form:

*** failed to import extension evolve from $HG_EXTENSIONS/mutable-history/hgext/evolve.py: [Errno 2] No such file or directory: '/home/botond/programs/mercurial/extensions/mutable-history/hgext/evolve.py'

every time I run any hg command!

Is there a way to avoid this? For example, is there a way to specify in the .hgrc file, "load this extension if you can find it, otherwise don't load it and just be quiet about it"? (Then, if I actually try to use the extension, I'd get an error.)


additional search terms:

  • How to conditionally enable Mercurial extensions
  • Activate Mercurial extension based on condition
  • Enable a Mercurial extension only if it exists
1

There are 1 best solutions below

5
On
  • Use Projrc extension
  • Enable all and any extensions in projrc's config
  • Disable missing|not needed files in .hg/hgrc