[PATCH 1 of 1] Add support for ui.one_filesystem in hgrc

Lars Damerow lars at pixar.com
Tue Mar 30 16:57:23 CDT 2010


# HG changeset patch
# User Lars R. Damerow <lars at pixar.com>
# Date 1269980725 25200
# Node ID bc43b3bdaac0239b0294c9a7b7ec918c8df56f2d
# Parent  ef3668450cd0075978e2d11ec991aab557d9c59c
Add support for ui.one_filesystem in hgrc

This patch makes Mercurial pay attention to the ui.one_filesystem hgrc
variable. When that variable is set to true, Mercurial will stop looking for a
repo directory when it attempts to cross a filesystem boundary.

This behavior is useful on machines which have many automount maps enabled.
When active it stops bogus mount requests (like "/home/.hg") from happening
and polluting syslogs.

Note that it only makes sense to use this variable in ~/.hgrc or
/etc/mercurial/hgrc, not in a given repo's hgrc.

diff -r ef3668450cd0 -r bc43b3bdaac0 mercurial/cmdutil.py
--- a/mercurial/cmdutil.py	Tue Mar 30 13:09:25 2010 -0500
+++ b/mercurial/cmdutil.py	Tue Mar 30 13:25:25 2010 -0700
@@ -7,7 +7,7 @@
 
 from node import hex, nullid, nullrev, short
 from i18n import _
-import os, sys, errno, re, glob, tempfile
+import os, sys, errno, re, glob, tempfile, stat
 import mdiff, bdiff, util, templater, patch, error, encoding, templatekw
 import match as _match
 
@@ -62,11 +62,26 @@
 
     raise error.UnknownCommand(cmd)
 
-def findrepo(p):
-    while not os.path.isdir(os.path.join(p, ".hg")):
+def findrepo(p, one_filesystem):
+    def stat_hg(p):
+        hgdir = os.path.join(p, '.hg')
+        try:
+            return os.stat(hgdir)
+        except:
+            return None
+
+    if one_filesystem:
+        startdev = os.stat(p).st_dev
+    hgstat = stat_hg(p)
+
+    while (hgstat == None) or not stat.S_ISDIR(hgstat.st_mode):
         oldp, p = p, os.path.dirname(p)
         if p == oldp:
             return None
+        if one_filesystem:
+            if startdev != os.stat(p).st_dev:
+                return None
+        hgstat = stat_hg(p)
 
     return p
 
diff -r ef3668450cd0 -r bc43b3bdaac0 mercurial/dispatch.py
--- a/mercurial/dispatch.py	Tue Mar 30 13:09:25 2010 -0500
+++ b/mercurial/dispatch.py	Tue Mar 30 13:25:25 2010 -0700
@@ -351,7 +351,8 @@
         os.chdir(cwd[-1])
 
     # read the local repository .hgrc into a local ui object
-    path = cmdutil.findrepo(os.getcwd()) or ""
+    path = cmdutil.findrepo(os.getcwd(),
+                            ui.configbool("ui", "one_filesystem", False)) or ""
     if not path:
         lui = ui
     else:


More information about the Mercurial-devel mailing list