[PATCH] handle relative paths for hgrc's ignore files
Roger Pate
roger at qxxy.com
Tue Jun 1 12:17:55 CDT 2010
# HG changeset patch
# User Roger Pate <roger at qxxy.com>
# Date 1275411353 14400
# Node ID abcaddaadfc893794166c9d4dcd7a8c0d5238e82
# Parent c61442f6d106ae2b91672898715e0fee26eeb54d
handle relative paths for hgrc's ignore files
diff -r c61442f6d106 -r abcaddaadfc8 doc/hgrc.5.txt
--- a/doc/hgrc.5.txt Mon May 31 13:47:51 2010 +0200
+++ b/doc/hgrc.5.txt Tue Jun 01 12:55:53 2010 -0400
@@ -836,12 +836,14 @@
Encoding to try if it's not possible to decode the changelog using
UTF-8. Default is ISO-8859-1.
``ignore``
- A file to read per-user ignore patterns from. This file should be
- in the same format as a repository-wide .hgignore file. This
- option supports hook syntax, so if you want to specify multiple
- ignore files, you can do so by setting something like
- ``ignore.other = ~/.hgignore2``. For details of the ignore file
- format, see the |hgignore(5)|_ man page.
+ A file to read local ignore patterns from. This file should be in
+ the same format as a repository-wide .hgignore file. Relative paths
+ are resolved from the repository root, so to specify a file in the
+ same directory as ``.hg/hgrc``, you can set ``ignore =
+ .hg/hgignore2``. This option supports hook syntax, so to specify
+ multiple ignore files, you can set something like ``ignore.other =
+ ~/.hgignore2``. For details of the ignore file format, see the
+ |hgignore(5)|_ man page.
``interactive``
Allow to prompt the user. True or False. Default is True.
``logtemplate``
diff -r c61442f6d106 -r abcaddaadfc8 mercurial/dirstate.py
--- a/mercurial/dirstate.py Mon May 31 13:47:51 2010 +0200
+++ b/mercurial/dirstate.py Tue Jun 01 12:55:53 2010 -0400
@@ -103,7 +103,7 @@
files = [self._join('.hgignore')]
for name, path in self._ui.configitems("ui"):
if name == 'ignore' or name.startswith('ignore.'):
- files.append(util.expandpath(path))
+ files.append(os.path.join(self._rootdir, util.expandpath(path)))
return ignore.ignore(self._root, files, self._ui.warn)
@propertycache
diff -r c61442f6d106 -r abcaddaadfc8 tests/test-hgignore-local
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-hgignore-local Tue Jun 01 12:55:53 2010 -0400
@@ -0,0 +1,63 @@
+#!/bin/sh
+
+# test ignore files specified in .hg/hgrc ("local" to each repository)
+
+hg init
+mkdir dir
+
+touch absolute-glob
+touch absolute-re
+cat > .hg/ignore-absolute <<END
+syntax: glob
+abs*-glob
+
+syntax: re
+abs.*-re
+END
+
+touch relative-glob
+touch relative-re
+cat > .hg/ignore-relative <<END
+syntax: glob
+rel*-glob
+
+syntax: re
+rel.*-re
+END
+
+touch home-glob
+touch home-re
+cat > .hg/ignore-home <<END
+syntax: glob
+hom*-glob
+
+syntax: re
+hom.*-re
+END
+
+
+echo "--" ; hg status
+
+echo "[ui]" > .hg/hgrc
+echo "ignore = `pwd`/.hg/ignore-absolute" >> .hg/hgrc
+
+echo "--" ; hg status
+cd dir
+echo "--" ; hg status
+cd ..
+
+echo "ignore.other = .hg/ignore-relative" >> .hg/hgrc
+
+echo "--" ; hg status
+cd dir
+echo "--" ; hg status
+cd ..
+
+HOME=".hg"
+export HOME
+echo "ignore.home = ~/ignore-home" >> .hg/hgrc
+
+echo "--" ; hg status
+cd dir
+echo "--" ; hg status
+cd ..
diff -r c61442f6d106 -r abcaddaadfc8 tests/test-hgignore-local.out
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-hgignore-local.out Tue Jun 01 12:55:53 2010 -0400
@@ -0,0 +1,25 @@
+--
+? absolute-glob
+? absolute-re
+? home-glob
+? home-re
+? relative-glob
+? relative-re
+--
+? home-glob
+? home-re
+? relative-glob
+? relative-re
+--
+? home-glob
+? home-re
+? relative-glob
+? relative-re
+--
+? home-glob
+? home-re
+--
+? home-glob
+? home-re
+--
+--
More information about the Mercurial-devel
mailing list