--- a/contrib/mercurial.el Tue Aug 22 14:02:43 2006 -0700
+++ b/contrib/mercurial.el Tue Aug 22 14:03:10 2006 -0700
@@ -1211,6 +1211,21 @@
root)
hg-root))
+(defun hg-cwd (&optional path)
+ "Return the current directory of PATH within the repository."
+ (do ((stack nil (cons (file-name-nondirectory
+ (directory-file-name dir))
+ stack))
+ (prev nil dir)
+ (dir (file-name-directory (or path buffer-file-name
+ (expand-file-name default-directory)))
+ (file-name-directory (directory-file-name dir))))
+ ((equal prev dir))
+ (when (file-directory-p (concat dir ".hg"))
+ (let ((cwd (mapconcat 'identity stack "/")))
+ (unless (equal cwd "")
+ (return (file-name-as-directory cwd)))))))
+
(defun hg-status (path)
"Print revision control status of a file or directory.
With prefix argument, prompt for the path to give status for.