mercurial/cmdutil.py
changeset 10402 d216fa04e48a
parent 10401 6252852b4332
child 10463 5ddde896a19d
--- a/mercurial/cmdutil.py	Mon Feb 08 10:23:44 2010 +0100
+++ b/mercurial/cmdutil.py	Mon Feb 08 10:50:00 2010 +0100
@@ -62,6 +62,14 @@
 
     raise error.UnknownCommand(cmd)
 
+def findrepo(p):
+    while not os.path.isdir(os.path.join(p, ".hg")):
+        oldp, p = p, os.path.dirname(p)
+        if p == oldp:
+            return None
+
+    return p
+
 def bail_if_changed(repo):
     if repo.dirstate.parents()[1] != nullid:
         raise util.Abort(_('outstanding uncommitted merge'))