Mercurial > hg > mercurial-crew-with-dirclash
comparison contrib/mercurial.el @ 2989:78fe7e2c2e1e
mercurial.el: add hg-cwd
author | Bryan O'Sullivan <bos@serpentine.com> |
---|---|
date | Tue, 22 Aug 2006 14:03:10 -0700 |
parents | 65efeb7b2c56 |
children | 18c661e9abd9 |
comparison
equal
deleted
inserted
replaced
2988:65efeb7b2c56 | 2989:78fe7e2c2e1e |
---|---|
1209 (message "The path `%s' is not in a Mercurial repository." | 1209 (message "The path `%s' is not in a Mercurial repository." |
1210 (hg-abbrev-file-name path)))) | 1210 (hg-abbrev-file-name path)))) |
1211 root) | 1211 root) |
1212 hg-root)) | 1212 hg-root)) |
1213 | 1213 |
1214 (defun hg-cwd (&optional path) | |
1215 "Return the current directory of PATH within the repository." | |
1216 (do ((stack nil (cons (file-name-nondirectory | |
1217 (directory-file-name dir)) | |
1218 stack)) | |
1219 (prev nil dir) | |
1220 (dir (file-name-directory (or path buffer-file-name | |
1221 (expand-file-name default-directory))) | |
1222 (file-name-directory (directory-file-name dir)))) | |
1223 ((equal prev dir)) | |
1224 (when (file-directory-p (concat dir ".hg")) | |
1225 (let ((cwd (mapconcat 'identity stack "/"))) | |
1226 (unless (equal cwd "") | |
1227 (return (file-name-as-directory cwd))))))) | |
1228 | |
1214 (defun hg-status (path) | 1229 (defun hg-status (path) |
1215 "Print revision control status of a file or directory. | 1230 "Print revision control status of a file or directory. |
1216 With prefix argument, prompt for the path to give status for. | 1231 With prefix argument, prompt for the path to give status for. |
1217 Names are displayed relative to the repository root." | 1232 Names are displayed relative to the repository root." |
1218 (interactive (list (hg-read-file-name " for status" (hg-root)))) | 1233 (interactive (list (hg-read-file-name " for status" (hg-root)))) |