Additional ignore files, relative to repository root

Isaac Jurado diptongo at
Fri Sep 14 12:16:25 CDT 2012


I was looking at the ui.ignore config option and found that the file
paths are either absolute or relative to the working directory.  There
is currently no way to specify paths relative to the repository root.

In an attempt to make it work for the ui.ignore option I came out with
this simple and silly patch:

diff -r fc1a5d0eb3bb mercurial/
--- a/mercurial/	Thu Sep 13 14:33:10 2012 -0500
+++ b/mercurial/	Fri Sep 14 19:11:52 2012 +0200
@@ -128,7 +128,10 @@
         files = [self._join('.hgignore')]
         for name, path in self._ui.configitems("ui"):
             if name == 'ignore' or name.startswith('ignore.'):
-                files.append(util.expandpath(path))
+                if path.startswith("~~"):
+                    files.append(os.path.normpath(self._root + path[2:]))
+                else:
+                    files.append(util.expandpath(path))
         return ignore.ignore(self._root, files, self._ui.warn)


But before sending it formally, I would like some feedback about the

The idea is to have a special prefix or marker (in this case, a double
tilde "~~") to enable a resolution relative to the repository root.
Obviously, the caveat is that you want to load an ignore file named
"~~foo" relative to the working directory you would have to define it as

Any help... or approval?  ;-)


Isaac Jurado

"The noblest pleasure is the joy of understanding"
Leonardo da Vinci

More information about the Mercurial-devel mailing list