emacs/lisp/vc/vc-hg.el

1574 lines
61 KiB
EmacsLisp
Raw Normal View History

;;; vc-hg.el --- VC backend for the mercurial version control system -*- lexical-binding: t -*-
2007-06-20 05:59:41 +00:00
2023-01-01 05:31:12 -05:00
;; Copyright (C) 2006-2023 Free Software Foundation, Inc.
2007-06-20 05:59:41 +00:00
;; Author: Ivan Kanis
;; Maintainer: emacs-devel@gnu.org
;; Keywords: vc tools
;; Package: vc
;; This file is part of GNU Emacs.
;; GNU Emacs is free software: you can redistribute it and/or modify
2007-06-20 05:59:41 +00:00
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
2007-06-20 05:59:41 +00:00
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
2007-06-20 05:59:41 +00:00
;;; Commentary:
;; This is a mercurial version control backend
;;; Todo:
;; 1) Implement the rest of the vc interface. See the comment at the
;; beginning of vc.el. The current status is:
;; FUNCTION NAME STATUS
;; BACKEND PROPERTIES
;; * revision-granularity OK
;; - update-on-retrieve-tag OK
;; STATE-QUERYING FUNCTIONS
;; * registered (file) OK
;; * state (file) OK
;; - dir-status-files (dir files uf) OK
;; - dir-extra-headers (dir) OK
;; - dir-printer (fileinfo) OK
2007-10-10 18:52:45 +00:00
;; * working-revision (file) OK
;; * checkout-model (files) OK
Performance improvements for vc-hg Teach vc-hg how to read some Mercurial internal data structures, allowing us to avoid the need to run hg status -A, which is very slow for large repositories. Fall back to running hg if anything looks funny. vc-hg now puts the _working directory_ revision in the modeline instead of the file revision, which greatly improves performance and which allows us to again skip running hg in the case that we have an active bookmark. * lisp/vc/vc-hg.el (vc-hg-state): Try calling `vc-hg-statefast' (vc-hg-symbolic-revision-styles) (vc-hg-use-file-version-for-mode-line-version) (vc-hg-parse-hg-data-structures): New user preferences (vc-hg--active-bookmark-internal, vc-hg--run-log) (vc-hg--symbolic-revision, vc-hg-mode-line-string) (vc-hg--read-u8, vc-hg--read-u32-be) (vc-hg--raw-dirstate-search, vc-hg--cached-dirstate-search) (vc-hg--parts-to-string, vc-hg--pcre-to-elisp-re) (vc-hg--glob-to-pcre, vc-hg--hgignore-add-pcre) (vc-hg--hgignore-add-glob, vc-hg--hgignore-add-path) (vc-hg--slurp-hgignore-1, vc-hg--slurp-hgignore) (vc-hg--ignore-patterns-valid-p) (vc-hg--ignore-patterns-ignored-p, vc-hg--time-to-fixnum) (vc-hg--file-ignored-p, vc-hg--read-repo-requirements) (vc-hg--requirements-understood-p, vc-hg--dirstate-scan-cache) (vc-hg-state-fast): New functions. (vc-hg--hgignore-patterns, vc-hg--hgignore-filenames) (vc-hg--cached-ignore-patterns, vc-hg--dirstate-scan-cache) (vc-hg--dirstate-scan-cache): New internal variables. * lisp/vc/vc-hooks.el (vc-refresh-state): Invoke vc find-file-hook before updating modeline.
2016-02-08 10:52:54 -08:00
;; - mode-line-string (file) OK
;; STATE-CHANGING FUNCTIONS
;; * register (files &optional rev comment) OK
;; * create-repo () OK
;; - responsible-p (file) OK
;; - receive-file (file rev) ?? PROBABLY NOT NEEDED
;; - unregister (file) OK
;; * checkin (files rev comment) OK
;; - checkin-patch (patch-string comment) OK
;; * find-revision (file rev buffer) OK
;; * checkout (file &optional rev) OK
;; * revert (file &optional contents-done) OK
;; - merge (file rev1 rev2) NEEDED
;; - merge-news (file) NEEDED
;; - steal-lock (file &optional revision) NOT NEEDED
;; HISTORY FUNCTIONS
;; * print-log (files buffer &optional shortlog start-revision limit) OK
;; - log-view-mode () OK
;; - show-log-entry (revision) NOT NEEDED, DEFAULT IS GOOD
;; - comment-history (file) NOT NEEDED
;; - update-changelog (files) NOT NEEDED
;; * diff (files &optional rev1 rev2 buffer) OK
;; - revision-completion-table (files) OK?
;; - annotate-command (file buf &optional rev) OK
;; - annotate-time () OK
;; - annotate-current-time () NOT NEEDED
;; - annotate-extract-revision-at-line () OK
;; TAG SYSTEM
;; - create-tag (dir name branchp) OK
;; - retrieve-tag (dir name update) OK
;; MISCELLANEOUS
;; - make-version-backups-p (file) ??
;; - previous-revision (file rev) OK
;; - next-revision (file rev) OK
;; - check-headers () ??
;; - delete-file (file) TEST IT
;; - rename-file (old new) OK
;; - find-file-hook () added for bug#10709
;; - prepare-patch (rev) OK
2007-06-20 05:59:41 +00:00
;; 2) Implement Stefan Monnier's advice:
;; vc-hg-registered and vc-hg-state
;; Both of those functions should be super extra careful to fail gracefully in
;; unexpected circumstances. The reason this is important is that any error
;; there will prevent the user from even looking at the file :-(
;; Ideally, just like in vc-arch and vc-cvs, checking that the file is under
;; mercurial's control and extracting the current revision should be done
;; without even using `hg' (this way even if you don't have `hg' installed,
;; Emacs is able to tell you this file is under mercurial's control).
2007-06-20 05:59:41 +00:00
;;; Code:
(require 'cl-lib)
2007-06-20 05:59:41 +00:00
(eval-when-compile
(require 'vc)
(require 'vc-dir))
2007-06-20 05:59:41 +00:00
(declare-function vc-compilation-mode "vc-dispatcher" (backend))
(declare-function vc-read-revision "vc"
(prompt &optional files backend default initial-input))
2007-06-20 05:59:41 +00:00
;;; Customization options
(defgroup vc-hg nil
"VC Mercurial (hg) backend."
:version "24.1"
:group 'vc)
2007-06-20 05:59:41 +00:00
(defcustom vc-hg-global-switches nil
* align.el: * allout.el: * apropos.el: * arc-mode.el: * autoinsert.el: * avoid.el: * battery.el: * bookmark.el: * buff-menu.el: * calculator.el: * chistory.el: * cmuscheme.el: * comint.el: * compare-w.el: * dabbrev.el: * delim-col.el: * desktop.el: * diff-mode.el: * diff.el: * dired-aux.el: * dired-x.el: * dired.el: * dos-vars.el: * ediff-diff.el: * ediff-help.el: * ediff-init.el: * ediff-merg.el: * ediff-mult.el: * ediff-ptch.el: * ediff-vers.el: * ediff-wind.el: * ediff.el: * emerge.el: * facemenu.el: * faces.el: * ffap.el: * filecache.el: * find-dired.el: * font-core.el: * font-lock.el: * forms.el: * fringe.el: * help-at-pt.el: * hippie-exp.el: * ido.el: * image-file.el: * imenu.el: * indent.el: * info.el: * isearchb.el: * iswitchb.el: * jit-lock.el: * jka-compr.el: * log-edit.el: * lpr.el: * ls-lisp.el: * man.el: * menu-bar.el: * midnight.el: * mouse-sel.el: * mouse.el: * msb.el: * outline.el: * paren.el: * pcmpl-cvs.el: * pcmpl-gnu.el: * pcomplete.el: * pcvs-info.el: * pcvs-parse.el: * printing.el: * ps-mule.el: * ps-print.el: * replace.el: * ruler-mode.el: * saveplace.el: * sb-image.el: * scroll-bar.el: * sha1.el: * shadowfile.el: * shell.el: * sort.el: * speedbar.el: * strokes.el: * tempo.el: * term.el: * terminal.el: * time-stamp.el: * time.el: * tree-widget.el: * type-break.el: * vc-cvs.el: * vc-hg.el: * vc-mcvs.el: * vc-rcs.el: * vc-sccs.el: * vc.el: * view.el: * w32-vars.el: * whitespace.el: * wid-edit.el: Remove leading * from docstrings of defcustoms, deffaces, defconsts and defuns.
2008-12-03 05:48:14 +00:00
"Global switches to pass to any Hg command."
2007-06-20 05:59:41 +00:00
:type '(choice (const :tag "None" nil)
(string :tag "Argument String")
2008-12-03 07:37:39 +00:00
(repeat :tag "Argument List" :value ("") string))
:version "22.2")
2007-06-20 05:59:41 +00:00
2008-12-03 07:37:39 +00:00
(defcustom vc-hg-diff-switches t ; Hg doesn't support common args like -u
"String or list of strings specifying switches for Hg diff under VC.
If nil, use the value of `vc-diff-switches'. If t, use no switches."
:type '(choice (const :tag "Unspecified" nil)
(const :tag "None" t)
(string :tag "Argument String")
(repeat :tag "Argument List" :value ("") string))
:version "23.1")
(defcustom vc-hg-annotate-switches '("-u" "--follow")
"String or list of strings specifying switches for hg annotate under VC.
If nil, use the value of `vc-annotate-switches'. If t, use no
switches."
:type '(choice (const :tag "Unspecified" nil)
(const :tag "None" t)
(string :tag "Argument String")
(repeat :tag "Argument List" :value ("") string))
:version "25.1")
(defcustom vc-hg-revert-switches nil
"String or list of strings specifying switches for hg revert under VC."
:type '(choice (const :tag "None" nil)
(string :tag "Argument String")
(repeat :tag "Argument List" :value ("") string))
:version "27.1")
(defcustom vc-hg-program "hg"
"Name of the Mercurial executable (excluding any arguments)."
:type 'string)
(defcustom vc-hg-root-log-format
`(,(concat "{rev}:{ifeq(branch, 'default','', '{branch}')}"
":{bookmarks}:{tags}:{author|person}"
" {date|shortdate} {desc|firstline}\\n")
,(concat "^\\(?:[+@o x|-]*\\)" ;Graph data.
"\\([0-9]+\\):\\([^:]*\\)"
":\\([^:]*\\):\\([^:]*\\):\\(.*?\\)"
"[ \t]+\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}\\)")
((1 'log-view-message)
(2 'change-log-file)
(3 'change-log-list)
(4 'change-log-conditionals)
(5 'change-log-name)
(6 'change-log-date)))
"Mercurial log template for `vc-hg-print-log' short format.
This should be a list (TEMPLATE REGEXP KEYWORDS), where TEMPLATE
is the \"--template\" argument string to pass to Mercurial,
REGEXP is a regular expression matching the resulting Mercurial
output, and KEYWORDS is a list of `font-lock-keywords' for
highlighting the Log View buffer."
Use regexp type for regexps in defcustom declarations * lisp/calendar/diary-lib.el (diary-face-attrs): * lisp/cedet/semantic/db-ebrowse.el (semanticdb-ebrowse-file-match): * lisp/cedet/srecode/document.el (srecode-document-autocomment-common-nouns-abbrevs) (srecode-document-autocomment-function-alist) (srecode-document-autocomment-return-first-alist) (srecode-document-autocomment-return-last-alist) (srecode-document-autocomment-param-alist) (srecode-document-autocomment-param-type-alist): * lisp/desktop.el (desktop-clear-preserve-buffers): * lisp/elide-head.el (elide-head-headers-to-hide): * lisp/erc/erc-backend.el (erc-encoding-coding-alist): * lisp/erc/erc-ezbounce.el (erc-ezb-regexp): * lisp/files.el (auto-save-file-name-transforms): * lisp/gnus/deuglify.el (gnus-outlook-deuglify-attrib-cut-regexp) (gnus-outlook-deuglify-attrib-verb-regexp) (gnus-outlook-deuglify-attrib-end-regexp): * lisp/gnus/gnus-fun.el (gnus-x-face-omit-files, gnus-face-omit-files): * lisp/gnus/spam.el (spam-spamassassin-positive-spam-flag-header): * lisp/htmlfontify.el (hfy-src-doc-link-unstyle): * lisp/info-look.el (info-lookup-file-name-alist): * lisp/international/rfc1843.el (rfc1843-newsgroups-regexp): * lisp/mail/feedmail.el (feedmail-queue-slug-suspect-regexp): * lisp/mail/rmail-spam-filter.el (rsf-white-list, rsf-definitions-alist): * lisp/man.el (Man-name-local-regexp): * lisp/net/ange-ftp.el (ange-ftp-dumb-unix-host-regexp): * lisp/net/newst-backend.el (newsticker-auto-mark-filter-list): * lisp/net/rcirc.el (rcirc-authinfo, rcirc-coding-system-alist): * lisp/net/tramp-adb.el (tramp-adb-prompt): * lisp/org/org-agenda.el (org-agenda-hide-tags-regexp) (org-agenda-category-icon-alist): * lisp/org/org-protocol.el (org-protocol-data-separator): * lisp/org/org-table.el (org-table-number-regexp): * lisp/org/ox-latex.el (org-latex-known-warnings): * lisp/progmodes/bug-reference.el (bug-reference-bug-regexp): * lisp/progmodes/hideif.el (hide-ifdef-header-regexp): * lisp/progmodes/idlw-help.el (idlwave-help-doclib-name) (idlwave-help-doclib-keyword): * lisp/progmodes/idlwave.el (idlwave-no-change-comment): * lisp/progmodes/python.el (python-shell-prompt-input-regexps) (python-shell-prompt-output-regexps, python-shell-prompt-regexp) (python-shell-prompt-block-regexp, python-shell-prompt-output-regexp) (python-shell-prompt-pdb-regexp, python-shell-compilation-regexp-alist) (python-pdbtrack-stacktrace-info-regexp): * lisp/progmodes/sql.el (sql-send-terminator, sql-ansi-statement-starters): * lisp/speedbar.el (speedbar-directory-unshown-regexp) (speedbar-file-unshown-regexp): * lisp/textmodes/flyspell.el (flyspell-mark-duplications-exceptions) (flyspell-tex-command-regexp): * lisp/textmodes/paragraphs.el (sentence-end-base): * lisp/textmodes/tildify.el (tildify-pattern, tildify-space-pattern): * lisp/vc/ediff-init.el (ediff-metachars): * lisp/vc/vc-git.el (vc-git-root-log-format): * lisp/vc/vc-hg.el (vc-hg-root-log-format): * lisp/whitespace.el (whitespace-indentation-regexp) (whitespace-space-after-tab-regexp): * lisp/woman.el (woman-manpath-man-regexp) (woman-imenu-generic-expression): Use 'regexp' instead of 'string' as type for values that are regexps in defcustom declarations.
2019-12-21 18:52:06 +01:00
:type '(list string regexp (repeat sexp))
:version "24.5")
(defcustom vc-hg-create-bookmark t
"This controls whether `vc-create-tag' will create a bookmark or branch.
If nil, named branch will be created.
If t, bookmark will be created.
If `ask', you will be prompted for a branch type."
:type '(choice (const :tag "No" nil)
(const :tag "Yes" t)
(const :tag "Ask" ask))
:version "28.1")
;; Clear up the cache to force vc-call to check again and discover
;; new functions when we reload this file.
(put 'Hg 'vc-functions nil)
;;; Properties of the backend
(defvar vc-hg-history nil)
(defun vc-hg-revision-granularity () 'repository)
(defun vc-hg-checkout-model (_files) 'implicit)
(defun vc-hg-update-on-retrieve-tag () nil)
2007-06-20 05:59:41 +00:00
;;; State querying functions
;;;###autoload (defun vc-hg-registered (file)
;;;###autoload "Return non-nil if FILE is registered with hg."
;;;###autoload (if (vc-find-root file ".hg") ; short cut
;;;###autoload (progn
;;;###autoload (load "vc-hg" nil t)
;;;###autoload (vc-hg-registered file))))
2008-06-27 02:41:14 +00:00
;; Modeled after the similar function in vc-bzr.el
2007-06-20 05:59:41 +00:00
(defun vc-hg-registered (file)
"Return non-nil if FILE is registered with hg."
(when (vc-hg-root file) ; short cut
(let ((state (vc-state file 'Hg))) ; expensive
(if (memq state '(ignored unregistered nil))
;; Clear the cache for proper fallback to another backend.
(ignore (vc-file-setprop file 'vc-state nil))
t))))
2007-06-20 05:59:41 +00:00
(defun vc-hg-state (file)
"Hg-specific version of `vc-state'."
Performance improvements for vc-hg Teach vc-hg how to read some Mercurial internal data structures, allowing us to avoid the need to run hg status -A, which is very slow for large repositories. Fall back to running hg if anything looks funny. vc-hg now puts the _working directory_ revision in the modeline instead of the file revision, which greatly improves performance and which allows us to again skip running hg in the case that we have an active bookmark. * lisp/vc/vc-hg.el (vc-hg-state): Try calling `vc-hg-statefast' (vc-hg-symbolic-revision-styles) (vc-hg-use-file-version-for-mode-line-version) (vc-hg-parse-hg-data-structures): New user preferences (vc-hg--active-bookmark-internal, vc-hg--run-log) (vc-hg--symbolic-revision, vc-hg-mode-line-string) (vc-hg--read-u8, vc-hg--read-u32-be) (vc-hg--raw-dirstate-search, vc-hg--cached-dirstate-search) (vc-hg--parts-to-string, vc-hg--pcre-to-elisp-re) (vc-hg--glob-to-pcre, vc-hg--hgignore-add-pcre) (vc-hg--hgignore-add-glob, vc-hg--hgignore-add-path) (vc-hg--slurp-hgignore-1, vc-hg--slurp-hgignore) (vc-hg--ignore-patterns-valid-p) (vc-hg--ignore-patterns-ignored-p, vc-hg--time-to-fixnum) (vc-hg--file-ignored-p, vc-hg--read-repo-requirements) (vc-hg--requirements-understood-p, vc-hg--dirstate-scan-cache) (vc-hg-state-fast): New functions. (vc-hg--hgignore-patterns, vc-hg--hgignore-filenames) (vc-hg--cached-ignore-patterns, vc-hg--dirstate-scan-cache) (vc-hg--dirstate-scan-cache): New internal variables. * lisp/vc/vc-hooks.el (vc-refresh-state): Invoke vc find-file-hook before updating modeline.
2016-02-08 10:52:54 -08:00
(let ((state (vc-hg-state-fast file)))
(if (eq state 'unsupported) (vc-hg-state-slow file) state)))
(defun vc-hg-state-slow (file)
"Determine status of FILE by running hg."
(setq file (expand-file-name file))
2008-02-20 15:21:55 +00:00
(let*
((status nil)
(default-directory (file-name-directory file))
(out
(with-output-to-string
(with-current-buffer
standard-output
(setq status
(condition-case nil
;; Ignore all errors.
(let ((process-environment
;; Avoid localization of messages so we
;; can parse the output. Disable pager.
(append
(list "TERM=dumb" "LANGUAGE=C" "HGPLAIN=1")
process-environment)))
(process-file
vc-hg-program nil t nil
"--config" "ui.report_untrusted=0"
"--config" "alias.status=status"
"--config" "defaults.status="
"status" "-A" (file-relative-name file)))
;; Some problem happened. E.g. We can't find an `hg'
;; executable.
(error nil)))))))
(when (and (eq 0 status)
(> (length out) 0)
(null (string-match ".*: No such file or directory$" out)))
(let ((state (aref out 0)))
(cond
((eq state ?=) 'up-to-date)
((eq state ?A) 'added)
((eq state ?M) 'edited)
((eq state ?I) 'ignored)
((eq state ?R) 'removed)
((eq state ?!) 'missing)
((eq state ??) 'unregistered)
((eq state ?C) 'up-to-date) ;; Older mercurial versions use this.
(t 'up-to-date))))))
(defun vc-hg-working-revision (_file)
2007-10-10 18:52:45 +00:00
"Hg-specific version of `vc-working-revision'."
(ignore-errors
(with-output-to-string
(vc-hg-command standard-output 0 nil
"log" "-r" "." "--template" "{rev}"))))
2007-06-20 05:59:41 +00:00
Performance improvements for vc-hg Teach vc-hg how to read some Mercurial internal data structures, allowing us to avoid the need to run hg status -A, which is very slow for large repositories. Fall back to running hg if anything looks funny. vc-hg now puts the _working directory_ revision in the modeline instead of the file revision, which greatly improves performance and which allows us to again skip running hg in the case that we have an active bookmark. * lisp/vc/vc-hg.el (vc-hg-state): Try calling `vc-hg-statefast' (vc-hg-symbolic-revision-styles) (vc-hg-use-file-version-for-mode-line-version) (vc-hg-parse-hg-data-structures): New user preferences (vc-hg--active-bookmark-internal, vc-hg--run-log) (vc-hg--symbolic-revision, vc-hg-mode-line-string) (vc-hg--read-u8, vc-hg--read-u32-be) (vc-hg--raw-dirstate-search, vc-hg--cached-dirstate-search) (vc-hg--parts-to-string, vc-hg--pcre-to-elisp-re) (vc-hg--glob-to-pcre, vc-hg--hgignore-add-pcre) (vc-hg--hgignore-add-glob, vc-hg--hgignore-add-path) (vc-hg--slurp-hgignore-1, vc-hg--slurp-hgignore) (vc-hg--ignore-patterns-valid-p) (vc-hg--ignore-patterns-ignored-p, vc-hg--time-to-fixnum) (vc-hg--file-ignored-p, vc-hg--read-repo-requirements) (vc-hg--requirements-understood-p, vc-hg--dirstate-scan-cache) (vc-hg-state-fast): New functions. (vc-hg--hgignore-patterns, vc-hg--hgignore-filenames) (vc-hg--cached-ignore-patterns, vc-hg--dirstate-scan-cache) (vc-hg--dirstate-scan-cache): New internal variables. * lisp/vc/vc-hooks.el (vc-refresh-state): Invoke vc find-file-hook before updating modeline.
2016-02-08 10:52:54 -08:00
(defcustom vc-hg-symbolic-revision-styles
'(builtin-active-bookmark
"{if(bookmarks,sub(' ',',',bookmarks),if(phabdiff,phabdiff,shortest(node,6)))}")
"List of ways to present versions symbolically.
The version that we use is the first one that successfully
produces a non-empty string.
Performance improvements for vc-hg Teach vc-hg how to read some Mercurial internal data structures, allowing us to avoid the need to run hg status -A, which is very slow for large repositories. Fall back to running hg if anything looks funny. vc-hg now puts the _working directory_ revision in the modeline instead of the file revision, which greatly improves performance and which allows us to again skip running hg in the case that we have an active bookmark. * lisp/vc/vc-hg.el (vc-hg-state): Try calling `vc-hg-statefast' (vc-hg-symbolic-revision-styles) (vc-hg-use-file-version-for-mode-line-version) (vc-hg-parse-hg-data-structures): New user preferences (vc-hg--active-bookmark-internal, vc-hg--run-log) (vc-hg--symbolic-revision, vc-hg-mode-line-string) (vc-hg--read-u8, vc-hg--read-u32-be) (vc-hg--raw-dirstate-search, vc-hg--cached-dirstate-search) (vc-hg--parts-to-string, vc-hg--pcre-to-elisp-re) (vc-hg--glob-to-pcre, vc-hg--hgignore-add-pcre) (vc-hg--hgignore-add-glob, vc-hg--hgignore-add-path) (vc-hg--slurp-hgignore-1, vc-hg--slurp-hgignore) (vc-hg--ignore-patterns-valid-p) (vc-hg--ignore-patterns-ignored-p, vc-hg--time-to-fixnum) (vc-hg--file-ignored-p, vc-hg--read-repo-requirements) (vc-hg--requirements-understood-p, vc-hg--dirstate-scan-cache) (vc-hg-state-fast): New functions. (vc-hg--hgignore-patterns, vc-hg--hgignore-filenames) (vc-hg--cached-ignore-patterns, vc-hg--dirstate-scan-cache) (vc-hg--dirstate-scan-cache): New internal variables. * lisp/vc/vc-hooks.el (vc-refresh-state): Invoke vc find-file-hook before updating modeline.
2016-02-08 10:52:54 -08:00
Each entry in the list can be either:
- The symbol `builtin-active-bookmark', which indicates that we
should use the active bookmark if one exists. A template can
supply this information as well, but `builtin-active-bookmark' is
handled entirely inside Emacs and so is more efficient than using
the generic Mercurial mechanism.
- A string giving the Mercurial template to supply to \"hg
parent\". \"hg help template\" may be useful reading.
- A function to call; it should accept two arguments (a revision
and an optional path to which to limit history) and produce a
string. The function is called with `default-directory' set to
within the repository.
2021-09-13 06:04:32 +02:00
If no list entry produces a useful revision, return nil."
Performance improvements for vc-hg Teach vc-hg how to read some Mercurial internal data structures, allowing us to avoid the need to run hg status -A, which is very slow for large repositories. Fall back to running hg if anything looks funny. vc-hg now puts the _working directory_ revision in the modeline instead of the file revision, which greatly improves performance and which allows us to again skip running hg in the case that we have an active bookmark. * lisp/vc/vc-hg.el (vc-hg-state): Try calling `vc-hg-statefast' (vc-hg-symbolic-revision-styles) (vc-hg-use-file-version-for-mode-line-version) (vc-hg-parse-hg-data-structures): New user preferences (vc-hg--active-bookmark-internal, vc-hg--run-log) (vc-hg--symbolic-revision, vc-hg-mode-line-string) (vc-hg--read-u8, vc-hg--read-u32-be) (vc-hg--raw-dirstate-search, vc-hg--cached-dirstate-search) (vc-hg--parts-to-string, vc-hg--pcre-to-elisp-re) (vc-hg--glob-to-pcre, vc-hg--hgignore-add-pcre) (vc-hg--hgignore-add-glob, vc-hg--hgignore-add-path) (vc-hg--slurp-hgignore-1, vc-hg--slurp-hgignore) (vc-hg--ignore-patterns-valid-p) (vc-hg--ignore-patterns-ignored-p, vc-hg--time-to-fixnum) (vc-hg--file-ignored-p, vc-hg--read-repo-requirements) (vc-hg--requirements-understood-p, vc-hg--dirstate-scan-cache) (vc-hg-state-fast): New functions. (vc-hg--hgignore-patterns, vc-hg--hgignore-filenames) (vc-hg--cached-ignore-patterns, vc-hg--dirstate-scan-cache) (vc-hg--dirstate-scan-cache): New internal variables. * lisp/vc/vc-hooks.el (vc-refresh-state): Invoke vc find-file-hook before updating modeline.
2016-02-08 10:52:54 -08:00
:type '(repeat (choice
(const :tag "Active bookmark" builtin-active-bookmark)
Performance improvements for vc-hg Teach vc-hg how to read some Mercurial internal data structures, allowing us to avoid the need to run hg status -A, which is very slow for large repositories. Fall back to running hg if anything looks funny. vc-hg now puts the _working directory_ revision in the modeline instead of the file revision, which greatly improves performance and which allows us to again skip running hg in the case that we have an active bookmark. * lisp/vc/vc-hg.el (vc-hg-state): Try calling `vc-hg-statefast' (vc-hg-symbolic-revision-styles) (vc-hg-use-file-version-for-mode-line-version) (vc-hg-parse-hg-data-structures): New user preferences (vc-hg--active-bookmark-internal, vc-hg--run-log) (vc-hg--symbolic-revision, vc-hg-mode-line-string) (vc-hg--read-u8, vc-hg--read-u32-be) (vc-hg--raw-dirstate-search, vc-hg--cached-dirstate-search) (vc-hg--parts-to-string, vc-hg--pcre-to-elisp-re) (vc-hg--glob-to-pcre, vc-hg--hgignore-add-pcre) (vc-hg--hgignore-add-glob, vc-hg--hgignore-add-path) (vc-hg--slurp-hgignore-1, vc-hg--slurp-hgignore) (vc-hg--ignore-patterns-valid-p) (vc-hg--ignore-patterns-ignored-p, vc-hg--time-to-fixnum) (vc-hg--file-ignored-p, vc-hg--read-repo-requirements) (vc-hg--requirements-understood-p, vc-hg--dirstate-scan-cache) (vc-hg-state-fast): New functions. (vc-hg--hgignore-patterns, vc-hg--hgignore-filenames) (vc-hg--cached-ignore-patterns, vc-hg--dirstate-scan-cache) (vc-hg--dirstate-scan-cache): New internal variables. * lisp/vc/vc-hooks.el (vc-refresh-state): Invoke vc find-file-hook before updating modeline.
2016-02-08 10:52:54 -08:00
(string :tag "Hg template")
(function :tag "Custom")))
:version "26.1")
Performance improvements for vc-hg Teach vc-hg how to read some Mercurial internal data structures, allowing us to avoid the need to run hg status -A, which is very slow for large repositories. Fall back to running hg if anything looks funny. vc-hg now puts the _working directory_ revision in the modeline instead of the file revision, which greatly improves performance and which allows us to again skip running hg in the case that we have an active bookmark. * lisp/vc/vc-hg.el (vc-hg-state): Try calling `vc-hg-statefast' (vc-hg-symbolic-revision-styles) (vc-hg-use-file-version-for-mode-line-version) (vc-hg-parse-hg-data-structures): New user preferences (vc-hg--active-bookmark-internal, vc-hg--run-log) (vc-hg--symbolic-revision, vc-hg-mode-line-string) (vc-hg--read-u8, vc-hg--read-u32-be) (vc-hg--raw-dirstate-search, vc-hg--cached-dirstate-search) (vc-hg--parts-to-string, vc-hg--pcre-to-elisp-re) (vc-hg--glob-to-pcre, vc-hg--hgignore-add-pcre) (vc-hg--hgignore-add-glob, vc-hg--hgignore-add-path) (vc-hg--slurp-hgignore-1, vc-hg--slurp-hgignore) (vc-hg--ignore-patterns-valid-p) (vc-hg--ignore-patterns-ignored-p, vc-hg--time-to-fixnum) (vc-hg--file-ignored-p, vc-hg--read-repo-requirements) (vc-hg--requirements-understood-p, vc-hg--dirstate-scan-cache) (vc-hg-state-fast): New functions. (vc-hg--hgignore-patterns, vc-hg--hgignore-filenames) (vc-hg--cached-ignore-patterns, vc-hg--dirstate-scan-cache) (vc-hg--dirstate-scan-cache): New internal variables. * lisp/vc/vc-hooks.el (vc-refresh-state): Invoke vc find-file-hook before updating modeline.
2016-02-08 10:52:54 -08:00
(defcustom vc-hg-use-file-version-for-mode-line-version nil
2016-04-03 23:16:35 -07:00
"When enabled, the modeline contains revision information for the visited file.
Performance improvements for vc-hg Teach vc-hg how to read some Mercurial internal data structures, allowing us to avoid the need to run hg status -A, which is very slow for large repositories. Fall back to running hg if anything looks funny. vc-hg now puts the _working directory_ revision in the modeline instead of the file revision, which greatly improves performance and which allows us to again skip running hg in the case that we have an active bookmark. * lisp/vc/vc-hg.el (vc-hg-state): Try calling `vc-hg-statefast' (vc-hg-symbolic-revision-styles) (vc-hg-use-file-version-for-mode-line-version) (vc-hg-parse-hg-data-structures): New user preferences (vc-hg--active-bookmark-internal, vc-hg--run-log) (vc-hg--symbolic-revision, vc-hg-mode-line-string) (vc-hg--read-u8, vc-hg--read-u32-be) (vc-hg--raw-dirstate-search, vc-hg--cached-dirstate-search) (vc-hg--parts-to-string, vc-hg--pcre-to-elisp-re) (vc-hg--glob-to-pcre, vc-hg--hgignore-add-pcre) (vc-hg--hgignore-add-glob, vc-hg--hgignore-add-path) (vc-hg--slurp-hgignore-1, vc-hg--slurp-hgignore) (vc-hg--ignore-patterns-valid-p) (vc-hg--ignore-patterns-ignored-p, vc-hg--time-to-fixnum) (vc-hg--file-ignored-p, vc-hg--read-repo-requirements) (vc-hg--requirements-understood-p, vc-hg--dirstate-scan-cache) (vc-hg-state-fast): New functions. (vc-hg--hgignore-patterns, vc-hg--hgignore-filenames) (vc-hg--cached-ignore-patterns, vc-hg--dirstate-scan-cache) (vc-hg--dirstate-scan-cache): New internal variables. * lisp/vc/vc-hooks.el (vc-refresh-state): Invoke vc find-file-hook before updating modeline.
2016-02-08 10:52:54 -08:00
When not, the revision in the modeline is for the repository
2021-09-13 06:04:32 +02:00
working copy. nil is the much faster setting for
Performance improvements for vc-hg Teach vc-hg how to read some Mercurial internal data structures, allowing us to avoid the need to run hg status -A, which is very slow for large repositories. Fall back to running hg if anything looks funny. vc-hg now puts the _working directory_ revision in the modeline instead of the file revision, which greatly improves performance and which allows us to again skip running hg in the case that we have an active bookmark. * lisp/vc/vc-hg.el (vc-hg-state): Try calling `vc-hg-statefast' (vc-hg-symbolic-revision-styles) (vc-hg-use-file-version-for-mode-line-version) (vc-hg-parse-hg-data-structures): New user preferences (vc-hg--active-bookmark-internal, vc-hg--run-log) (vc-hg--symbolic-revision, vc-hg-mode-line-string) (vc-hg--read-u8, vc-hg--read-u32-be) (vc-hg--raw-dirstate-search, vc-hg--cached-dirstate-search) (vc-hg--parts-to-string, vc-hg--pcre-to-elisp-re) (vc-hg--glob-to-pcre, vc-hg--hgignore-add-pcre) (vc-hg--hgignore-add-glob, vc-hg--hgignore-add-path) (vc-hg--slurp-hgignore-1, vc-hg--slurp-hgignore) (vc-hg--ignore-patterns-valid-p) (vc-hg--ignore-patterns-ignored-p, vc-hg--time-to-fixnum) (vc-hg--file-ignored-p, vc-hg--read-repo-requirements) (vc-hg--requirements-understood-p, vc-hg--dirstate-scan-cache) (vc-hg-state-fast): New functions. (vc-hg--hgignore-patterns, vc-hg--hgignore-filenames) (vc-hg--cached-ignore-patterns, vc-hg--dirstate-scan-cache) (vc-hg--dirstate-scan-cache): New internal variables. * lisp/vc/vc-hooks.el (vc-refresh-state): Invoke vc find-file-hook before updating modeline.
2016-02-08 10:52:54 -08:00
large repositories."
:type 'boolean
:version "26.1")
Performance improvements for vc-hg Teach vc-hg how to read some Mercurial internal data structures, allowing us to avoid the need to run hg status -A, which is very slow for large repositories. Fall back to running hg if anything looks funny. vc-hg now puts the _working directory_ revision in the modeline instead of the file revision, which greatly improves performance and which allows us to again skip running hg in the case that we have an active bookmark. * lisp/vc/vc-hg.el (vc-hg-state): Try calling `vc-hg-statefast' (vc-hg-symbolic-revision-styles) (vc-hg-use-file-version-for-mode-line-version) (vc-hg-parse-hg-data-structures): New user preferences (vc-hg--active-bookmark-internal, vc-hg--run-log) (vc-hg--symbolic-revision, vc-hg-mode-line-string) (vc-hg--read-u8, vc-hg--read-u32-be) (vc-hg--raw-dirstate-search, vc-hg--cached-dirstate-search) (vc-hg--parts-to-string, vc-hg--pcre-to-elisp-re) (vc-hg--glob-to-pcre, vc-hg--hgignore-add-pcre) (vc-hg--hgignore-add-glob, vc-hg--hgignore-add-path) (vc-hg--slurp-hgignore-1, vc-hg--slurp-hgignore) (vc-hg--ignore-patterns-valid-p) (vc-hg--ignore-patterns-ignored-p, vc-hg--time-to-fixnum) (vc-hg--file-ignored-p, vc-hg--read-repo-requirements) (vc-hg--requirements-understood-p, vc-hg--dirstate-scan-cache) (vc-hg-state-fast): New functions. (vc-hg--hgignore-patterns, vc-hg--hgignore-filenames) (vc-hg--cached-ignore-patterns, vc-hg--dirstate-scan-cache) (vc-hg--dirstate-scan-cache): New internal variables. * lisp/vc/vc-hooks.el (vc-refresh-state): Invoke vc find-file-hook before updating modeline.
2016-02-08 10:52:54 -08:00
(defun vc-hg--active-bookmark-internal (rev)
(when (equal rev ".")
(let* ((current-bookmarks-file ".hg/bookmarks.current"))
(when (file-exists-p current-bookmarks-file)
(ignore-errors
(with-temp-buffer
(insert-file-contents current-bookmarks-file)
(buffer-substring-no-properties
(point-min) (point-max))))))))
(defun vc-hg--run-log (template rev path)
(ignore-errors
(with-output-to-string
(if path
(vc-hg-command
standard-output 0 nil
"log" "-f" "-l1" "--template" template path)
(vc-hg-command
standard-output 0 nil
"log" "-r" rev "-l1" "--template" template)))))
(defun vc-hg--symbolic-revision (rev &optional path)
"Make a Mercurial revision human-readable.
REV is a Mercurial revision. `default-directory' is assumed to
be in the repository root of interest. PATH, if set, is a
specific file to query."
(let ((symbolic-revision nil)
(styles vc-hg-symbolic-revision-styles))
(while (and (not symbolic-revision) styles)
(let ((style (pop styles)))
(setf symbolic-revision
(cond ((and (null path) (eq style 'builtin-active-bookmark))
(vc-hg--active-bookmark-internal rev))
((stringp style)
(vc-hg--run-log style rev path))
((functionp style)
(funcall style rev path))))))
symbolic-revision))
(defun vc-hg-mode-line-string (file)
"Hg-specific version of `vc-mode-line-string'."
(let* ((backend-name "Hg")
(truename (file-truename file))
(state (vc-state truename))
(state-echo nil)
(face nil)
(rev (and state
(let ((default-directory
(expand-file-name (vc-hg-root truename))))
(vc-hg--symbolic-revision
"."
(and vc-hg-use-file-version-for-mode-line-version
truename)))))
(rev (or rev "???")))
(propertize
(cond ((or (eq state 'up-to-date)
(eq state 'needs-update))
(setq state-echo "Up to date file")
(setq face 'vc-up-to-date-state)
(concat backend-name "-" rev))
((eq state 'added)
(setq state-echo "Locally added file")
(setq face 'vc-locally-added-state)
(concat backend-name "@" rev))
((eq state 'conflict)
(setq state-echo "File contains conflicts after the last merge")
(setq face 'vc-conflict-state)
(concat backend-name "!" rev))
((eq state 'removed)
(setq state-echo "File removed from the VC system")
(setq face 'vc-removed-state)
(concat backend-name "!" rev))
((eq state 'missing)
(setq state-echo "File tracked by the VC system, but missing from the file system")
(setq face 'vc-missing-state)
(concat backend-name "?" rev))
(t
(setq state-echo "Locally modified file")
(setq face 'vc-edited-state)
(concat backend-name ":" rev)))
'face face
'help-echo (concat state-echo " under the " backend-name
" version control system"))))
2007-06-20 05:59:41 +00:00
;;; History functions
(defcustom vc-hg-log-switches nil
"String or list of strings specifying switches for hg log under VC."
:type '(choice (const :tag "None" nil)
(string :tag "Argument String")
(repeat :tag "Argument List" :value ("") string)))
(autoload 'vc-setup-buffer "vc-dispatcher")
(defvar vc-hg-log-graph nil
"If non-nil, use `--graph' in the short log output.")
(defvar vc-hg-log-format (concat "changeset: {rev}:{node|short}\n"
"{tags % 'tag: {tag}\n'}"
"{if(parents, 'parents: {parents}\n')}"
"user: {author}\n"
"Date: {date|date}\n"
"summary: {desc|tabindent}\n\n")
"Mercurial log template for `vc-hg-print-log' long format.")
2009-12-14 16:55:34 +00:00
(defun vc-hg-print-log (files buffer &optional shortlog start-revision limit)
"Print commit log associated with FILES into specified BUFFER.
If SHORTLOG is non-nil, use a short format based on `vc-hg-root-log-format'.
If START-REVISION is non-nil, it is the newest revision to show.
If LIMIT is non-nil, show no more than this many entries."
;; `vc-do-command' creates the buffer, but we need it before running
;; the command.
(vc-setup-buffer buffer)
;; If the buffer exists from a previous invocation it might be
;; read-only.
(let ((inhibit-read-only t))
(with-current-buffer
buffer
(apply #'vc-hg-command buffer 'async files "log"
(nconc
(when start-revision (list (format "-r%s:0" start-revision)))
(when limit (list "-l" (format "%s" limit)))
(when (eq vc-log-view-type 'with-diff)
(list "-p"))
(if shortlog
`(,@(if vc-hg-log-graph '("--graph"))
"--template"
,(car vc-hg-root-log-format))
`("--template" ,vc-hg-log-format))
vc-hg-log-switches)))))
2007-06-20 05:59:41 +00:00
2007-06-22 02:11:59 +00:00
(defvar log-view-message-re)
(defvar log-view-file-re)
(defvar log-view-font-lock-keywords)
(defvar log-view-per-file-logs)
(defvar log-view-expanded-log-entry-function)
2007-06-22 02:11:59 +00:00
(define-derived-mode vc-hg-log-view-mode log-view-mode "Hg-Log-View"
(require 'add-log) ;; we need the add-log faces
(setq-local log-view-file-re regexp-unmatchable)
(setq-local log-view-per-file-logs nil)
(setq-local log-view-message-re
(if (eq vc-log-view-type 'short)
(cadr vc-hg-root-log-format)
"^changeset:[ \t]*\\([0-9]+\\):\\(.+\\)"))
(setq-local tab-width 2)
;; Allow expanding short log entries
(when (eq vc-log-view-type 'short)
(setq truncate-lines t)
(setq-local log-view-expanded-log-entry-function
'vc-hg-expanded-log-entry))
(setq-local log-view-font-lock-keywords
(if (eq vc-log-view-type 'short)
(list (cons (nth 1 vc-hg-root-log-format)
(nth 2 vc-hg-root-log-format)))
(append
log-view-font-lock-keywords
'(
;; Handle the case:
;; user: FirstName LastName <foo@bar>
("^user:[ \t]+\\([^<(]+?\\)[ \t]*[(<]\\([A-Za-z0-9_.+-]+@[A-Za-z0-9_.-]+\\)[>)]"
(1 'change-log-name)
(2 'change-log-email))
;; Handle the cases:
;; user: foo@bar
;; and
;; user: foo
("^user:[ \t]+\\([A-Za-z0-9_.+-]+\\(?:@[A-Za-z0-9_.-]+\\)?\\)"
(1 'change-log-email))
("^date: \\(.+\\)" (1 'change-log-date))
("^tag: +\\([^ ]+\\)$" (1 'highlight))
("^summary:[ \t]+\\(.+\\)" (1 'log-view-message)))))))
2007-06-22 02:11:59 +00:00
(autoload 'vc-switches "vc")
(defun vc-hg-region-history (file buffer lfrom lto)
"Insert into BUFFER the history of FILE for lines LFROM to LTO.
This requires hg 4.4 or later, for the \"-L\" option of \"hg log\"."
(vc-hg-command buffer 'async nil "log" "-f" "-p" "-L"
(format "%s,%d:%d" (file-relative-name file) lfrom lto)))
(require 'diff-mode)
(defvar vc-hg-region-history-mode-map
(let ((map (make-composed-keymap
nil (make-composed-keymap
(list diff-mode-map vc-hg-log-view-mode-map)))))
map))
(defvar vc-hg--log-view-long-font-lock-keywords nil)
(defvar font-lock-keywords)
(defvar vc-hg-region-history-font-lock-keywords
'((vc-hg-region-history-font-lock)))
(defun vc-hg-region-history-font-lock (limit)
(let ((in-diff (save-excursion
(beginning-of-line)
(or (looking-at "^\\(?:diff\\|changeset\\)\\>")
(re-search-backward "^\\(?:diff\\|changeset\\)\\>"
nil t))
(eq ?d (char-after (match-beginning 0))))))
(while
(let ((end (save-excursion
(if (re-search-forward "\n\\(diff\\|changeset\\)\\>"
limit t)
(match-beginning 1)
limit))))
(let ((font-lock-keywords (if in-diff diff-font-lock-keywords
vc-hg--log-view-long-font-lock-keywords)))
(font-lock-fontify-keywords-region (point) end))
(goto-char end)
(prog1 (< (point) limit)
(setq in-diff (eq ?d (char-after))))))
nil))
(define-derived-mode vc-hg-region-history-mode
vc-hg-log-view-mode "Hg-Region-History"
"Major mode to browse Hg's \"log -p\" output."
(setq-local vc-hg--log-view-long-font-lock-keywords
log-view-font-lock-keywords)
(setq-local font-lock-defaults
(cons 'vc-hg-region-history-font-lock-keywords
(cdr font-lock-defaults))))
(defun vc-hg-diff (files &optional oldvers newvers buffer _async)
"Get a difference report using hg between two revisions of FILES."
(let* ((firstfile (car files))
(working (and firstfile (vc-working-revision firstfile))))
(when (and (equal oldvers working) (not newvers))
(setq oldvers nil))
(when (and (not oldvers) newvers)
(setq oldvers working))
(apply #'vc-hg-command
(or buffer "*vc-diff*")
nil ; bug#21969
files "diff"
(append
(vc-switches 'hg 'diff)
(when oldvers
(if newvers
(list "-r" oldvers "-r" newvers)
(list "-r" oldvers)))))))
(defun vc-hg-expanded-log-entry (revision)
(with-temp-buffer
(vc-hg-command t nil nil "log" "-r" revision "--template" vc-hg-log-format)
(goto-char (point-min))
(unless (eobp)
;; Indent the expanded log entry.
(indent-region (point-min) (point-max) 2)
(goto-char (point-max))
(buffer-string))))
(defun vc-hg-revision-table (files)
(let ((default-directory (file-name-directory (car files))))
(with-temp-buffer
(vc-hg-command t nil nil "branches" "-q")
(vc-hg-command t nil nil "bookmarks" "-q")
(vc-hg-command t nil nil "tags" "-q")
2008-02-20 15:21:55 +00:00
(split-string
(buffer-substring-no-properties (point-min) (point-max))))))
2008-06-27 02:41:14 +00:00
;; Modeled after the similar function in vc-cvs.el
(defun vc-hg-revision-completion-table (files)
(letrec ((table (lazy-completion-table
table (lambda () (vc-hg-revision-table files)))))
table))
(defun vc-hg-annotate-command (file buffer &optional revision)
"Execute \"hg annotate\" on FILE, inserting the contents in BUFFER.
Optional arg REVISION is a revision to annotate from."
(apply #'vc-hg-command buffer 0 file "annotate" "-dq" "-n"
(append (vc-switches 'hg 'annotate)
(if revision (list (concat "-r" revision))))))
(declare-function vc-annotate-convert-time "vc-annotate" (&optional time))
;; One line printed by "hg annotate -dq -n -u --follow" looks like this:
;; b56girard 114590 2012-03-13 CLOBBER: Lorem ipsum dolor sit
;; i.e. AUTHOR REVISION DATE FILENAME: CONTENTS
;; The user can omit options "-u" and/or "--follow". Then it'll look like:
;; 114590 2012-03-13 CLOBBER:
;; or
;; b56girard 114590 2012-03-13:
(defconst vc-hg-annotate-re
(concat
"^\\(?: *[^ ]+ +\\)?\\([0-9]+\\) " ;User and revision.
"\\([0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]\\)" ;Date.
"\\(?: +\\([^:]+\\)\\)?:")) ;Filename.
(defun vc-hg-annotate-time ()
(when (looking-at vc-hg-annotate-re)
(goto-char (match-end 0))
(vc-annotate-convert-time
(let ((str (match-string-no-properties 2)))
(encode-time 0 0 0
(string-to-number (substring str 6 8))
(string-to-number (substring str 4 6))
(string-to-number (substring str 0 4)))))))
(defun vc-hg-annotate-extract-revision-at-line ()
(save-excursion
(beginning-of-line)
(when (looking-at vc-hg-annotate-re)
(if (match-beginning 3)
(cons (match-string-no-properties 1)
(expand-file-name (match-string-no-properties 3)
(vc-hg-root default-directory)))
(match-string-no-properties 1)))))
;;; Tag system
(defun vc-hg-create-tag (dir name branchp)
"Create tag NAME in repo in DIR. Create branch if BRANCHP.
Variable `vc-hg-create-bookmark' controls what kind of branch will be created."
(let ((default-directory dir))
(vc-hg-command nil 0 nil
(if branchp
(if (if (eq vc-hg-create-bookmark 'ask)
(yes-or-no-p "Create bookmark instead of branch? ")
vc-hg-create-bookmark)
"bookmark"
"branch")
"tag")
name)))
(defun vc-hg-retrieve-tag (dir name _update)
"Retrieve the version tagged by NAME of all registered files at or below DIR."
(let ((default-directory dir))
(vc-hg-command nil 0 nil "update" (and (not (equal name ""))
name))
;; TODO: update *vc-change-log* buffer so can see @ if --graph
))
Performance improvements for vc-hg Teach vc-hg how to read some Mercurial internal data structures, allowing us to avoid the need to run hg status -A, which is very slow for large repositories. Fall back to running hg if anything looks funny. vc-hg now puts the _working directory_ revision in the modeline instead of the file revision, which greatly improves performance and which allows us to again skip running hg in the case that we have an active bookmark. * lisp/vc/vc-hg.el (vc-hg-state): Try calling `vc-hg-statefast' (vc-hg-symbolic-revision-styles) (vc-hg-use-file-version-for-mode-line-version) (vc-hg-parse-hg-data-structures): New user preferences (vc-hg--active-bookmark-internal, vc-hg--run-log) (vc-hg--symbolic-revision, vc-hg-mode-line-string) (vc-hg--read-u8, vc-hg--read-u32-be) (vc-hg--raw-dirstate-search, vc-hg--cached-dirstate-search) (vc-hg--parts-to-string, vc-hg--pcre-to-elisp-re) (vc-hg--glob-to-pcre, vc-hg--hgignore-add-pcre) (vc-hg--hgignore-add-glob, vc-hg--hgignore-add-path) (vc-hg--slurp-hgignore-1, vc-hg--slurp-hgignore) (vc-hg--ignore-patterns-valid-p) (vc-hg--ignore-patterns-ignored-p, vc-hg--time-to-fixnum) (vc-hg--file-ignored-p, vc-hg--read-repo-requirements) (vc-hg--requirements-understood-p, vc-hg--dirstate-scan-cache) (vc-hg-state-fast): New functions. (vc-hg--hgignore-patterns, vc-hg--hgignore-filenames) (vc-hg--cached-ignore-patterns, vc-hg--dirstate-scan-cache) (vc-hg--dirstate-scan-cache): New internal variables. * lisp/vc/vc-hooks.el (vc-refresh-state): Invoke vc find-file-hook before updating modeline.
2016-02-08 10:52:54 -08:00
;;; Native data structure reading
(defcustom vc-hg-parse-hg-data-structures t
"If true, try parsing Mercurial data structures directly.
This is done instead of always running Mercurial. We try to be safe
Performance improvements for vc-hg Teach vc-hg how to read some Mercurial internal data structures, allowing us to avoid the need to run hg status -A, which is very slow for large repositories. Fall back to running hg if anything looks funny. vc-hg now puts the _working directory_ revision in the modeline instead of the file revision, which greatly improves performance and which allows us to again skip running hg in the case that we have an active bookmark. * lisp/vc/vc-hg.el (vc-hg-state): Try calling `vc-hg-statefast' (vc-hg-symbolic-revision-styles) (vc-hg-use-file-version-for-mode-line-version) (vc-hg-parse-hg-data-structures): New user preferences (vc-hg--active-bookmark-internal, vc-hg--run-log) (vc-hg--symbolic-revision, vc-hg-mode-line-string) (vc-hg--read-u8, vc-hg--read-u32-be) (vc-hg--raw-dirstate-search, vc-hg--cached-dirstate-search) (vc-hg--parts-to-string, vc-hg--pcre-to-elisp-re) (vc-hg--glob-to-pcre, vc-hg--hgignore-add-pcre) (vc-hg--hgignore-add-glob, vc-hg--hgignore-add-path) (vc-hg--slurp-hgignore-1, vc-hg--slurp-hgignore) (vc-hg--ignore-patterns-valid-p) (vc-hg--ignore-patterns-ignored-p, vc-hg--time-to-fixnum) (vc-hg--file-ignored-p, vc-hg--read-repo-requirements) (vc-hg--requirements-understood-p, vc-hg--dirstate-scan-cache) (vc-hg-state-fast): New functions. (vc-hg--hgignore-patterns, vc-hg--hgignore-filenames) (vc-hg--cached-ignore-patterns, vc-hg--dirstate-scan-cache) (vc-hg--dirstate-scan-cache): New internal variables. * lisp/vc/vc-hooks.el (vc-refresh-state): Invoke vc find-file-hook before updating modeline.
2016-02-08 10:52:54 -08:00
against Mercurial data structure format changes and always fall
back to running Mercurial directly."
:type 'boolean
:version "26.1")
Performance improvements for vc-hg Teach vc-hg how to read some Mercurial internal data structures, allowing us to avoid the need to run hg status -A, which is very slow for large repositories. Fall back to running hg if anything looks funny. vc-hg now puts the _working directory_ revision in the modeline instead of the file revision, which greatly improves performance and which allows us to again skip running hg in the case that we have an active bookmark. * lisp/vc/vc-hg.el (vc-hg-state): Try calling `vc-hg-statefast' (vc-hg-symbolic-revision-styles) (vc-hg-use-file-version-for-mode-line-version) (vc-hg-parse-hg-data-structures): New user preferences (vc-hg--active-bookmark-internal, vc-hg--run-log) (vc-hg--symbolic-revision, vc-hg-mode-line-string) (vc-hg--read-u8, vc-hg--read-u32-be) (vc-hg--raw-dirstate-search, vc-hg--cached-dirstate-search) (vc-hg--parts-to-string, vc-hg--pcre-to-elisp-re) (vc-hg--glob-to-pcre, vc-hg--hgignore-add-pcre) (vc-hg--hgignore-add-glob, vc-hg--hgignore-add-path) (vc-hg--slurp-hgignore-1, vc-hg--slurp-hgignore) (vc-hg--ignore-patterns-valid-p) (vc-hg--ignore-patterns-ignored-p, vc-hg--time-to-fixnum) (vc-hg--file-ignored-p, vc-hg--read-repo-requirements) (vc-hg--requirements-understood-p, vc-hg--dirstate-scan-cache) (vc-hg-state-fast): New functions. (vc-hg--hgignore-patterns, vc-hg--hgignore-filenames) (vc-hg--cached-ignore-patterns, vc-hg--dirstate-scan-cache) (vc-hg--dirstate-scan-cache): New internal variables. * lisp/vc/vc-hooks.el (vc-refresh-state): Invoke vc find-file-hook before updating modeline.
2016-02-08 10:52:54 -08:00
(defsubst vc-hg--read-u8 ()
"Read and advance over an unsigned byte.
Return the byte's value as an integer."
Performance improvements for vc-hg Teach vc-hg how to read some Mercurial internal data structures, allowing us to avoid the need to run hg status -A, which is very slow for large repositories. Fall back to running hg if anything looks funny. vc-hg now puts the _working directory_ revision in the modeline instead of the file revision, which greatly improves performance and which allows us to again skip running hg in the case that we have an active bookmark. * lisp/vc/vc-hg.el (vc-hg-state): Try calling `vc-hg-statefast' (vc-hg-symbolic-revision-styles) (vc-hg-use-file-version-for-mode-line-version) (vc-hg-parse-hg-data-structures): New user preferences (vc-hg--active-bookmark-internal, vc-hg--run-log) (vc-hg--symbolic-revision, vc-hg-mode-line-string) (vc-hg--read-u8, vc-hg--read-u32-be) (vc-hg--raw-dirstate-search, vc-hg--cached-dirstate-search) (vc-hg--parts-to-string, vc-hg--pcre-to-elisp-re) (vc-hg--glob-to-pcre, vc-hg--hgignore-add-pcre) (vc-hg--hgignore-add-glob, vc-hg--hgignore-add-path) (vc-hg--slurp-hgignore-1, vc-hg--slurp-hgignore) (vc-hg--ignore-patterns-valid-p) (vc-hg--ignore-patterns-ignored-p, vc-hg--time-to-fixnum) (vc-hg--file-ignored-p, vc-hg--read-repo-requirements) (vc-hg--requirements-understood-p, vc-hg--dirstate-scan-cache) (vc-hg-state-fast): New functions. (vc-hg--hgignore-patterns, vc-hg--hgignore-filenames) (vc-hg--cached-ignore-patterns, vc-hg--dirstate-scan-cache) (vc-hg--dirstate-scan-cache): New internal variables. * lisp/vc/vc-hooks.el (vc-refresh-state): Invoke vc find-file-hook before updating modeline.
2016-02-08 10:52:54 -08:00
(prog1 (char-after)
(forward-char)))
(defsubst vc-hg--read-u32-be ()
"Read and advance over a big-endian unsigned 32-bit integer."
Performance improvements for vc-hg Teach vc-hg how to read some Mercurial internal data structures, allowing us to avoid the need to run hg status -A, which is very slow for large repositories. Fall back to running hg if anything looks funny. vc-hg now puts the _working directory_ revision in the modeline instead of the file revision, which greatly improves performance and which allows us to again skip running hg in the case that we have an active bookmark. * lisp/vc/vc-hg.el (vc-hg-state): Try calling `vc-hg-statefast' (vc-hg-symbolic-revision-styles) (vc-hg-use-file-version-for-mode-line-version) (vc-hg-parse-hg-data-structures): New user preferences (vc-hg--active-bookmark-internal, vc-hg--run-log) (vc-hg--symbolic-revision, vc-hg-mode-line-string) (vc-hg--read-u8, vc-hg--read-u32-be) (vc-hg--raw-dirstate-search, vc-hg--cached-dirstate-search) (vc-hg--parts-to-string, vc-hg--pcre-to-elisp-re) (vc-hg--glob-to-pcre, vc-hg--hgignore-add-pcre) (vc-hg--hgignore-add-glob, vc-hg--hgignore-add-path) (vc-hg--slurp-hgignore-1, vc-hg--slurp-hgignore) (vc-hg--ignore-patterns-valid-p) (vc-hg--ignore-patterns-ignored-p, vc-hg--time-to-fixnum) (vc-hg--file-ignored-p, vc-hg--read-repo-requirements) (vc-hg--requirements-understood-p, vc-hg--dirstate-scan-cache) (vc-hg-state-fast): New functions. (vc-hg--hgignore-patterns, vc-hg--hgignore-filenames) (vc-hg--cached-ignore-patterns, vc-hg--dirstate-scan-cache) (vc-hg--dirstate-scan-cache): New internal variables. * lisp/vc/vc-hooks.el (vc-refresh-state): Invoke vc find-file-hook before updating modeline.
2016-02-08 10:52:54 -08:00
;; Because elisp bytecode has an instruction for multiply and
;; doesn't have one for shift, it's somewhat counter-intuitively
Performance improvements for vc-hg Teach vc-hg how to read some Mercurial internal data structures, allowing us to avoid the need to run hg status -A, which is very slow for large repositories. Fall back to running hg if anything looks funny. vc-hg now puts the _working directory_ revision in the modeline instead of the file revision, which greatly improves performance and which allows us to again skip running hg in the case that we have an active bookmark. * lisp/vc/vc-hg.el (vc-hg-state): Try calling `vc-hg-statefast' (vc-hg-symbolic-revision-styles) (vc-hg-use-file-version-for-mode-line-version) (vc-hg-parse-hg-data-structures): New user preferences (vc-hg--active-bookmark-internal, vc-hg--run-log) (vc-hg--symbolic-revision, vc-hg-mode-line-string) (vc-hg--read-u8, vc-hg--read-u32-be) (vc-hg--raw-dirstate-search, vc-hg--cached-dirstate-search) (vc-hg--parts-to-string, vc-hg--pcre-to-elisp-re) (vc-hg--glob-to-pcre, vc-hg--hgignore-add-pcre) (vc-hg--hgignore-add-glob, vc-hg--hgignore-add-path) (vc-hg--slurp-hgignore-1, vc-hg--slurp-hgignore) (vc-hg--ignore-patterns-valid-p) (vc-hg--ignore-patterns-ignored-p, vc-hg--time-to-fixnum) (vc-hg--file-ignored-p, vc-hg--read-repo-requirements) (vc-hg--requirements-understood-p, vc-hg--dirstate-scan-cache) (vc-hg-state-fast): New functions. (vc-hg--hgignore-patterns, vc-hg--hgignore-filenames) (vc-hg--cached-ignore-patterns, vc-hg--dirstate-scan-cache) (vc-hg--dirstate-scan-cache): New internal variables. * lisp/vc/vc-hooks.el (vc-refresh-state): Invoke vc find-file-hook before updating modeline.
2016-02-08 10:52:54 -08:00
;; faster to multiply than to shift.
(+ (* (vc-hg--read-u8) (* 256 256 256))
(* (vc-hg--read-u8) (* 256 256))
(* (vc-hg--read-u8) 256)
(identity (vc-hg--read-u8))))
(defun vc-hg--raw-dirstate-search (dirstate fname)
(with-temp-buffer
(set-buffer-multibyte nil)
(insert-file-contents-literally dirstate)
(let* ((result nil)
(flen (length fname))
(case-fold-search nil)
;; Find a conservative bound for the loop below by using
;; Boyer-Moore on the raw dirstate without parsing it; we
;; know we can't possibly find fname _after_ the last place
;; it appears, so we can bail out early if we try to parse
;; past it, which especially helps when the file we're
;; trying to find isn't in dirstate at all. There's no way
;; to similarly bound the starting search position, since
;; the file format is such that we need to parse it from
;; the beginning to find record boundaries.
(search-limit
(progn
(goto-char (point-max))
(or (search-backward fname (+ (point-min) 40) t)
(point-min)))))
;; 40 is just after the header, which contains the working
;; directory parents
(goto-char (+ (point-min) 40))
;; Iterate over all dirstate entries; we might run this loop
;; hundreds of thousands of times, so performance is important
;; here
(while (< (point) search-limit)
;; 1+4*4 is the length of the dirstate item header.
Performance improvements for vc-hg Teach vc-hg how to read some Mercurial internal data structures, allowing us to avoid the need to run hg status -A, which is very slow for large repositories. Fall back to running hg if anything looks funny. vc-hg now puts the _working directory_ revision in the modeline instead of the file revision, which greatly improves performance and which allows us to again skip running hg in the case that we have an active bookmark. * lisp/vc/vc-hg.el (vc-hg-state): Try calling `vc-hg-statefast' (vc-hg-symbolic-revision-styles) (vc-hg-use-file-version-for-mode-line-version) (vc-hg-parse-hg-data-structures): New user preferences (vc-hg--active-bookmark-internal, vc-hg--run-log) (vc-hg--symbolic-revision, vc-hg-mode-line-string) (vc-hg--read-u8, vc-hg--read-u32-be) (vc-hg--raw-dirstate-search, vc-hg--cached-dirstate-search) (vc-hg--parts-to-string, vc-hg--pcre-to-elisp-re) (vc-hg--glob-to-pcre, vc-hg--hgignore-add-pcre) (vc-hg--hgignore-add-glob, vc-hg--hgignore-add-path) (vc-hg--slurp-hgignore-1, vc-hg--slurp-hgignore) (vc-hg--ignore-patterns-valid-p) (vc-hg--ignore-patterns-ignored-p, vc-hg--time-to-fixnum) (vc-hg--file-ignored-p, vc-hg--read-repo-requirements) (vc-hg--requirements-understood-p, vc-hg--dirstate-scan-cache) (vc-hg-state-fast): New functions. (vc-hg--hgignore-patterns, vc-hg--hgignore-filenames) (vc-hg--cached-ignore-patterns, vc-hg--dirstate-scan-cache) (vc-hg--dirstate-scan-cache): New internal variables. * lisp/vc/vc-hooks.el (vc-refresh-state): Invoke vc find-file-hook before updating modeline.
2016-02-08 10:52:54 -08:00
(forward-char (1+ (* 3 4)))
(let ((this-flen (vc-hg--read-u32-be)))
(if (and (or (eq this-flen flen)
Performance improvements for vc-hg Teach vc-hg how to read some Mercurial internal data structures, allowing us to avoid the need to run hg status -A, which is very slow for large repositories. Fall back to running hg if anything looks funny. vc-hg now puts the _working directory_ revision in the modeline instead of the file revision, which greatly improves performance and which allows us to again skip running hg in the case that we have an active bookmark. * lisp/vc/vc-hg.el (vc-hg-state): Try calling `vc-hg-statefast' (vc-hg-symbolic-revision-styles) (vc-hg-use-file-version-for-mode-line-version) (vc-hg-parse-hg-data-structures): New user preferences (vc-hg--active-bookmark-internal, vc-hg--run-log) (vc-hg--symbolic-revision, vc-hg-mode-line-string) (vc-hg--read-u8, vc-hg--read-u32-be) (vc-hg--raw-dirstate-search, vc-hg--cached-dirstate-search) (vc-hg--parts-to-string, vc-hg--pcre-to-elisp-re) (vc-hg--glob-to-pcre, vc-hg--hgignore-add-pcre) (vc-hg--hgignore-add-glob, vc-hg--hgignore-add-path) (vc-hg--slurp-hgignore-1, vc-hg--slurp-hgignore) (vc-hg--ignore-patterns-valid-p) (vc-hg--ignore-patterns-ignored-p, vc-hg--time-to-fixnum) (vc-hg--file-ignored-p, vc-hg--read-repo-requirements) (vc-hg--requirements-understood-p, vc-hg--dirstate-scan-cache) (vc-hg-state-fast): New functions. (vc-hg--hgignore-patterns, vc-hg--hgignore-filenames) (vc-hg--cached-ignore-patterns, vc-hg--dirstate-scan-cache) (vc-hg--dirstate-scan-cache): New internal variables. * lisp/vc/vc-hooks.el (vc-refresh-state): Invoke vc find-file-hook before updating modeline.
2016-02-08 10:52:54 -08:00
(and (> this-flen flen)
(eq (char-after (+ (point) flen)) 0)))
(search-forward fname (+ (point) flen) t))
(progn
(backward-char (+ flen (1+ (* 4 4))))
(setf result
(list (vc-hg--read-u8) ; status
(vc-hg--read-u32-be) ; mode
(vc-hg--read-u32-be) ; size (of file)
(vc-hg--read-u32-be) ; mtime
))
(goto-char (point-max)))
(forward-char this-flen))))
result)))
(define-error 'vc-hg-unsupported-syntax "unsupported hgignore syntax")
(defconst vc-hg--pcre-c-escapes
'((?a . ?\a)
(?b . ?\b)
(?f . ?\f)
(?n . ?\n)
(?r . ?\r)
(?t . ?\t)
(?n . ?\n)
(?r . ?\r)
(?t . ?\t)
(?v . ?\v)))
(defconst vc-hg--pcre-metacharacters
'(?. ?^ ?$ ?* ?+ ?? ?{ ?\\ ?\[ ?\| ?\())
(defconst vc-hg--elisp-metacharacters
'(?. ?* ?+ ?? ?\[ ?$ ?\\))
(defun vc-hg--escape-for-pcre (c)
(if (memq c vc-hg--pcre-metacharacters)
(string ?\\ c)
c))
(defun vc-hg--parts-to-string (parts)
"Build a string from list PARTS. Each element is a character or string."
(let ((parts2 nil))
(while parts
(let* ((partcell (prog1 parts (setf parts (cdr parts))))
(part (car partcell)))
(if (stringp part)
(setf parts2 (nconc (append part nil) parts2))
(setcdr partcell parts2)
(setf parts2 partcell))))
(apply #'string parts2)))
(defun vc-hg--pcre-to-elisp-re (pcre prefix)
"Transform PCRE, a Mercurial file PCRE, into an elisp RE against PREFIX.
PREFIX is the directory name of the directory against which these
patterns are rooted. We understand only a subset of PCRE syntax;
if we don't understand a construct, we signal
`vc-hg-unsupported-syntax'."
(cl-assert (and (file-name-absolute-p prefix)
(directory-name-p prefix)))
Performance improvements for vc-hg Teach vc-hg how to read some Mercurial internal data structures, allowing us to avoid the need to run hg status -A, which is very slow for large repositories. Fall back to running hg if anything looks funny. vc-hg now puts the _working directory_ revision in the modeline instead of the file revision, which greatly improves performance and which allows us to again skip running hg in the case that we have an active bookmark. * lisp/vc/vc-hg.el (vc-hg-state): Try calling `vc-hg-statefast' (vc-hg-symbolic-revision-styles) (vc-hg-use-file-version-for-mode-line-version) (vc-hg-parse-hg-data-structures): New user preferences (vc-hg--active-bookmark-internal, vc-hg--run-log) (vc-hg--symbolic-revision, vc-hg-mode-line-string) (vc-hg--read-u8, vc-hg--read-u32-be) (vc-hg--raw-dirstate-search, vc-hg--cached-dirstate-search) (vc-hg--parts-to-string, vc-hg--pcre-to-elisp-re) (vc-hg--glob-to-pcre, vc-hg--hgignore-add-pcre) (vc-hg--hgignore-add-glob, vc-hg--hgignore-add-path) (vc-hg--slurp-hgignore-1, vc-hg--slurp-hgignore) (vc-hg--ignore-patterns-valid-p) (vc-hg--ignore-patterns-ignored-p, vc-hg--time-to-fixnum) (vc-hg--file-ignored-p, vc-hg--read-repo-requirements) (vc-hg--requirements-understood-p, vc-hg--dirstate-scan-cache) (vc-hg-state-fast): New functions. (vc-hg--hgignore-patterns, vc-hg--hgignore-filenames) (vc-hg--cached-ignore-patterns, vc-hg--dirstate-scan-cache) (vc-hg--dirstate-scan-cache): New internal variables. * lisp/vc/vc-hooks.el (vc-refresh-state): Invoke vc find-file-hook before updating modeline.
2016-02-08 10:52:54 -08:00
(let ((parts nil)
(i 0)
(anchored nil)
(state 'normal)
(pcrelen (length pcre)))
(while (< i pcrelen)
(let ((c (aref pcre i)))
(cond ((eq state 'normal)
(cond ((string-match
(rx (| "}\\?" (: "(?" (not (any ":")))))
pcre i)
(signal 'vc-hg-unsupported-syntax (list pcre)))
((eq c ?\\)
(setf state 'backslash))
((eq c ?\[)
(setf state 'charclass-enter)
(push c parts))
((eq c ?^)
(if (eq i 0) (setf anchored t)
(signal 'vc-hg-unsupported-syntax (list pcre))))
((eq c ?$)
;; Patterns can also match directories exactly,
;; ignoring everything under a matched directory
(push "\\(?:$\\|/\\)" parts))
((memq c '(?| ?\( ?\)))
(push ?\\ parts)
(push c parts))
(t (push c parts))))
((eq state 'backslash)
(cond ((memq c '(?0 ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9
?A ?b ?B ?d ?D ?s ?S ?w ?W ?Z ?x))
(signal 'vc-hg-unsupported-syntax (list pcre)))
((memq c vc-hg--elisp-metacharacters)
(push ?\\ parts)
(push c parts))
(t (push (or (cdr (assq c vc-hg--pcre-c-escapes)) c) parts)))
(setf state 'normal))
((eq state 'charclass-enter)
(push c parts)
(setf state
(if (eq c ?\\)
'charclass
'charclass-backslash)))
((eq state 'charclass-backslash)
(if (memq c '(?0 ?x))
(signal 'vc-hg-unsupported-syntax (list pcre)))
(push (or (cdr (assq c vc-hg--pcre-c-escapes)) c) parts)
(setf state 'charclass))
((eq state 'charclass)
(push c parts)
(cond ((eq c ?\\) (setf state 'charclass-backslash))
((eq c ?\]) (setf state 'normal))))
(t (error "Invalid state")))
Performance improvements for vc-hg Teach vc-hg how to read some Mercurial internal data structures, allowing us to avoid the need to run hg status -A, which is very slow for large repositories. Fall back to running hg if anything looks funny. vc-hg now puts the _working directory_ revision in the modeline instead of the file revision, which greatly improves performance and which allows us to again skip running hg in the case that we have an active bookmark. * lisp/vc/vc-hg.el (vc-hg-state): Try calling `vc-hg-statefast' (vc-hg-symbolic-revision-styles) (vc-hg-use-file-version-for-mode-line-version) (vc-hg-parse-hg-data-structures): New user preferences (vc-hg--active-bookmark-internal, vc-hg--run-log) (vc-hg--symbolic-revision, vc-hg-mode-line-string) (vc-hg--read-u8, vc-hg--read-u32-be) (vc-hg--raw-dirstate-search, vc-hg--cached-dirstate-search) (vc-hg--parts-to-string, vc-hg--pcre-to-elisp-re) (vc-hg--glob-to-pcre, vc-hg--hgignore-add-pcre) (vc-hg--hgignore-add-glob, vc-hg--hgignore-add-path) (vc-hg--slurp-hgignore-1, vc-hg--slurp-hgignore) (vc-hg--ignore-patterns-valid-p) (vc-hg--ignore-patterns-ignored-p, vc-hg--time-to-fixnum) (vc-hg--file-ignored-p, vc-hg--read-repo-requirements) (vc-hg--requirements-understood-p, vc-hg--dirstate-scan-cache) (vc-hg-state-fast): New functions. (vc-hg--hgignore-patterns, vc-hg--hgignore-filenames) (vc-hg--cached-ignore-patterns, vc-hg--dirstate-scan-cache) (vc-hg--dirstate-scan-cache): New internal variables. * lisp/vc/vc-hooks.el (vc-refresh-state): Invoke vc find-file-hook before updating modeline.
2016-02-08 10:52:54 -08:00
(setf i (1+ i))))
(unless (eq state 'normal)
(signal 'vc-hg-unsupported-syntax (list pcre)))
(concat
"^"
prefix
(if anchored "" "\\(?:.*/\\)?")
(vc-hg--parts-to-string parts))))
(defun vc-hg--glob-to-pcre (glob)
"Transform a glob pattern into a Mercurial file pattern regex."
(let ((parts nil) (i 0) (n (length glob)) (group 0) c)
(cl-macrolet ((peek () '(and (< i n) (aref glob i))))
(while (< i n)
(setf c (aref glob i))
(cl-incf i)
(cond ((not (memq c '(?* ?? ?\[ ?\{ ?\} ?, ?\\)))
(push (vc-hg--escape-for-pcre c) parts))
((eq c ?*)
(cond ((eq (peek) ?*)
(cl-incf i)
(cond ((eq (peek) ?/)
(cl-incf i)
(push "(?:.*/)?" parts))
(t
(push ".*" parts))))
(t (push "[^/]*" parts))))
((eq c ??)
(push ?. parts))
((eq c ?\[)
(let ((j i))
(when (and (< j n) (memq (aref glob j) '(?! ?\])))
(cl-incf j))
(while (and (< j n) (not (eq (aref glob j) ?\])))
(cl-incf j))
(cond ((>= j n)
(push "\\[" parts))
(t
(let ((x (substring glob i j)))
Use string-replace instead of replace-regexp-in-string `string-replace` is easier to understand, less error-prone, much faster, and results in shorter Lisp and byte code. Use it where applicable and obviously safe (erring on the conservative side). * admin/authors.el (authors-scan-change-log): * lisp/autoinsert.el (auto-insert-alist): * lisp/calc/calc-prog.el (calc-edit-macro-combine-alg-ent) (calc-edit-macro-combine-ext-command) (calc-edit-macro-combine-var-name): * lisp/calc/calc-units.el (math-make-unit-string): * lisp/calendar/cal-html.el (cal-html-comment): * lisp/calendar/cal-tex.el (cal-tex-comment): * lisp/calendar/icalendar.el (icalendar--convert-string-for-export) (icalendar--convert-string-for-import): * lisp/calendar/iso8601.el (iso8601--concat-regexps) (iso8601--full-time-match, iso8601--combined-match): * lisp/calendar/time-date.el (format-seconds): * lisp/calendar/todo-mode.el (todo-filter-items-filename): * lisp/cedet/cedet-files.el (cedet-directory-name-to-file-name) (cedet-file-name-to-directory-name): * lisp/comint.el (comint-watch-for-password-prompt): * lisp/dired-aux.el (dired-do-chmod): * lisp/dired-x.el (dired-man): * lisp/dired.el (dired-insert-directory, dired-goto-file-1): * lisp/emacs-lisp/comp.el (comp-c-func-name): * lisp/emacs-lisp/re-builder.el (reb-copy): * lisp/erc/erc-dcc.el (erc-dcc-unquote-filename): * lisp/erc/erc.el (erc-quit-reason-zippy, erc-part-reason-zippy) (erc-update-mode-line-buffer, erc-message-english-PART): * lisp/files.el (make-backup-file-name-1, files--transform-file-name) (read-file-modes): * lisp/fringe.el (fringe-mode): * lisp/gnus/gnus-art.el (gnus-button-handle-info-url): * lisp/gnus/gnus-group.el (gnus-group-completing-read): * lisp/gnus/gnus-icalendar.el (gnus-icalendar-event-from-ical): * lisp/gnus/gnus-mlspl.el (gnus-group-split-fancy): * lisp/gnus/gnus-search.el (gnus-search-query-parse-date) (gnus-search-transform-expression, gnus-search-run-search): * lisp/gnus/gnus-start.el (gnus-dribble-enter): * lisp/gnus/gnus-sum.el (gnus-summary-refer-article): * lisp/gnus/gnus-util.el (gnus-mode-string-quote): * lisp/gnus/message.el (message-put-addresses-in-ecomplete) (message-parse-mailto-url, message-mailto-1): * lisp/gnus/mml-sec.el (mml-secure-epg-sign): * lisp/gnus/mml-smime.el (mml-smime-epg-verify): * lisp/gnus/mml2015.el (mml2015-epg-verify): * lisp/gnus/nnmaildir.el (nnmaildir--system-name) (nnmaildir-request-list, nnmaildir-retrieve-groups) (nnmaildir-request-group, nnmaildir-retrieve-headers): * lisp/gnus/nnrss.el (nnrss-node-text): * lisp/gnus/spam-report.el (spam-report-gmane-internal) (spam-report-user-mail-address): * lisp/ibuffer.el (name): * lisp/image-dired.el (image-dired-pngnq-thumb) (image-dired-pngcrush-thumb, image-dired-optipng-thumb) (image-dired-create-thumb-1): * lisp/info.el (Info-set-mode-line): * lisp/international/mule-cmds.el (describe-language-environment): * lisp/mail/rfc2231.el (rfc2231-parse-string): * lisp/mail/rfc2368.el (rfc2368-parse-mailto-url): * lisp/mail/rmail.el (rmail-insert-inbox-text) (rmail-simplified-subject-regexp): * lisp/mail/rmailout.el (rmail-output-body-to-file): * lisp/mail/undigest.el (rmail-digest-rfc1153): * lisp/man.el (Man-default-man-entry): * lisp/mouse.el (minor-mode-menu-from-indicator): * lisp/mpc.el (mpc--debug): * lisp/net/browse-url.el (browse-url-mail): * lisp/net/eww.el (eww-update-header-line-format): * lisp/net/newst-backend.el (newsticker-save-item): * lisp/net/rcirc.el (rcirc-sentinel): * lisp/net/soap-client.el (soap-decode-date-time): * lisp/nxml/rng-cmpct.el (rng-c-literal-2-re): * lisp/nxml/xmltok.el (let*): * lisp/obsolete/nnir.el (nnir-run-swish-e, nnir-run-hyrex) (nnir-run-find-grep): * lisp/play/dunnet.el (dun-doassign): * lisp/play/handwrite.el (handwrite): * lisp/proced.el (proced-format-args): * lisp/profiler.el (profiler-report-header-line-format): * lisp/progmodes/gdb-mi.el (gdb-mi-quote): * lisp/progmodes/make-mode.el (makefile-bsdmake-rule-action-regex) (makefile-make-font-lock-keywords): * lisp/progmodes/prolog.el (prolog-guess-fill-prefix): * lisp/progmodes/ruby-mode.el (ruby-toggle-string-quotes): * lisp/progmodes/sql.el (sql-remove-tabs-filter, sql-str-literal): * lisp/progmodes/which-func.el (which-func-current): * lisp/replace.el (query-replace-read-from) (occur-engine, replace-quote): * lisp/select.el (xselect--encode-string): * lisp/ses.el (ses-export-tab): * lisp/subr.el (shell-quote-argument): * lisp/term/pc-win.el (msdos-show-help): * lisp/term/w32-win.el (w32--set-selection): * lisp/term/xterm.el (gui-backend-set-selection): * lisp/textmodes/picture.el (picture-tab-search): * lisp/thumbs.el (thumbs-call-setroot-command): * lisp/tooltip.el (tooltip-show-help-non-mode): * lisp/transient.el (transient-format-key): * lisp/url/url-mailto.el (url-mailto): * lisp/vc/log-edit.el (log-edit-changelog-ours-p): * lisp/vc/vc-bzr.el (vc-bzr-status): * lisp/vc/vc-hg.el (vc-hg--glob-to-pcre): * lisp/vc/vc-svn.el (vc-svn-after-dir-status): * lisp/xdg.el (xdg-desktop-strings): * test/lisp/electric-tests.el (defun): * test/lisp/term-tests.el (term-simple-lines): * test/lisp/time-stamp-tests.el (formatz-mod-del-colons): * test/lisp/wdired-tests.el (wdired-test-bug32173-01) (wdired-test-unfinished-edit-01): * test/src/json-tests.el (json-parse-with-custom-null-and-false-objects): Use `string-replace` instead of `replace-regexp-in-string`.
2021-08-08 18:58:46 +02:00
(setf x (string-replace
"\\" "\\\\" x))
Performance improvements for vc-hg Teach vc-hg how to read some Mercurial internal data structures, allowing us to avoid the need to run hg status -A, which is very slow for large repositories. Fall back to running hg if anything looks funny. vc-hg now puts the _working directory_ revision in the modeline instead of the file revision, which greatly improves performance and which allows us to again skip running hg in the case that we have an active bookmark. * lisp/vc/vc-hg.el (vc-hg-state): Try calling `vc-hg-statefast' (vc-hg-symbolic-revision-styles) (vc-hg-use-file-version-for-mode-line-version) (vc-hg-parse-hg-data-structures): New user preferences (vc-hg--active-bookmark-internal, vc-hg--run-log) (vc-hg--symbolic-revision, vc-hg-mode-line-string) (vc-hg--read-u8, vc-hg--read-u32-be) (vc-hg--raw-dirstate-search, vc-hg--cached-dirstate-search) (vc-hg--parts-to-string, vc-hg--pcre-to-elisp-re) (vc-hg--glob-to-pcre, vc-hg--hgignore-add-pcre) (vc-hg--hgignore-add-glob, vc-hg--hgignore-add-path) (vc-hg--slurp-hgignore-1, vc-hg--slurp-hgignore) (vc-hg--ignore-patterns-valid-p) (vc-hg--ignore-patterns-ignored-p, vc-hg--time-to-fixnum) (vc-hg--file-ignored-p, vc-hg--read-repo-requirements) (vc-hg--requirements-understood-p, vc-hg--dirstate-scan-cache) (vc-hg-state-fast): New functions. (vc-hg--hgignore-patterns, vc-hg--hgignore-filenames) (vc-hg--cached-ignore-patterns, vc-hg--dirstate-scan-cache) (vc-hg--dirstate-scan-cache): New internal variables. * lisp/vc/vc-hooks.el (vc-refresh-state): Invoke vc find-file-hook before updating modeline.
2016-02-08 10:52:54 -08:00
(setf i (1+ j))
(cond ((eq (aref x 0) ?!)
(setf (aref x 0) ?^))
((eq (aref x 0) ?^)
(setf x (concat "\\" x))))
(push ?\[ parts)
(push x parts)
(push ?\] parts))))))
((eq c ?\{)
(cl-incf group)
(push "(?:" parts))
((eq c ?\})
(push ?\) parts)
(cl-decf group))
((and (eq c ?,) (> group 0))
(push ?| parts))
((eq c ?\\)
(if (eq i n)
(push "\\\\" parts)
(cl-incf i)
(push ?\\ parts)
(push c parts)))
(t
(push (vc-hg--escape-for-pcre c) parts)))))
(concat (vc-hg--parts-to-string parts) "$")))
(defvar vc-hg--hgignore-patterns)
(defvar vc-hg--hgignore-filenames)
(defun vc-hg--hgignore-add-pcre (pcre prefix)
(push (vc-hg--pcre-to-elisp-re pcre prefix) vc-hg--hgignore-patterns))
(defun vc-hg--hgignore-add-glob (glob prefix)
(push (vc-hg--pcre-to-elisp-re (vc-hg--glob-to-pcre glob) prefix)
vc-hg--hgignore-patterns))
(defun vc-hg--hgignore-add-path (path prefix)
(let ((parts nil))
(dotimes (i (length path))
(push (vc-hg--escape-for-pcre (aref path i)) parts))
(vc-hg--hgignore-add-pcre
(concat "^" (vc-hg--parts-to-string parts) "$")
prefix)))
(defun vc-hg--slurp-hgignore-1 (hgignore prefix)
(let ((default-syntax 'vc-hg--hgignore-add-pcre))
Performance improvements for vc-hg Teach vc-hg how to read some Mercurial internal data structures, allowing us to avoid the need to run hg status -A, which is very slow for large repositories. Fall back to running hg if anything looks funny. vc-hg now puts the _working directory_ revision in the modeline instead of the file revision, which greatly improves performance and which allows us to again skip running hg in the case that we have an active bookmark. * lisp/vc/vc-hg.el (vc-hg-state): Try calling `vc-hg-statefast' (vc-hg-symbolic-revision-styles) (vc-hg-use-file-version-for-mode-line-version) (vc-hg-parse-hg-data-structures): New user preferences (vc-hg--active-bookmark-internal, vc-hg--run-log) (vc-hg--symbolic-revision, vc-hg-mode-line-string) (vc-hg--read-u8, vc-hg--read-u32-be) (vc-hg--raw-dirstate-search, vc-hg--cached-dirstate-search) (vc-hg--parts-to-string, vc-hg--pcre-to-elisp-re) (vc-hg--glob-to-pcre, vc-hg--hgignore-add-pcre) (vc-hg--hgignore-add-glob, vc-hg--hgignore-add-path) (vc-hg--slurp-hgignore-1, vc-hg--slurp-hgignore) (vc-hg--ignore-patterns-valid-p) (vc-hg--ignore-patterns-ignored-p, vc-hg--time-to-fixnum) (vc-hg--file-ignored-p, vc-hg--read-repo-requirements) (vc-hg--requirements-understood-p, vc-hg--dirstate-scan-cache) (vc-hg-state-fast): New functions. (vc-hg--hgignore-patterns, vc-hg--hgignore-filenames) (vc-hg--cached-ignore-patterns, vc-hg--dirstate-scan-cache) (vc-hg--dirstate-scan-cache): New internal variables. * lisp/vc/vc-hooks.el (vc-refresh-state): Invoke vc find-file-hook before updating modeline.
2016-02-08 10:52:54 -08:00
(with-temp-buffer
(let ((attr (file-attributes hgignore)))
(when attr (insert-file-contents hgignore))
file-attributes cleanup Mostly, this replaces magic-number calls like (nth 4 A) with more-informative calls like (file-attribute-access-time A). It also fixes some documentation and minor timestamp coding issues that I noticed while looking into this. * doc/lispref/files.texi (File Attributes): * lisp/files.el (file-attribute-size) (file-attribute-inode-number, file-attribute-device-number): * src/dired.c (Fdirectory_files_and_attributes) (Ffile_attributes): Mention which attributes must be integers, or nonnegative integers, as opposed to merely being numbers. Remove no-longer-correct talk about representing large integers as conses of integers. * doc/lispref/files.texi (Magic File Names): * doc/misc/gnus.texi (Low-level interface to the spam-stat dictionary): * lisp/autorevert.el (auto-revert-find-file-function) (auto-revert-tail-mode, auto-revert-handler): * lisp/auth-source.el (auth-source-netrc-parse): * lisp/cedet/ede/files.el (ede--inode-for-dir): * lisp/cedet/semantic/db-file.el (object-write): * lisp/cedet/semantic/db-mode.el (semanticdb-kill-hook): * lisp/cedet/semantic/db.el (semanticdb-needs-refresh-p) (semanticdb-synchronize): * lisp/cedet/srecode/table.el (srecode-mode-table-new): * lisp/desktop.el (desktop-save, desktop-read): * lisp/dired-aux.el (dired-file-set-difference) (dired-do-chxxx, dired-do-chmod, dired-copy-file-recursive) (dired-create-files): * lisp/dired.el (dired-directory-changed-p, dired-readin): * lisp/dos-w32.el (w32-direct-print-region-helper): * lisp/emacs-lisp/autoload.el (autoload-generate-file-autoloads) (autoload-find-destination, update-directory-autoloads): * lisp/emacs-lisp/shadow.el (load-path-shadows-same-file-or-nonexistent): * lisp/epg.el (epg--start, epg-wait-for-completion): * lisp/eshell/em-ls.el (eshell-ls-filetype-p) (eshell-ls-applicable, eshell-ls-size-string) (eshell-ls-file, eshell-ls-dir, eshell-ls-files) (eshell-ls-entries): * lisp/eshell/em-pred.el (eshell-predicate-alist) (eshell-pred-file-type, eshell-pred-file-links) (eshell-pred-file-size): * lisp/eshell/em-unix.el (eshell-shuffle-files, eshell/cat) (eshell-du-sum-directory, eshell/du): * lisp/eshell/esh-util.el (eshell-read-passwd) (eshell-read-hosts): * lisp/files.el (remote-file-name-inhibit-cache) (find-file-noselect, insert-file-1, dir-locals-find-file) (dir-locals-read-from-dir, backup-buffer) (file-ownership-preserved-p, copy-directory) (read-file-modes): * lisp/find-lisp.el (find-lisp-format): * lisp/gnus/gnus-agent.el (gnus-agent-unfetch-articles) (gnus-agent-read-agentview, gnus-agent-expire-group-1) (gnus-agent-request-article, gnus-agent-regenerate-group) (gnus-agent-update-files-total-fetched-for) (gnus-agent-update-view-total-fetched-for): * lisp/gnus/gnus-cache.el (gnus-cache-read-active) (gnus-cache-update-file-total-fetched-for) (gnus-cache-update-overview-total-fetched-for): * lisp/gnus/gnus-cloud.el (gnus-cloud-file-new-p): * lisp/gnus/gnus-score.el (gnus-score-score-files): * lisp/gnus/gnus-start.el (gnus-save-newsrc-file) (gnus-master-read-slave-newsrc): * lisp/gnus/gnus-sum.el (gnus-summary-import-article): * lisp/gnus/gnus-util.el (gnus-file-newer-than) (gnus-cache-file-contents): * lisp/gnus/mail-source.el (mail-source-delete-old-incoming) (mail-source-callback, mail-source-movemail): * lisp/gnus/nneething.el (nneething-create-mapping) (nneething-make-head): * lisp/gnus/nnfolder.el (nnfolder-read-folder): * lisp/gnus/nnheader.el (nnheader-file-size) (nnheader-insert-nov-file): * lisp/gnus/nnmail.el (nnmail-activate): * lisp/gnus/nnmaildir.el (nnmaildir--group-maxnum) (nnmaildir--new-number, nnmaildir--update-nov) (nnmaildir--scan, nnmaildir-request-scan) (nnmaildir-request-update-info) (nnmaildir-request-expire-articles): * lisp/gnus/nnmh.el (nnmh-request-list-1) (nnmh-request-expire-articles, nnmh-update-gnus-unreads): * lisp/gnus/nnml.el (nnml-request-expire-articles): * lisp/gnus/spam-stat.el (spam-stat-save, spam-stat-load) (spam-stat-process-directory, spam-stat-test-directory): * lisp/ido.el (ido-directory-too-big-p) (ido-file-name-all-completions): * lisp/image-dired.el (image-dired-get-thumbnail-image) (image-dired-create-thumb-1): * lisp/info.el (info-insert-file-contents): * lisp/ls-lisp.el (ls-lisp-insert-directory) (ls-lisp-handle-switches, ls-lisp-classify-file) (ls-lisp-format): * lisp/mail/blessmail.el: * lisp/mail/feedmail.el (feedmail-default-date-generator) (feedmail-default-message-id-generator): * lisp/mail/mailabbrev.el (mail-abbrevs-sync-aliases) (mail-abbrevs-setup): * lisp/mail/mspools.el (mspools-size-folder): * lisp/mail/rmail.el (rmail-insert-inbox-text): * lisp/mail/sendmail.el (sendmail-sync-aliases): * lisp/mh-e/mh-alias.el (mh-alias-tstamp): * lisp/net/ange-ftp.el (ange-ftp-parse-netrc) (ange-ftp-write-region, ange-ftp-file-newer-than-file-p) (ange-ftp-cf1): * lisp/net/eudcb-mab.el (eudc-mab-query-internal): * lisp/net/eww.el (eww-read-bookmarks): * lisp/net/netrc.el (netrc-parse): * lisp/net/newst-backend.el (newsticker--image-get): * lisp/nxml/rng-loc.el (rng-get-parsed-schema-locating-file): * lisp/obsolete/fast-lock.el (fast-lock-save-cache): * lisp/obsolete/vc-arch.el (vc-arch-state) (vc-arch-diff3-rej-p): * lisp/org/ob-eval.el (org-babel--shell-command-on-region): * lisp/org/org-attach.el (org-attach-commit): * lisp/org/org-macro.el (org-macro-initialize-templates): * lisp/org/org.el (org-babel-load-file) (org-file-newer-than-p): * lisp/org/ox-html.el (org-html-format-spec): * lisp/org/ox-publish.el (org-publish-find-date) (org-publish-cache-ctime-of-src): * lisp/pcmpl-gnu.el (pcomplete/tar): * lisp/pcmpl-rpm.el (pcmpl-rpm-packages): * lisp/play/cookie1.el (cookie-snarf): * lisp/progmodes/cmacexp.el (c-macro-expansion): * lisp/ps-bdf.el (bdf-file-mod-time): * lisp/server.el (server-ensure-safe-dir): * lisp/simple.el (shell-command-on-region): * lisp/speedbar.el (speedbar-item-info-file-helper) (speedbar-check-obj-this-line): * lisp/thumbs.el (thumbs-cleanup-thumbsdir): * lisp/time.el (display-time-mail-check-directory) (display-time-file-nonempty-p): * lisp/url/url-cache.el (url-is-cached): * lisp/url/url-file.el (url-file-asynch-callback): * lisp/vc/diff-mode.el (diff-delete-if-empty): * lisp/vc/pcvs-info.el (cvs-fileinfo-from-entries): * lisp/vc/vc-bzr.el (vc-bzr-state-heuristic): * lisp/vc/vc-cvs.el (vc-cvs-checkout-model) (vc-cvs-state-heuristic, vc-cvs-merge-news) (vc-cvs-retrieve-tag, vc-cvs-parse-status, vc-cvs-parse-entry): * lisp/vc/vc-hg.el (vc-hg--slurp-hgignore-1) (vc-hg--ignore-patterns-valid-p) (vc-hg--cached-dirstate-search, vc-hg-state-fast): * lisp/vc/vc-hooks.el (vc-after-save): * lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer): * lisp/vc/vc-svn.el (vc-svn-merge-news, vc-svn-parse-status): * lisp/vc/vc.el (vc-checkout, vc-checkin, vc-revert-file): * lisp/xdg.el (xdg-mime-apps): Prefer (file-attribute-size A) to (nth 7 A), and similarly for other file attributes accessors. * doc/lispref/files.texi (File Attributes): * doc/lispref/intro.texi (Version Info): * doc/lispref/os.texi (Idle Timers): * lisp/erc/erc.el (erc-string-to-emacs-time): * lisp/files.el (file-attribute-access-time) (file-attribute-modification-time) (file-attribute-status-change-time): * lisp/net/tramp-compat.el: (tramp-compat-file-attribute-modification-time) (tramp-compat-file-attribute-size): * src/buffer.c (syms_of_buffer): * src/editfns.c (Fget_internal_run_time): * src/fileio.c (Fvisited_file_modtime) (Fset_visited_file_modtime): * src/keyboard.c (Fcurrent_idle_time): * src/process.c (Fprocess_attributes): Defer implementation details about timestamp format to the section that talks about timestamp format, to make it easier to change the documentation later if timestamp formats are extended. * lisp/gnus/gnus-util.el (gnus-file-newer-than): * lisp/speedbar.el (speedbar-check-obj-this-line): * lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer): Prefer time-less-p to doing it by hand. * lisp/ls-lisp.el (ls-lisp-format): Inode numbers are no longer conses. * lisp/vc/vc-bzr.el (vc-bzr-state-heuristic): Use eql, not eq, to compare integers that might be bignums. * lisp/org/ox-publish.el (org-publish-cache-ctime-of-src): Prefer float-time to doing time arithmetic by hand.
2018-09-23 18:30:46 -07:00
(push (list hgignore (file-attribute-modification-time attr) (file-attribute-size attr))
Performance improvements for vc-hg Teach vc-hg how to read some Mercurial internal data structures, allowing us to avoid the need to run hg status -A, which is very slow for large repositories. Fall back to running hg if anything looks funny. vc-hg now puts the _working directory_ revision in the modeline instead of the file revision, which greatly improves performance and which allows us to again skip running hg in the case that we have an active bookmark. * lisp/vc/vc-hg.el (vc-hg-state): Try calling `vc-hg-statefast' (vc-hg-symbolic-revision-styles) (vc-hg-use-file-version-for-mode-line-version) (vc-hg-parse-hg-data-structures): New user preferences (vc-hg--active-bookmark-internal, vc-hg--run-log) (vc-hg--symbolic-revision, vc-hg-mode-line-string) (vc-hg--read-u8, vc-hg--read-u32-be) (vc-hg--raw-dirstate-search, vc-hg--cached-dirstate-search) (vc-hg--parts-to-string, vc-hg--pcre-to-elisp-re) (vc-hg--glob-to-pcre, vc-hg--hgignore-add-pcre) (vc-hg--hgignore-add-glob, vc-hg--hgignore-add-path) (vc-hg--slurp-hgignore-1, vc-hg--slurp-hgignore) (vc-hg--ignore-patterns-valid-p) (vc-hg--ignore-patterns-ignored-p, vc-hg--time-to-fixnum) (vc-hg--file-ignored-p, vc-hg--read-repo-requirements) (vc-hg--requirements-understood-p, vc-hg--dirstate-scan-cache) (vc-hg-state-fast): New functions. (vc-hg--hgignore-patterns, vc-hg--hgignore-filenames) (vc-hg--cached-ignore-patterns, vc-hg--dirstate-scan-cache) (vc-hg--dirstate-scan-cache): New internal variables. * lisp/vc/vc-hooks.el (vc-refresh-state): Invoke vc find-file-hook before updating modeline.
2016-02-08 10:52:54 -08:00
vc-hg--hgignore-filenames))
(while (not (eobp))
;; This list of pattern-file commands isn't complete, but it
;; should cover the common cases. Remember that we fall back
;; to regular hg commands if we see something we don't like.
(save-restriction
(narrow-to-region (point) (line-end-position))
Performance improvements for vc-hg Teach vc-hg how to read some Mercurial internal data structures, allowing us to avoid the need to run hg status -A, which is very slow for large repositories. Fall back to running hg if anything looks funny. vc-hg now puts the _working directory_ revision in the modeline instead of the file revision, which greatly improves performance and which allows us to again skip running hg in the case that we have an active bookmark. * lisp/vc/vc-hg.el (vc-hg-state): Try calling `vc-hg-statefast' (vc-hg-symbolic-revision-styles) (vc-hg-use-file-version-for-mode-line-version) (vc-hg-parse-hg-data-structures): New user preferences (vc-hg--active-bookmark-internal, vc-hg--run-log) (vc-hg--symbolic-revision, vc-hg-mode-line-string) (vc-hg--read-u8, vc-hg--read-u32-be) (vc-hg--raw-dirstate-search, vc-hg--cached-dirstate-search) (vc-hg--parts-to-string, vc-hg--pcre-to-elisp-re) (vc-hg--glob-to-pcre, vc-hg--hgignore-add-pcre) (vc-hg--hgignore-add-glob, vc-hg--hgignore-add-path) (vc-hg--slurp-hgignore-1, vc-hg--slurp-hgignore) (vc-hg--ignore-patterns-valid-p) (vc-hg--ignore-patterns-ignored-p, vc-hg--time-to-fixnum) (vc-hg--file-ignored-p, vc-hg--read-repo-requirements) (vc-hg--requirements-understood-p, vc-hg--dirstate-scan-cache) (vc-hg-state-fast): New functions. (vc-hg--hgignore-patterns, vc-hg--hgignore-filenames) (vc-hg--cached-ignore-patterns, vc-hg--dirstate-scan-cache) (vc-hg--dirstate-scan-cache): New internal variables. * lisp/vc/vc-hooks.el (vc-refresh-state): Invoke vc find-file-hook before updating modeline.
2016-02-08 10:52:54 -08:00
(cond ((looking-at "[ \t]*\\(?:#.*\\)?$"))
((looking-at "syntax:[ \t]*re[ \t]*$")
(setf default-syntax 'vc-hg--hgignore-add-pcre))
((looking-at "syntax:[ \t]*glob[ \t]*$")
(setf default-syntax 'vc-hg--hgignore-add-glob))
((looking-at "path:\\(.+?\\)[ \t]*$")
(vc-hg--hgignore-add-path (match-string 1) prefix))
((looking-at "glob:\\(.+?\\)[ \t]*$")
(vc-hg--hgignore-add-glob (match-string 1) prefix))
((looking-at "re:\\(.+?\\)[ \t]*$")
(vc-hg--hgignore-add-pcre (match-string 1) prefix))
((looking-at "\\(sub\\)?include:\\(.+?\\)[ \t]*$")
(let* ((sub (equal (match-string 1) "sub"))
(arg (match-string 2))
(included-file
(if (string-match "^/" arg) arg
(concat (file-name-directory hgignore) arg))))
(vc-hg--slurp-hgignore-1
included-file
(if sub (file-name-directory included-file) prefix))))
((looking-at "[a-zA-Z0-9_]*:")
(signal 'vc-hg-unsupported-syntax (list (match-string 0))))
((looking-at ".*$")
(funcall default-syntax (match-string 0) prefix))))
(forward-line 1)))))
(cl-defstruct (vc-hg--ignore-patterns
(:copier nil)
(:constructor vc-hg--ignore-patterns-make))
repo
ignore-patterns
file-sources)
(defun vc-hg--slurp-hgignore (repo)
"Read hg ignore patterns from REPO.
REPO must be the directory name of an hg repository."
(cl-assert (and (file-name-absolute-p repo)
(directory-name-p repo)))
Performance improvements for vc-hg Teach vc-hg how to read some Mercurial internal data structures, allowing us to avoid the need to run hg status -A, which is very slow for large repositories. Fall back to running hg if anything looks funny. vc-hg now puts the _working directory_ revision in the modeline instead of the file revision, which greatly improves performance and which allows us to again skip running hg in the case that we have an active bookmark. * lisp/vc/vc-hg.el (vc-hg-state): Try calling `vc-hg-statefast' (vc-hg-symbolic-revision-styles) (vc-hg-use-file-version-for-mode-line-version) (vc-hg-parse-hg-data-structures): New user preferences (vc-hg--active-bookmark-internal, vc-hg--run-log) (vc-hg--symbolic-revision, vc-hg-mode-line-string) (vc-hg--read-u8, vc-hg--read-u32-be) (vc-hg--raw-dirstate-search, vc-hg--cached-dirstate-search) (vc-hg--parts-to-string, vc-hg--pcre-to-elisp-re) (vc-hg--glob-to-pcre, vc-hg--hgignore-add-pcre) (vc-hg--hgignore-add-glob, vc-hg--hgignore-add-path) (vc-hg--slurp-hgignore-1, vc-hg--slurp-hgignore) (vc-hg--ignore-patterns-valid-p) (vc-hg--ignore-patterns-ignored-p, vc-hg--time-to-fixnum) (vc-hg--file-ignored-p, vc-hg--read-repo-requirements) (vc-hg--requirements-understood-p, vc-hg--dirstate-scan-cache) (vc-hg-state-fast): New functions. (vc-hg--hgignore-patterns, vc-hg--hgignore-filenames) (vc-hg--cached-ignore-patterns, vc-hg--dirstate-scan-cache) (vc-hg--dirstate-scan-cache): New internal variables. * lisp/vc/vc-hooks.el (vc-refresh-state): Invoke vc find-file-hook before updating modeline.
2016-02-08 10:52:54 -08:00
(let* ((hgignore (concat repo ".hgignore"))
(vc-hg--hgignore-patterns nil)
(vc-hg--hgignore-filenames nil))
(vc-hg--slurp-hgignore-1 hgignore repo)
(vc-hg--ignore-patterns-make
:repo repo
:ignore-patterns (nreverse vc-hg--hgignore-patterns)
:file-sources (nreverse vc-hg--hgignore-filenames))))
(defun vc-hg--ignore-patterns-valid-p (hgip)
lisp/*.el: Fix typos and other trivial doc fixes * lisp/allout-widgets.el (allout-widgets-auto-activation) (allout-current-decorated-p): * lisp/auth-source.el (auth-source-protocols): * lisp/autorevert.el (auto-revert-set-timer): * lisp/battery.el (battery-mode-line-limit): * lisp/calc/calcalg3.el (math-map-binop): * lisp/calendar/cal-dst.el (calendar-dst-find-startend): * lisp/calendar/cal-mayan.el (calendar-mayan-long-count-to-absolute): * lisp/calendar/calendar.el (calendar-date-echo-text) (calendar-generate-month, calendar-string-spread) (calendar-cursor-to-date, calendar-read, calendar-read-date) (calendar-mark-visible-date, calendar-dayname-on-or-before): * lisp/calendar/diary-lib.el (diary-ordinal-suffix): * lisp/cedet/ede/autoconf-edit.el (autoconf-new-program) (autoconf-find-last-macro, autoconf-parameter-strip): * lisp/cedet/ede/config.el (ede-target-with-config-build): * lisp/cedet/ede/linux.el (ede-linux--detect-architecture) (ede-linux--get-architecture): * lisp/cedet/semantic/complete.el (semantic-collector-calculate-cache) (semantic-displayer-abstract, semantic-displayer-point-position): * lisp/cedet/semantic/format.el (semantic-format-face-alist) (semantic-format-tag-short-doc): * lisp/cedet/semantic/fw.el (semantic-find-file-noselect): * lisp/cedet/semantic/idle.el (semantic-idle-scheduler-work-idle-time) (semantic-idle-breadcrumbs-display-function) (semantic-idle-breadcrumbs-format-tag-list-function): * lisp/cedet/semantic/lex.el (semantic-lex-map-types) (define-lex, define-lex-block-type-analyzer): * lisp/cedet/semantic/senator.el (senator-search-default-tag-filter): * lisp/cedet/semantic/symref.el (semantic-symref-result) (semantic-symref-hit-to-tag-via-db): * lisp/cedet/semantic/symref.el (semantic-symref-tool-baseclass): * lisp/cedet/semantic/tag.el (semantic-tag-new-variable) (semantic-tag-new-include, semantic-tag-new-package) (semantic-tag-set-faux, semantic-create-tag-proxy) (semantic-tag-function-parent) (semantic-tag-components-with-overlays): * lisp/cedet/srecode/cpp.el (srecode-cpp-namespaces) (srecode-semantic-handle-:c, srecode-semantic-apply-tag-to-dict): * lisp/cedet/srecode/dictionary.el (srecode-create-dictionary) (srecode-dictionary-add-entries, srecode-dictionary-lookup-name) (srecode-create-dictionaries-from-tags): * lisp/cmuscheme.el (scheme-compile-region): * lisp/color.el (color-lab-to-lch): * lisp/doc-view.el (doc-view-image-width) (doc-view-set-up-single-converter): * lisp/dynamic-setting.el (font-setting-change-default-font) (dynamic-setting-handle-config-changed-event): * lisp/elec-pair.el (electric-pair-text-pairs) (electric-pair-skip-whitespace-function) (electric-pair-string-bound-function): * lisp/emacs-lisp/avl-tree.el (avl-tree--del-balance) (avl-tree-member, avl-tree-mapcar, avl-tree-iter): * lisp/emacs-lisp/bytecomp.el (byte-compile-generate-call-tree): * lisp/emacs-lisp/checkdoc.el (checkdoc-autofix-flag) (checkdoc-spellcheck-documentation-flag, checkdoc-ispell) (checkdoc-ispell-current-buffer, checkdoc-ispell-interactive) (checkdoc-ispell-message-interactive) (checkdoc-ispell-message-text, checkdoc-ispell-start) (checkdoc-ispell-continue, checkdoc-ispell-comments) (checkdoc-ispell-defun): * lisp/emacs-lisp/cl-generic.el (cl--generic-search-method): * lisp/emacs-lisp/eieio-custom.el (eieio-read-customization-group): * lisp/emacs-lisp/lisp.el (forward-sexp, up-list): * lisp/emacs-lisp/package-x.el (package--archive-contents-from-file): * lisp/emacs-lisp/package.el (package-desc) (package--make-autoloads-and-stuff, package-hidden-regexps): * lisp/emacs-lisp/tcover-ses.el (ses-exercise-startup): * lisp/emacs-lisp/testcover.el (testcover-nohits) (testcover-1value): * lisp/epg.el (epg-receive-keys, epg-start-edit-key): * lisp/erc/erc-backend.el (erc-server-processing-p) (erc-split-line-length, erc-server-coding-system) (erc-server-send, erc-message): * lisp/erc/erc-button.el (erc-button-face, erc-button-alist) (erc-browse-emacswiki): * lisp/erc/erc-ezbounce.el (erc-ezbounce, erc-ezb-get-login): * lisp/erc/erc-fill.el (erc-fill-variable-maximum-indentation): * lisp/erc/erc-log.el (erc-current-logfile): * lisp/erc/erc-match.el (erc-log-match-format) (erc-text-matched-hook): * lisp/erc/erc-netsplit.el (erc-netsplit, erc-netsplit-debug): * lisp/erc/erc-networks.el (erc-server-alist) (erc-networks-alist, erc-current-network): * lisp/erc/erc-ring.el (erc-input-ring-index): * lisp/erc/erc-speedbar.el (erc-speedbar) (erc-speedbar-update-channel): * lisp/erc/erc-stamp.el (erc-timestamp-only-if-changed-flag): * lisp/erc/erc-track.el (erc-track-position-in-mode-line) (erc-track-remove-from-mode-line, erc-modified-channels-update) (erc-track-last-non-erc-buffer, erc-track-sort-by-importance) (erc-track-get-active-buffer): * lisp/erc/erc.el (erc-get-channel-user-list) (erc-echo-notice-hook, erc-echo-notice-always-hook) (erc-wash-quit-reason, erc-format-@nick): * lisp/ffap.el (ffap-latex-mode): * lisp/files.el (abort-if-file-too-large) (dir-locals--get-sort-score, buffer-stale--default-function): * lisp/filesets.el (filesets-tree-max-level, filesets-data) (filesets-update-pre010505): * lisp/gnus/gnus-agent.el (gnus-agent-flush-cache): * lisp/gnus/gnus-art.el (gnus-article-encrypt-protocol) (gnus-button-prefer-mid-or-mail): * lisp/gnus/gnus-cus.el (gnus-group-parameters): * lisp/gnus/gnus-demon.el (gnus-demon-handlers) (gnus-demon-run-callback): * lisp/gnus/gnus-dired.el (gnus-dired-print): * lisp/gnus/gnus-icalendar.el (gnus-icalendar-event-from-buffer): * lisp/gnus/gnus-range.el (gnus-range-normalize): * lisp/gnus/gnus-spec.el (gnus-pad-form): * lisp/gnus/gnus-srvr.el (gnus-server-agent, gnus-server-cloud) (gnus-server-opened, gnus-server-closed, gnus-server-denied) (gnus-server-offline): * lisp/gnus/gnus-sum.el (gnus-refer-thread-use-nnir) (gnus-refer-thread-limit-to-thread) (gnus-summary-limit-include-thread, gnus-summary-refer-thread) (gnus-summary-find-matching): * lisp/gnus/gnus-util.el (gnus-rescale-image): * lisp/gnus/gnus.el (gnus-summary-line-format, gnus-no-server): * lisp/gnus/mail-source.el (mail-source-incoming-file-prefix): * lisp/gnus/message.el (message-cite-reply-position) (message-cite-style-outlook, message-cite-style-thunderbird) (message-cite-style-gmail, message--send-mail-maybe-partially): * lisp/gnus/mm-extern.el (mm-inline-external-body): * lisp/gnus/mm-partial.el (mm-inline-partial): * lisp/gnus/mml-sec.el (mml-secure-message-sign) (mml-secure-message-sign-encrypt, mml-secure-message-encrypt): * lisp/gnus/mml2015.el (mml2015-epg-key-image) (mml2015-epg-key-image-to-string): * lisp/gnus/nndiary.el (nndiary-reminders, nndiary-get-new-mail): * lisp/gnus/nnheader.el (nnheader-directory-files-is-safe): * lisp/gnus/nnir.el (nnir-search-history) (nnir-imap-search-other, nnir-artlist-length) (nnir-artlist-article, nnir-artitem-group, nnir-artitem-number) (nnir-artitem-rsv, nnir-article-group, nnir-article-number) (nnir-article-rsv, nnir-article-ids, nnir-categorize) (nnir-retrieve-headers-override-function) (nnir-imap-default-search-key, nnir-hyrex-additional-switches) (gnus-group-make-nnir-group, nnir-run-namazu, nnir-read-parms) (nnir-read-parm, nnir-read-server-parm, nnir-search-thread): * lisp/gnus/nnmairix.el (nnmairix-default-group) (nnmairix-propagate-marks): * lisp/gnus/smime.el (smime-keys, smime-crl-check) (smime-verify-buffer, smime-noverify-buffer): * lisp/gnus/spam-report.el (spam-report-url-ping-mm-url): * lisp/gnus/spam.el (spam-spamassassin-positive-spam-flag-header) (spam-spamassassin-spam-status-header, spam-sa-learn-rebuild) (spam-classifications, spam-check-stat, spam-spamassassin-score): * lisp/help.el (describe-minor-mode-from-symbol): * lisp/hippie-exp.el (hippie-expand-ignore-buffers): * lisp/htmlfontify.el (hfy-optimizations, hfy-face-resolve-face) (hfy-begin-span): * lisp/ibuf-ext.el (ibuffer-update-saved-filters-format) (ibuffer-saved-filters, ibuffer-old-saved-filters-warning) (ibuffer-filtering-qualifiers, ibuffer-repair-saved-filters) (eval, ibuffer-unary-operand, file-extension, directory): * lisp/image-dired.el (image-dired-cmd-pngcrush-options): * lisp/image-mode.el (image-toggle-display): * lisp/international/ccl.el (ccl-compile-read-multibyte-character) (ccl-compile-write-multibyte-character): * lisp/international/kkc.el (kkc-save-init-file): * lisp/international/latin1-disp.el (latin1-display): * lisp/international/ogonek.el (ogonek-name-encoding-alist) (ogonek-information, ogonek-lookup-encoding) (ogonek-deprefixify-region): * lisp/isearch.el (isearch-filter-predicate) (isearch--momentary-message): * lisp/jsonrpc.el (jsonrpc-connection-send) (jsonrpc-process-connection, jsonrpc-shutdown) (jsonrpc--async-request-1): * lisp/language/tibet-util.el (tibetan-char-p): * lisp/mail/feedmail.el (feedmail-queue-use-send-time-for-date) (feedmail-last-chance-hook, feedmail-before-fcc-hook) (feedmail-send-it-immediately-wrapper, feedmail-find-eoh): * lisp/mail/hashcash.el (hashcash-generate-payment) (hashcash-generate-payment-async, hashcash-insert-payment) (hashcash-verify-payment): * lisp/mail/rmail.el (rmail-movemail-variant-in-use) (rmail-get-attr-value): * lisp/mail/rmailmm.el (rmail-mime-prefer-html, rmail-mime): * lisp/mail/rmailsum.el (rmail-summary-show-message): * lisp/mail/supercite.el (sc-raw-mode-toggle): * lisp/man.el (Man-start-calling): * lisp/mh-e/mh-acros.el (mh-do-at-event-location) (mh-iterate-on-messages-in-region, mh-iterate-on-range): * lisp/mh-e/mh-alias.el (mh-alias-system-aliases) (mh-alias-reload, mh-alias-ali) (mh-alias-canonicalize-suggestion, mh-alias-add-alias-to-file) (mh-alias-add-alias): * lisp/mouse.el (mouse-save-then-kill): * lisp/net/browse-url.el (browse-url-default-macosx-browser): * lisp/net/eudc.el (eudc-set, eudc-variable-protocol-value) (eudc-variable-server-value, eudc-update-variable) (eudc-expand-inline): * lisp/net/eudcb-bbdb.el (eudc-bbdb-format-record-as-result): * lisp/net/eudcb-ldap.el (eudc-ldap-get-field-list): * lisp/net/pop3.el (pop3-list): * lisp/net/soap-client.el (soap-namespace-put) (soap-xs-parse-sequence, soap-parse-envelope): * lisp/net/soap-inspect.el (soap-inspect-xs-complex-type): * lisp/nxml/rng-xsd.el (rng-xsd-date-to-days): * lisp/org/ob-C.el (org-babel-prep-session:C) (org-babel-load-session:C): * lisp/org/ob-J.el (org-babel-execute:J): * lisp/org/ob-asymptote.el (org-babel-prep-session:asymptote): * lisp/org/ob-awk.el (org-babel-execute:awk): * lisp/org/ob-core.el (org-babel-process-file-name): * lisp/org/ob-ebnf.el (org-babel-execute:ebnf): * lisp/org/ob-forth.el (org-babel-execute:forth): * lisp/org/ob-fortran.el (org-babel-execute:fortran) (org-babel-prep-session:fortran, org-babel-load-session:fortran): * lisp/org/ob-groovy.el (org-babel-execute:groovy): * lisp/org/ob-io.el (org-babel-execute:io): * lisp/org/ob-js.el (org-babel-execute:js): * lisp/org/ob-lilypond.el (org-babel-default-header-args:lilypond) (org-babel-lilypond-compile-post-tangle) (org-babel-lilypond-display-pdf-post-tangle) (org-babel-lilypond-tangle) (org-babel-lilypond-execute-tangled-ly) (org-babel-lilypond-compile-lilyfile) (org-babel-lilypond-check-for-compile-error) (org-babel-lilypond-process-compile-error) (org-babel-lilypond-mark-error-line) (org-babel-lilypond-parse-error-line) (org-babel-lilypond-attempt-to-open-pdf) (org-babel-lilypond-attempt-to-play-midi) (org-babel-lilypond-switch-extension) (org-babel-lilypond-set-header-args): * lisp/org/ob-lua.el (org-babel-prep-session:lua): * lisp/org/ob-picolisp.el (org-babel-execute:picolisp): * lisp/org/ob-processing.el (org-babel-prep-session:processing): * lisp/org/ob-python.el (org-babel-prep-session:python): * lisp/org/ob-scheme.el (org-babel-scheme-capture-current-message) (org-babel-scheme-execute-with-geiser, org-babel-execute:scheme): * lisp/org/ob-shen.el (org-babel-execute:shen): * lisp/org/org-agenda.el (org-agenda-entry-types) (org-agenda-move-date-from-past-immediately-to-today) (org-agenda-time-grid, org-agenda-sorting-strategy) (org-agenda-filter-by-category, org-agenda-forward-block): * lisp/org/org-colview.el (org-columns--overlay-text): * lisp/org/org-faces.el (org-verbatim, org-cycle-level-faces): * lisp/org/org-indent.el (org-indent-set-line-properties): * lisp/org/org-macs.el (org-get-limited-outline-regexp): * lisp/org/org-mobile.el (org-mobile-files): * lisp/org/org.el (org-use-fast-todo-selection) (org-extend-today-until, org-use-property-inheritance) (org-refresh-effort-properties, org-open-at-point-global) (org-track-ordered-property-with-tag, org-shiftright): * lisp/org/ox-html.el (org-html-checkbox-type): * lisp/org/ox-man.el (org-man-source-highlight) (org-man-verse-block): * lisp/org/ox-publish.el (org-publish-sitemap-default): * lisp/outline.el (outline-head-from-level): * lisp/progmodes/dcl-mode.el (dcl-back-to-indentation-1) (dcl-calc-command-indent, dcl-indent-to): * lisp/progmodes/flymake.el (flymake-make-diagnostic) (flymake--overlays, flymake-diagnostic-functions) (flymake-diagnostic-types-alist, flymake--backend-state) (flymake-is-running, flymake--collect, flymake-mode): * lisp/progmodes/gdb-mi.el (gdb-threads-list, gdb, gdb-non-stop) (gdb-buffers, gdb-gud-context-call, gdb-jsonify-buffer): * lisp/progmodes/grep.el (grep-error-screen-columns): * lisp/progmodes/gud.el (gud-prev-expr): * lisp/progmodes/ps-mode.el (ps-mode, ps-mode-target-column) (ps-run-goto-error): * lisp/progmodes/python.el (python-eldoc-get-doc) (python-eldoc-function-timeout-permanent, python-eldoc-function): * lisp/shadowfile.el (shadow-make-group): * lisp/speedbar.el (speedbar-obj-do-check): * lisp/textmodes/flyspell.el (flyspell-auto-correct-previous-hook): * lisp/textmodes/reftex-cite.el (reftex-bib-or-thebib): * lisp/textmodes/reftex-index.el (reftex-index-goto-entry) (reftex-index-kill, reftex-index-undo): * lisp/textmodes/reftex-parse.el (reftex-context-substring): * lisp/textmodes/reftex.el (reftex-TeX-master-file): * lisp/textmodes/rst.el (rst-next-hdr, rst-toc) (rst-uncomment-region, rst-font-lock-extend-region-internal): * lisp/thumbs.el (thumbs-mode): * lisp/vc/ediff-util.el (ediff-restore-diff): * lisp/vc/pcvs-defs.el (cvs-cvsroot, cvs-force-dir-tag): * lisp/vc/vc-hg.el (vc-hg--ignore-patterns-valid-p): * lisp/wid-edit.el (widget-field-value-set, string): * lisp/x-dnd.el (x-dnd-version-from-flags) (x-dnd-more-than-3-from-flags): Assorted docfixes.
2019-09-21 00:27:53 +02:00
"Return whether the cached ignore patterns in HGIP are still valid."
Performance improvements for vc-hg Teach vc-hg how to read some Mercurial internal data structures, allowing us to avoid the need to run hg status -A, which is very slow for large repositories. Fall back to running hg if anything looks funny. vc-hg now puts the _working directory_ revision in the modeline instead of the file revision, which greatly improves performance and which allows us to again skip running hg in the case that we have an active bookmark. * lisp/vc/vc-hg.el (vc-hg-state): Try calling `vc-hg-statefast' (vc-hg-symbolic-revision-styles) (vc-hg-use-file-version-for-mode-line-version) (vc-hg-parse-hg-data-structures): New user preferences (vc-hg--active-bookmark-internal, vc-hg--run-log) (vc-hg--symbolic-revision, vc-hg-mode-line-string) (vc-hg--read-u8, vc-hg--read-u32-be) (vc-hg--raw-dirstate-search, vc-hg--cached-dirstate-search) (vc-hg--parts-to-string, vc-hg--pcre-to-elisp-re) (vc-hg--glob-to-pcre, vc-hg--hgignore-add-pcre) (vc-hg--hgignore-add-glob, vc-hg--hgignore-add-path) (vc-hg--slurp-hgignore-1, vc-hg--slurp-hgignore) (vc-hg--ignore-patterns-valid-p) (vc-hg--ignore-patterns-ignored-p, vc-hg--time-to-fixnum) (vc-hg--file-ignored-p, vc-hg--read-repo-requirements) (vc-hg--requirements-understood-p, vc-hg--dirstate-scan-cache) (vc-hg-state-fast): New functions. (vc-hg--hgignore-patterns, vc-hg--hgignore-filenames) (vc-hg--cached-ignore-patterns, vc-hg--dirstate-scan-cache) (vc-hg--dirstate-scan-cache): New internal variables. * lisp/vc/vc-hooks.el (vc-refresh-state): Invoke vc find-file-hook before updating modeline.
2016-02-08 10:52:54 -08:00
(let ((valid t)
(file-sources (vc-hg--ignore-patterns-file-sources hgip)))
(while (and file-sources valid)
(let* ((fs (pop file-sources))
(saved-mtime (nth 1 fs))
(saved-size (nth 2 fs))
(attr (file-attributes (nth 0 fs)))
file-attributes cleanup Mostly, this replaces magic-number calls like (nth 4 A) with more-informative calls like (file-attribute-access-time A). It also fixes some documentation and minor timestamp coding issues that I noticed while looking into this. * doc/lispref/files.texi (File Attributes): * lisp/files.el (file-attribute-size) (file-attribute-inode-number, file-attribute-device-number): * src/dired.c (Fdirectory_files_and_attributes) (Ffile_attributes): Mention which attributes must be integers, or nonnegative integers, as opposed to merely being numbers. Remove no-longer-correct talk about representing large integers as conses of integers. * doc/lispref/files.texi (Magic File Names): * doc/misc/gnus.texi (Low-level interface to the spam-stat dictionary): * lisp/autorevert.el (auto-revert-find-file-function) (auto-revert-tail-mode, auto-revert-handler): * lisp/auth-source.el (auth-source-netrc-parse): * lisp/cedet/ede/files.el (ede--inode-for-dir): * lisp/cedet/semantic/db-file.el (object-write): * lisp/cedet/semantic/db-mode.el (semanticdb-kill-hook): * lisp/cedet/semantic/db.el (semanticdb-needs-refresh-p) (semanticdb-synchronize): * lisp/cedet/srecode/table.el (srecode-mode-table-new): * lisp/desktop.el (desktop-save, desktop-read): * lisp/dired-aux.el (dired-file-set-difference) (dired-do-chxxx, dired-do-chmod, dired-copy-file-recursive) (dired-create-files): * lisp/dired.el (dired-directory-changed-p, dired-readin): * lisp/dos-w32.el (w32-direct-print-region-helper): * lisp/emacs-lisp/autoload.el (autoload-generate-file-autoloads) (autoload-find-destination, update-directory-autoloads): * lisp/emacs-lisp/shadow.el (load-path-shadows-same-file-or-nonexistent): * lisp/epg.el (epg--start, epg-wait-for-completion): * lisp/eshell/em-ls.el (eshell-ls-filetype-p) (eshell-ls-applicable, eshell-ls-size-string) (eshell-ls-file, eshell-ls-dir, eshell-ls-files) (eshell-ls-entries): * lisp/eshell/em-pred.el (eshell-predicate-alist) (eshell-pred-file-type, eshell-pred-file-links) (eshell-pred-file-size): * lisp/eshell/em-unix.el (eshell-shuffle-files, eshell/cat) (eshell-du-sum-directory, eshell/du): * lisp/eshell/esh-util.el (eshell-read-passwd) (eshell-read-hosts): * lisp/files.el (remote-file-name-inhibit-cache) (find-file-noselect, insert-file-1, dir-locals-find-file) (dir-locals-read-from-dir, backup-buffer) (file-ownership-preserved-p, copy-directory) (read-file-modes): * lisp/find-lisp.el (find-lisp-format): * lisp/gnus/gnus-agent.el (gnus-agent-unfetch-articles) (gnus-agent-read-agentview, gnus-agent-expire-group-1) (gnus-agent-request-article, gnus-agent-regenerate-group) (gnus-agent-update-files-total-fetched-for) (gnus-agent-update-view-total-fetched-for): * lisp/gnus/gnus-cache.el (gnus-cache-read-active) (gnus-cache-update-file-total-fetched-for) (gnus-cache-update-overview-total-fetched-for): * lisp/gnus/gnus-cloud.el (gnus-cloud-file-new-p): * lisp/gnus/gnus-score.el (gnus-score-score-files): * lisp/gnus/gnus-start.el (gnus-save-newsrc-file) (gnus-master-read-slave-newsrc): * lisp/gnus/gnus-sum.el (gnus-summary-import-article): * lisp/gnus/gnus-util.el (gnus-file-newer-than) (gnus-cache-file-contents): * lisp/gnus/mail-source.el (mail-source-delete-old-incoming) (mail-source-callback, mail-source-movemail): * lisp/gnus/nneething.el (nneething-create-mapping) (nneething-make-head): * lisp/gnus/nnfolder.el (nnfolder-read-folder): * lisp/gnus/nnheader.el (nnheader-file-size) (nnheader-insert-nov-file): * lisp/gnus/nnmail.el (nnmail-activate): * lisp/gnus/nnmaildir.el (nnmaildir--group-maxnum) (nnmaildir--new-number, nnmaildir--update-nov) (nnmaildir--scan, nnmaildir-request-scan) (nnmaildir-request-update-info) (nnmaildir-request-expire-articles): * lisp/gnus/nnmh.el (nnmh-request-list-1) (nnmh-request-expire-articles, nnmh-update-gnus-unreads): * lisp/gnus/nnml.el (nnml-request-expire-articles): * lisp/gnus/spam-stat.el (spam-stat-save, spam-stat-load) (spam-stat-process-directory, spam-stat-test-directory): * lisp/ido.el (ido-directory-too-big-p) (ido-file-name-all-completions): * lisp/image-dired.el (image-dired-get-thumbnail-image) (image-dired-create-thumb-1): * lisp/info.el (info-insert-file-contents): * lisp/ls-lisp.el (ls-lisp-insert-directory) (ls-lisp-handle-switches, ls-lisp-classify-file) (ls-lisp-format): * lisp/mail/blessmail.el: * lisp/mail/feedmail.el (feedmail-default-date-generator) (feedmail-default-message-id-generator): * lisp/mail/mailabbrev.el (mail-abbrevs-sync-aliases) (mail-abbrevs-setup): * lisp/mail/mspools.el (mspools-size-folder): * lisp/mail/rmail.el (rmail-insert-inbox-text): * lisp/mail/sendmail.el (sendmail-sync-aliases): * lisp/mh-e/mh-alias.el (mh-alias-tstamp): * lisp/net/ange-ftp.el (ange-ftp-parse-netrc) (ange-ftp-write-region, ange-ftp-file-newer-than-file-p) (ange-ftp-cf1): * lisp/net/eudcb-mab.el (eudc-mab-query-internal): * lisp/net/eww.el (eww-read-bookmarks): * lisp/net/netrc.el (netrc-parse): * lisp/net/newst-backend.el (newsticker--image-get): * lisp/nxml/rng-loc.el (rng-get-parsed-schema-locating-file): * lisp/obsolete/fast-lock.el (fast-lock-save-cache): * lisp/obsolete/vc-arch.el (vc-arch-state) (vc-arch-diff3-rej-p): * lisp/org/ob-eval.el (org-babel--shell-command-on-region): * lisp/org/org-attach.el (org-attach-commit): * lisp/org/org-macro.el (org-macro-initialize-templates): * lisp/org/org.el (org-babel-load-file) (org-file-newer-than-p): * lisp/org/ox-html.el (org-html-format-spec): * lisp/org/ox-publish.el (org-publish-find-date) (org-publish-cache-ctime-of-src): * lisp/pcmpl-gnu.el (pcomplete/tar): * lisp/pcmpl-rpm.el (pcmpl-rpm-packages): * lisp/play/cookie1.el (cookie-snarf): * lisp/progmodes/cmacexp.el (c-macro-expansion): * lisp/ps-bdf.el (bdf-file-mod-time): * lisp/server.el (server-ensure-safe-dir): * lisp/simple.el (shell-command-on-region): * lisp/speedbar.el (speedbar-item-info-file-helper) (speedbar-check-obj-this-line): * lisp/thumbs.el (thumbs-cleanup-thumbsdir): * lisp/time.el (display-time-mail-check-directory) (display-time-file-nonempty-p): * lisp/url/url-cache.el (url-is-cached): * lisp/url/url-file.el (url-file-asynch-callback): * lisp/vc/diff-mode.el (diff-delete-if-empty): * lisp/vc/pcvs-info.el (cvs-fileinfo-from-entries): * lisp/vc/vc-bzr.el (vc-bzr-state-heuristic): * lisp/vc/vc-cvs.el (vc-cvs-checkout-model) (vc-cvs-state-heuristic, vc-cvs-merge-news) (vc-cvs-retrieve-tag, vc-cvs-parse-status, vc-cvs-parse-entry): * lisp/vc/vc-hg.el (vc-hg--slurp-hgignore-1) (vc-hg--ignore-patterns-valid-p) (vc-hg--cached-dirstate-search, vc-hg-state-fast): * lisp/vc/vc-hooks.el (vc-after-save): * lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer): * lisp/vc/vc-svn.el (vc-svn-merge-news, vc-svn-parse-status): * lisp/vc/vc.el (vc-checkout, vc-checkin, vc-revert-file): * lisp/xdg.el (xdg-mime-apps): Prefer (file-attribute-size A) to (nth 7 A), and similarly for other file attributes accessors. * doc/lispref/files.texi (File Attributes): * doc/lispref/intro.texi (Version Info): * doc/lispref/os.texi (Idle Timers): * lisp/erc/erc.el (erc-string-to-emacs-time): * lisp/files.el (file-attribute-access-time) (file-attribute-modification-time) (file-attribute-status-change-time): * lisp/net/tramp-compat.el: (tramp-compat-file-attribute-modification-time) (tramp-compat-file-attribute-size): * src/buffer.c (syms_of_buffer): * src/editfns.c (Fget_internal_run_time): * src/fileio.c (Fvisited_file_modtime) (Fset_visited_file_modtime): * src/keyboard.c (Fcurrent_idle_time): * src/process.c (Fprocess_attributes): Defer implementation details about timestamp format to the section that talks about timestamp format, to make it easier to change the documentation later if timestamp formats are extended. * lisp/gnus/gnus-util.el (gnus-file-newer-than): * lisp/speedbar.el (speedbar-check-obj-this-line): * lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer): Prefer time-less-p to doing it by hand. * lisp/ls-lisp.el (ls-lisp-format): Inode numbers are no longer conses. * lisp/vc/vc-bzr.el (vc-bzr-state-heuristic): Use eql, not eq, to compare integers that might be bignums. * lisp/org/ox-publish.el (org-publish-cache-ctime-of-src): Prefer float-time to doing time arithmetic by hand.
2018-09-23 18:30:46 -07:00
(current-mtime (file-attribute-modification-time attr))
(current-size (file-attribute-size attr)))
(unless (and (time-equal-p saved-mtime current-mtime)
Performance improvements for vc-hg Teach vc-hg how to read some Mercurial internal data structures, allowing us to avoid the need to run hg status -A, which is very slow for large repositories. Fall back to running hg if anything looks funny. vc-hg now puts the _working directory_ revision in the modeline instead of the file revision, which greatly improves performance and which allows us to again skip running hg in the case that we have an active bookmark. * lisp/vc/vc-hg.el (vc-hg-state): Try calling `vc-hg-statefast' (vc-hg-symbolic-revision-styles) (vc-hg-use-file-version-for-mode-line-version) (vc-hg-parse-hg-data-structures): New user preferences (vc-hg--active-bookmark-internal, vc-hg--run-log) (vc-hg--symbolic-revision, vc-hg-mode-line-string) (vc-hg--read-u8, vc-hg--read-u32-be) (vc-hg--raw-dirstate-search, vc-hg--cached-dirstate-search) (vc-hg--parts-to-string, vc-hg--pcre-to-elisp-re) (vc-hg--glob-to-pcre, vc-hg--hgignore-add-pcre) (vc-hg--hgignore-add-glob, vc-hg--hgignore-add-path) (vc-hg--slurp-hgignore-1, vc-hg--slurp-hgignore) (vc-hg--ignore-patterns-valid-p) (vc-hg--ignore-patterns-ignored-p, vc-hg--time-to-fixnum) (vc-hg--file-ignored-p, vc-hg--read-repo-requirements) (vc-hg--requirements-understood-p, vc-hg--dirstate-scan-cache) (vc-hg-state-fast): New functions. (vc-hg--hgignore-patterns, vc-hg--hgignore-filenames) (vc-hg--cached-ignore-patterns, vc-hg--dirstate-scan-cache) (vc-hg--dirstate-scan-cache): New internal variables. * lisp/vc/vc-hooks.el (vc-refresh-state): Invoke vc find-file-hook before updating modeline.
2016-02-08 10:52:54 -08:00
(equal saved-size current-size))
(setf valid nil))))
valid))
(defun vc-hg--ignore-patterns-ignored-p (hgip filename)
"Test whether the ignore pattern set HGIP says to ignore FILENAME.
FILENAME must be the file's true absolute name."
(let ((patterns (vc-hg--ignore-patterns-ignore-patterns hgip))
(ignored nil))
(while (and patterns (not ignored))
(setf ignored (string-match-p (pop patterns) filename)))
Performance improvements for vc-hg Teach vc-hg how to read some Mercurial internal data structures, allowing us to avoid the need to run hg status -A, which is very slow for large repositories. Fall back to running hg if anything looks funny. vc-hg now puts the _working directory_ revision in the modeline instead of the file revision, which greatly improves performance and which allows us to again skip running hg in the case that we have an active bookmark. * lisp/vc/vc-hg.el (vc-hg-state): Try calling `vc-hg-statefast' (vc-hg-symbolic-revision-styles) (vc-hg-use-file-version-for-mode-line-version) (vc-hg-parse-hg-data-structures): New user preferences (vc-hg--active-bookmark-internal, vc-hg--run-log) (vc-hg--symbolic-revision, vc-hg-mode-line-string) (vc-hg--read-u8, vc-hg--read-u32-be) (vc-hg--raw-dirstate-search, vc-hg--cached-dirstate-search) (vc-hg--parts-to-string, vc-hg--pcre-to-elisp-re) (vc-hg--glob-to-pcre, vc-hg--hgignore-add-pcre) (vc-hg--hgignore-add-glob, vc-hg--hgignore-add-path) (vc-hg--slurp-hgignore-1, vc-hg--slurp-hgignore) (vc-hg--ignore-patterns-valid-p) (vc-hg--ignore-patterns-ignored-p, vc-hg--time-to-fixnum) (vc-hg--file-ignored-p, vc-hg--read-repo-requirements) (vc-hg--requirements-understood-p, vc-hg--dirstate-scan-cache) (vc-hg-state-fast): New functions. (vc-hg--hgignore-patterns, vc-hg--hgignore-filenames) (vc-hg--cached-ignore-patterns, vc-hg--dirstate-scan-cache) (vc-hg--dirstate-scan-cache): New internal variables. * lisp/vc/vc-hooks.el (vc-refresh-state): Invoke vc find-file-hook before updating modeline.
2016-02-08 10:52:54 -08:00
ignored))
(defvar vc-hg--cached-ignore-patterns nil
"Cached pre-parsed hg ignore patterns.")
(defun vc-hg--file-ignored-p (repo repo-relative-filename)
(let ((hgip vc-hg--cached-ignore-patterns))
(unless (and hgip
(equal repo (vc-hg--ignore-patterns-repo hgip))
(vc-hg--ignore-patterns-valid-p hgip))
(setf vc-hg--cached-ignore-patterns nil)
(setf hgip (vc-hg--slurp-hgignore repo))
(setf vc-hg--cached-ignore-patterns hgip))
(vc-hg--ignore-patterns-ignored-p
hgip
(concat repo repo-relative-filename))))
(defun vc-hg--read-repo-requirements (repo)
(cl-assert (and (file-name-absolute-p repo)
(directory-name-p repo)))
Performance improvements for vc-hg Teach vc-hg how to read some Mercurial internal data structures, allowing us to avoid the need to run hg status -A, which is very slow for large repositories. Fall back to running hg if anything looks funny. vc-hg now puts the _working directory_ revision in the modeline instead of the file revision, which greatly improves performance and which allows us to again skip running hg in the case that we have an active bookmark. * lisp/vc/vc-hg.el (vc-hg-state): Try calling `vc-hg-statefast' (vc-hg-symbolic-revision-styles) (vc-hg-use-file-version-for-mode-line-version) (vc-hg-parse-hg-data-structures): New user preferences (vc-hg--active-bookmark-internal, vc-hg--run-log) (vc-hg--symbolic-revision, vc-hg-mode-line-string) (vc-hg--read-u8, vc-hg--read-u32-be) (vc-hg--raw-dirstate-search, vc-hg--cached-dirstate-search) (vc-hg--parts-to-string, vc-hg--pcre-to-elisp-re) (vc-hg--glob-to-pcre, vc-hg--hgignore-add-pcre) (vc-hg--hgignore-add-glob, vc-hg--hgignore-add-path) (vc-hg--slurp-hgignore-1, vc-hg--slurp-hgignore) (vc-hg--ignore-patterns-valid-p) (vc-hg--ignore-patterns-ignored-p, vc-hg--time-to-fixnum) (vc-hg--file-ignored-p, vc-hg--read-repo-requirements) (vc-hg--requirements-understood-p, vc-hg--dirstate-scan-cache) (vc-hg-state-fast): New functions. (vc-hg--hgignore-patterns, vc-hg--hgignore-filenames) (vc-hg--cached-ignore-patterns, vc-hg--dirstate-scan-cache) (vc-hg--dirstate-scan-cache): New internal variables. * lisp/vc/vc-hooks.el (vc-refresh-state): Invoke vc find-file-hook before updating modeline.
2016-02-08 10:52:54 -08:00
(let* ((requires-filename (concat repo ".hg/requires")))
(and (file-exists-p requires-filename)
(with-temp-buffer
(set-buffer-multibyte nil)
(insert-file-contents-literally requires-filename)
(split-string (buffer-substring-no-properties
(point-min) (point-max)))))))
(defconst vc-hg-supported-requirements
'("dotencode"
"fncache"
"generaldelta"
"lz4revlog"
"remotefilelog"
"revlogv1"
"store")
"List of Mercurial repository requirements we understand.
If a repository requires features not present in this list, we
avoid attempting to parse Mercurial data structures.")
Performance improvements for vc-hg Teach vc-hg how to read some Mercurial internal data structures, allowing us to avoid the need to run hg status -A, which is very slow for large repositories. Fall back to running hg if anything looks funny. vc-hg now puts the _working directory_ revision in the modeline instead of the file revision, which greatly improves performance and which allows us to again skip running hg in the case that we have an active bookmark. * lisp/vc/vc-hg.el (vc-hg-state): Try calling `vc-hg-statefast' (vc-hg-symbolic-revision-styles) (vc-hg-use-file-version-for-mode-line-version) (vc-hg-parse-hg-data-structures): New user preferences (vc-hg--active-bookmark-internal, vc-hg--run-log) (vc-hg--symbolic-revision, vc-hg-mode-line-string) (vc-hg--read-u8, vc-hg--read-u32-be) (vc-hg--raw-dirstate-search, vc-hg--cached-dirstate-search) (vc-hg--parts-to-string, vc-hg--pcre-to-elisp-re) (vc-hg--glob-to-pcre, vc-hg--hgignore-add-pcre) (vc-hg--hgignore-add-glob, vc-hg--hgignore-add-path) (vc-hg--slurp-hgignore-1, vc-hg--slurp-hgignore) (vc-hg--ignore-patterns-valid-p) (vc-hg--ignore-patterns-ignored-p, vc-hg--time-to-fixnum) (vc-hg--file-ignored-p, vc-hg--read-repo-requirements) (vc-hg--requirements-understood-p, vc-hg--dirstate-scan-cache) (vc-hg-state-fast): New functions. (vc-hg--hgignore-patterns, vc-hg--hgignore-filenames) (vc-hg--cached-ignore-patterns, vc-hg--dirstate-scan-cache) (vc-hg--dirstate-scan-cache): New internal variables. * lisp/vc/vc-hooks.el (vc-refresh-state): Invoke vc find-file-hook before updating modeline.
2016-02-08 10:52:54 -08:00
(defun vc-hg--requirements-understood-p (repo)
"Check that we understand the format of the given repository.
REPO is the directory name of a Mercurial repository."
(null (cl-set-difference (vc-hg--read-repo-requirements repo)
vc-hg-supported-requirements
:test #'equal)))
(defvar vc-hg--dirstate-scan-cache nil
"Cache of the last result of `vc-hg--raw-dirstate-search'.
Avoids the need to repeatedly scan dirstate on repeated calls to
`vc-hg-state', as we see during registration queries.")
(defun vc-hg--cached-dirstate-search (dirstate dirstate-attr ascii-fname)
file-attributes cleanup Mostly, this replaces magic-number calls like (nth 4 A) with more-informative calls like (file-attribute-access-time A). It also fixes some documentation and minor timestamp coding issues that I noticed while looking into this. * doc/lispref/files.texi (File Attributes): * lisp/files.el (file-attribute-size) (file-attribute-inode-number, file-attribute-device-number): * src/dired.c (Fdirectory_files_and_attributes) (Ffile_attributes): Mention which attributes must be integers, or nonnegative integers, as opposed to merely being numbers. Remove no-longer-correct talk about representing large integers as conses of integers. * doc/lispref/files.texi (Magic File Names): * doc/misc/gnus.texi (Low-level interface to the spam-stat dictionary): * lisp/autorevert.el (auto-revert-find-file-function) (auto-revert-tail-mode, auto-revert-handler): * lisp/auth-source.el (auth-source-netrc-parse): * lisp/cedet/ede/files.el (ede--inode-for-dir): * lisp/cedet/semantic/db-file.el (object-write): * lisp/cedet/semantic/db-mode.el (semanticdb-kill-hook): * lisp/cedet/semantic/db.el (semanticdb-needs-refresh-p) (semanticdb-synchronize): * lisp/cedet/srecode/table.el (srecode-mode-table-new): * lisp/desktop.el (desktop-save, desktop-read): * lisp/dired-aux.el (dired-file-set-difference) (dired-do-chxxx, dired-do-chmod, dired-copy-file-recursive) (dired-create-files): * lisp/dired.el (dired-directory-changed-p, dired-readin): * lisp/dos-w32.el (w32-direct-print-region-helper): * lisp/emacs-lisp/autoload.el (autoload-generate-file-autoloads) (autoload-find-destination, update-directory-autoloads): * lisp/emacs-lisp/shadow.el (load-path-shadows-same-file-or-nonexistent): * lisp/epg.el (epg--start, epg-wait-for-completion): * lisp/eshell/em-ls.el (eshell-ls-filetype-p) (eshell-ls-applicable, eshell-ls-size-string) (eshell-ls-file, eshell-ls-dir, eshell-ls-files) (eshell-ls-entries): * lisp/eshell/em-pred.el (eshell-predicate-alist) (eshell-pred-file-type, eshell-pred-file-links) (eshell-pred-file-size): * lisp/eshell/em-unix.el (eshell-shuffle-files, eshell/cat) (eshell-du-sum-directory, eshell/du): * lisp/eshell/esh-util.el (eshell-read-passwd) (eshell-read-hosts): * lisp/files.el (remote-file-name-inhibit-cache) (find-file-noselect, insert-file-1, dir-locals-find-file) (dir-locals-read-from-dir, backup-buffer) (file-ownership-preserved-p, copy-directory) (read-file-modes): * lisp/find-lisp.el (find-lisp-format): * lisp/gnus/gnus-agent.el (gnus-agent-unfetch-articles) (gnus-agent-read-agentview, gnus-agent-expire-group-1) (gnus-agent-request-article, gnus-agent-regenerate-group) (gnus-agent-update-files-total-fetched-for) (gnus-agent-update-view-total-fetched-for): * lisp/gnus/gnus-cache.el (gnus-cache-read-active) (gnus-cache-update-file-total-fetched-for) (gnus-cache-update-overview-total-fetched-for): * lisp/gnus/gnus-cloud.el (gnus-cloud-file-new-p): * lisp/gnus/gnus-score.el (gnus-score-score-files): * lisp/gnus/gnus-start.el (gnus-save-newsrc-file) (gnus-master-read-slave-newsrc): * lisp/gnus/gnus-sum.el (gnus-summary-import-article): * lisp/gnus/gnus-util.el (gnus-file-newer-than) (gnus-cache-file-contents): * lisp/gnus/mail-source.el (mail-source-delete-old-incoming) (mail-source-callback, mail-source-movemail): * lisp/gnus/nneething.el (nneething-create-mapping) (nneething-make-head): * lisp/gnus/nnfolder.el (nnfolder-read-folder): * lisp/gnus/nnheader.el (nnheader-file-size) (nnheader-insert-nov-file): * lisp/gnus/nnmail.el (nnmail-activate): * lisp/gnus/nnmaildir.el (nnmaildir--group-maxnum) (nnmaildir--new-number, nnmaildir--update-nov) (nnmaildir--scan, nnmaildir-request-scan) (nnmaildir-request-update-info) (nnmaildir-request-expire-articles): * lisp/gnus/nnmh.el (nnmh-request-list-1) (nnmh-request-expire-articles, nnmh-update-gnus-unreads): * lisp/gnus/nnml.el (nnml-request-expire-articles): * lisp/gnus/spam-stat.el (spam-stat-save, spam-stat-load) (spam-stat-process-directory, spam-stat-test-directory): * lisp/ido.el (ido-directory-too-big-p) (ido-file-name-all-completions): * lisp/image-dired.el (image-dired-get-thumbnail-image) (image-dired-create-thumb-1): * lisp/info.el (info-insert-file-contents): * lisp/ls-lisp.el (ls-lisp-insert-directory) (ls-lisp-handle-switches, ls-lisp-classify-file) (ls-lisp-format): * lisp/mail/blessmail.el: * lisp/mail/feedmail.el (feedmail-default-date-generator) (feedmail-default-message-id-generator): * lisp/mail/mailabbrev.el (mail-abbrevs-sync-aliases) (mail-abbrevs-setup): * lisp/mail/mspools.el (mspools-size-folder): * lisp/mail/rmail.el (rmail-insert-inbox-text): * lisp/mail/sendmail.el (sendmail-sync-aliases): * lisp/mh-e/mh-alias.el (mh-alias-tstamp): * lisp/net/ange-ftp.el (ange-ftp-parse-netrc) (ange-ftp-write-region, ange-ftp-file-newer-than-file-p) (ange-ftp-cf1): * lisp/net/eudcb-mab.el (eudc-mab-query-internal): * lisp/net/eww.el (eww-read-bookmarks): * lisp/net/netrc.el (netrc-parse): * lisp/net/newst-backend.el (newsticker--image-get): * lisp/nxml/rng-loc.el (rng-get-parsed-schema-locating-file): * lisp/obsolete/fast-lock.el (fast-lock-save-cache): * lisp/obsolete/vc-arch.el (vc-arch-state) (vc-arch-diff3-rej-p): * lisp/org/ob-eval.el (org-babel--shell-command-on-region): * lisp/org/org-attach.el (org-attach-commit): * lisp/org/org-macro.el (org-macro-initialize-templates): * lisp/org/org.el (org-babel-load-file) (org-file-newer-than-p): * lisp/org/ox-html.el (org-html-format-spec): * lisp/org/ox-publish.el (org-publish-find-date) (org-publish-cache-ctime-of-src): * lisp/pcmpl-gnu.el (pcomplete/tar): * lisp/pcmpl-rpm.el (pcmpl-rpm-packages): * lisp/play/cookie1.el (cookie-snarf): * lisp/progmodes/cmacexp.el (c-macro-expansion): * lisp/ps-bdf.el (bdf-file-mod-time): * lisp/server.el (server-ensure-safe-dir): * lisp/simple.el (shell-command-on-region): * lisp/speedbar.el (speedbar-item-info-file-helper) (speedbar-check-obj-this-line): * lisp/thumbs.el (thumbs-cleanup-thumbsdir): * lisp/time.el (display-time-mail-check-directory) (display-time-file-nonempty-p): * lisp/url/url-cache.el (url-is-cached): * lisp/url/url-file.el (url-file-asynch-callback): * lisp/vc/diff-mode.el (diff-delete-if-empty): * lisp/vc/pcvs-info.el (cvs-fileinfo-from-entries): * lisp/vc/vc-bzr.el (vc-bzr-state-heuristic): * lisp/vc/vc-cvs.el (vc-cvs-checkout-model) (vc-cvs-state-heuristic, vc-cvs-merge-news) (vc-cvs-retrieve-tag, vc-cvs-parse-status, vc-cvs-parse-entry): * lisp/vc/vc-hg.el (vc-hg--slurp-hgignore-1) (vc-hg--ignore-patterns-valid-p) (vc-hg--cached-dirstate-search, vc-hg-state-fast): * lisp/vc/vc-hooks.el (vc-after-save): * lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer): * lisp/vc/vc-svn.el (vc-svn-merge-news, vc-svn-parse-status): * lisp/vc/vc.el (vc-checkout, vc-checkin, vc-revert-file): * lisp/xdg.el (xdg-mime-apps): Prefer (file-attribute-size A) to (nth 7 A), and similarly for other file attributes accessors. * doc/lispref/files.texi (File Attributes): * doc/lispref/intro.texi (Version Info): * doc/lispref/os.texi (Idle Timers): * lisp/erc/erc.el (erc-string-to-emacs-time): * lisp/files.el (file-attribute-access-time) (file-attribute-modification-time) (file-attribute-status-change-time): * lisp/net/tramp-compat.el: (tramp-compat-file-attribute-modification-time) (tramp-compat-file-attribute-size): * src/buffer.c (syms_of_buffer): * src/editfns.c (Fget_internal_run_time): * src/fileio.c (Fvisited_file_modtime) (Fset_visited_file_modtime): * src/keyboard.c (Fcurrent_idle_time): * src/process.c (Fprocess_attributes): Defer implementation details about timestamp format to the section that talks about timestamp format, to make it easier to change the documentation later if timestamp formats are extended. * lisp/gnus/gnus-util.el (gnus-file-newer-than): * lisp/speedbar.el (speedbar-check-obj-this-line): * lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer): Prefer time-less-p to doing it by hand. * lisp/ls-lisp.el (ls-lisp-format): Inode numbers are no longer conses. * lisp/vc/vc-bzr.el (vc-bzr-state-heuristic): Use eql, not eq, to compare integers that might be bignums. * lisp/org/ox-publish.el (org-publish-cache-ctime-of-src): Prefer float-time to doing time arithmetic by hand.
2018-09-23 18:30:46 -07:00
(let* ((mtime (file-attribute-modification-time dirstate-attr))
(size (file-attribute-size dirstate-attr))
Performance improvements for vc-hg Teach vc-hg how to read some Mercurial internal data structures, allowing us to avoid the need to run hg status -A, which is very slow for large repositories. Fall back to running hg if anything looks funny. vc-hg now puts the _working directory_ revision in the modeline instead of the file revision, which greatly improves performance and which allows us to again skip running hg in the case that we have an active bookmark. * lisp/vc/vc-hg.el (vc-hg-state): Try calling `vc-hg-statefast' (vc-hg-symbolic-revision-styles) (vc-hg-use-file-version-for-mode-line-version) (vc-hg-parse-hg-data-structures): New user preferences (vc-hg--active-bookmark-internal, vc-hg--run-log) (vc-hg--symbolic-revision, vc-hg-mode-line-string) (vc-hg--read-u8, vc-hg--read-u32-be) (vc-hg--raw-dirstate-search, vc-hg--cached-dirstate-search) (vc-hg--parts-to-string, vc-hg--pcre-to-elisp-re) (vc-hg--glob-to-pcre, vc-hg--hgignore-add-pcre) (vc-hg--hgignore-add-glob, vc-hg--hgignore-add-path) (vc-hg--slurp-hgignore-1, vc-hg--slurp-hgignore) (vc-hg--ignore-patterns-valid-p) (vc-hg--ignore-patterns-ignored-p, vc-hg--time-to-fixnum) (vc-hg--file-ignored-p, vc-hg--read-repo-requirements) (vc-hg--requirements-understood-p, vc-hg--dirstate-scan-cache) (vc-hg-state-fast): New functions. (vc-hg--hgignore-patterns, vc-hg--hgignore-filenames) (vc-hg--cached-ignore-patterns, vc-hg--dirstate-scan-cache) (vc-hg--dirstate-scan-cache): New internal variables. * lisp/vc/vc-hooks.el (vc-refresh-state): Invoke vc find-file-hook before updating modeline.
2016-02-08 10:52:54 -08:00
(cache vc-hg--dirstate-scan-cache)
)
(if (and cache
(equal dirstate (pop cache))
(time-equal-p mtime (pop cache))
Performance improvements for vc-hg Teach vc-hg how to read some Mercurial internal data structures, allowing us to avoid the need to run hg status -A, which is very slow for large repositories. Fall back to running hg if anything looks funny. vc-hg now puts the _working directory_ revision in the modeline instead of the file revision, which greatly improves performance and which allows us to again skip running hg in the case that we have an active bookmark. * lisp/vc/vc-hg.el (vc-hg-state): Try calling `vc-hg-statefast' (vc-hg-symbolic-revision-styles) (vc-hg-use-file-version-for-mode-line-version) (vc-hg-parse-hg-data-structures): New user preferences (vc-hg--active-bookmark-internal, vc-hg--run-log) (vc-hg--symbolic-revision, vc-hg-mode-line-string) (vc-hg--read-u8, vc-hg--read-u32-be) (vc-hg--raw-dirstate-search, vc-hg--cached-dirstate-search) (vc-hg--parts-to-string, vc-hg--pcre-to-elisp-re) (vc-hg--glob-to-pcre, vc-hg--hgignore-add-pcre) (vc-hg--hgignore-add-glob, vc-hg--hgignore-add-path) (vc-hg--slurp-hgignore-1, vc-hg--slurp-hgignore) (vc-hg--ignore-patterns-valid-p) (vc-hg--ignore-patterns-ignored-p, vc-hg--time-to-fixnum) (vc-hg--file-ignored-p, vc-hg--read-repo-requirements) (vc-hg--requirements-understood-p, vc-hg--dirstate-scan-cache) (vc-hg-state-fast): New functions. (vc-hg--hgignore-patterns, vc-hg--hgignore-filenames) (vc-hg--cached-ignore-patterns, vc-hg--dirstate-scan-cache) (vc-hg--dirstate-scan-cache): New internal variables. * lisp/vc/vc-hooks.el (vc-refresh-state): Invoke vc find-file-hook before updating modeline.
2016-02-08 10:52:54 -08:00
(equal size (pop cache))
(equal ascii-fname (pop cache)))
(pop cache)
(let ((result (save-match-data
(vc-hg--raw-dirstate-search dirstate ascii-fname))))
Performance improvements for vc-hg Teach vc-hg how to read some Mercurial internal data structures, allowing us to avoid the need to run hg status -A, which is very slow for large repositories. Fall back to running hg if anything looks funny. vc-hg now puts the _working directory_ revision in the modeline instead of the file revision, which greatly improves performance and which allows us to again skip running hg in the case that we have an active bookmark. * lisp/vc/vc-hg.el (vc-hg-state): Try calling `vc-hg-statefast' (vc-hg-symbolic-revision-styles) (vc-hg-use-file-version-for-mode-line-version) (vc-hg-parse-hg-data-structures): New user preferences (vc-hg--active-bookmark-internal, vc-hg--run-log) (vc-hg--symbolic-revision, vc-hg-mode-line-string) (vc-hg--read-u8, vc-hg--read-u32-be) (vc-hg--raw-dirstate-search, vc-hg--cached-dirstate-search) (vc-hg--parts-to-string, vc-hg--pcre-to-elisp-re) (vc-hg--glob-to-pcre, vc-hg--hgignore-add-pcre) (vc-hg--hgignore-add-glob, vc-hg--hgignore-add-path) (vc-hg--slurp-hgignore-1, vc-hg--slurp-hgignore) (vc-hg--ignore-patterns-valid-p) (vc-hg--ignore-patterns-ignored-p, vc-hg--time-to-fixnum) (vc-hg--file-ignored-p, vc-hg--read-repo-requirements) (vc-hg--requirements-understood-p, vc-hg--dirstate-scan-cache) (vc-hg-state-fast): New functions. (vc-hg--hgignore-patterns, vc-hg--hgignore-filenames) (vc-hg--cached-ignore-patterns, vc-hg--dirstate-scan-cache) (vc-hg--dirstate-scan-cache): New internal variables. * lisp/vc/vc-hooks.el (vc-refresh-state): Invoke vc find-file-hook before updating modeline.
2016-02-08 10:52:54 -08:00
(setf vc-hg--dirstate-scan-cache
(list dirstate mtime size ascii-fname result))
result))))
(defun vc-hg-state-fast (filename)
"Like `vc-hg-state', but parse internal data structures directly.
Returns one of the usual `vc-state' enumeration values or
`unsupported' if we need to take the slow path and run the
hg binary."
(let* (truename
repo
dirstate
dirstate-attr
repo-relative-filename)
Performance improvements for vc-hg Teach vc-hg how to read some Mercurial internal data structures, allowing us to avoid the need to run hg status -A, which is very slow for large repositories. Fall back to running hg if anything looks funny. vc-hg now puts the _working directory_ revision in the modeline instead of the file revision, which greatly improves performance and which allows us to again skip running hg in the case that we have an active bookmark. * lisp/vc/vc-hg.el (vc-hg-state): Try calling `vc-hg-statefast' (vc-hg-symbolic-revision-styles) (vc-hg-use-file-version-for-mode-line-version) (vc-hg-parse-hg-data-structures): New user preferences (vc-hg--active-bookmark-internal, vc-hg--run-log) (vc-hg--symbolic-revision, vc-hg-mode-line-string) (vc-hg--read-u8, vc-hg--read-u32-be) (vc-hg--raw-dirstate-search, vc-hg--cached-dirstate-search) (vc-hg--parts-to-string, vc-hg--pcre-to-elisp-re) (vc-hg--glob-to-pcre, vc-hg--hgignore-add-pcre) (vc-hg--hgignore-add-glob, vc-hg--hgignore-add-path) (vc-hg--slurp-hgignore-1, vc-hg--slurp-hgignore) (vc-hg--ignore-patterns-valid-p) (vc-hg--ignore-patterns-ignored-p, vc-hg--time-to-fixnum) (vc-hg--file-ignored-p, vc-hg--read-repo-requirements) (vc-hg--requirements-understood-p, vc-hg--dirstate-scan-cache) (vc-hg-state-fast): New functions. (vc-hg--hgignore-patterns, vc-hg--hgignore-filenames) (vc-hg--cached-ignore-patterns, vc-hg--dirstate-scan-cache) (vc-hg--dirstate-scan-cache): New internal variables. * lisp/vc/vc-hooks.el (vc-refresh-state): Invoke vc find-file-hook before updating modeline.
2016-02-08 10:52:54 -08:00
(if (or
;; Explicit user disable
(not vc-hg-parse-hg-data-structures)
;; It'll probably be faster to run hg remotely
(file-remote-p filename)
(progn
(setf truename (file-truename filename))
(file-remote-p truename))
(not (setf repo (vc-hg-root truename)))
;; dirstate must exist
(not (progn
(setf repo (expand-file-name repo))
(cl-assert (and (file-name-absolute-p repo)
(directory-name-p repo)))
Performance improvements for vc-hg Teach vc-hg how to read some Mercurial internal data structures, allowing us to avoid the need to run hg status -A, which is very slow for large repositories. Fall back to running hg if anything looks funny. vc-hg now puts the _working directory_ revision in the modeline instead of the file revision, which greatly improves performance and which allows us to again skip running hg in the case that we have an active bookmark. * lisp/vc/vc-hg.el (vc-hg-state): Try calling `vc-hg-statefast' (vc-hg-symbolic-revision-styles) (vc-hg-use-file-version-for-mode-line-version) (vc-hg-parse-hg-data-structures): New user preferences (vc-hg--active-bookmark-internal, vc-hg--run-log) (vc-hg--symbolic-revision, vc-hg-mode-line-string) (vc-hg--read-u8, vc-hg--read-u32-be) (vc-hg--raw-dirstate-search, vc-hg--cached-dirstate-search) (vc-hg--parts-to-string, vc-hg--pcre-to-elisp-re) (vc-hg--glob-to-pcre, vc-hg--hgignore-add-pcre) (vc-hg--hgignore-add-glob, vc-hg--hgignore-add-path) (vc-hg--slurp-hgignore-1, vc-hg--slurp-hgignore) (vc-hg--ignore-patterns-valid-p) (vc-hg--ignore-patterns-ignored-p, vc-hg--time-to-fixnum) (vc-hg--file-ignored-p, vc-hg--read-repo-requirements) (vc-hg--requirements-understood-p, vc-hg--dirstate-scan-cache) (vc-hg-state-fast): New functions. (vc-hg--hgignore-patterns, vc-hg--hgignore-filenames) (vc-hg--cached-ignore-patterns, vc-hg--dirstate-scan-cache) (vc-hg--dirstate-scan-cache): New internal variables. * lisp/vc/vc-hooks.el (vc-refresh-state): Invoke vc find-file-hook before updating modeline.
2016-02-08 10:52:54 -08:00
(setf dirstate (concat repo ".hg/dirstate"))
(setf dirstate-attr (file-attributes dirstate))))
;; Repository must be in an understood format
(not (vc-hg--requirements-understood-p repo))
;; Dirstate too small to be valid
file-attributes cleanup Mostly, this replaces magic-number calls like (nth 4 A) with more-informative calls like (file-attribute-access-time A). It also fixes some documentation and minor timestamp coding issues that I noticed while looking into this. * doc/lispref/files.texi (File Attributes): * lisp/files.el (file-attribute-size) (file-attribute-inode-number, file-attribute-device-number): * src/dired.c (Fdirectory_files_and_attributes) (Ffile_attributes): Mention which attributes must be integers, or nonnegative integers, as opposed to merely being numbers. Remove no-longer-correct talk about representing large integers as conses of integers. * doc/lispref/files.texi (Magic File Names): * doc/misc/gnus.texi (Low-level interface to the spam-stat dictionary): * lisp/autorevert.el (auto-revert-find-file-function) (auto-revert-tail-mode, auto-revert-handler): * lisp/auth-source.el (auth-source-netrc-parse): * lisp/cedet/ede/files.el (ede--inode-for-dir): * lisp/cedet/semantic/db-file.el (object-write): * lisp/cedet/semantic/db-mode.el (semanticdb-kill-hook): * lisp/cedet/semantic/db.el (semanticdb-needs-refresh-p) (semanticdb-synchronize): * lisp/cedet/srecode/table.el (srecode-mode-table-new): * lisp/desktop.el (desktop-save, desktop-read): * lisp/dired-aux.el (dired-file-set-difference) (dired-do-chxxx, dired-do-chmod, dired-copy-file-recursive) (dired-create-files): * lisp/dired.el (dired-directory-changed-p, dired-readin): * lisp/dos-w32.el (w32-direct-print-region-helper): * lisp/emacs-lisp/autoload.el (autoload-generate-file-autoloads) (autoload-find-destination, update-directory-autoloads): * lisp/emacs-lisp/shadow.el (load-path-shadows-same-file-or-nonexistent): * lisp/epg.el (epg--start, epg-wait-for-completion): * lisp/eshell/em-ls.el (eshell-ls-filetype-p) (eshell-ls-applicable, eshell-ls-size-string) (eshell-ls-file, eshell-ls-dir, eshell-ls-files) (eshell-ls-entries): * lisp/eshell/em-pred.el (eshell-predicate-alist) (eshell-pred-file-type, eshell-pred-file-links) (eshell-pred-file-size): * lisp/eshell/em-unix.el (eshell-shuffle-files, eshell/cat) (eshell-du-sum-directory, eshell/du): * lisp/eshell/esh-util.el (eshell-read-passwd) (eshell-read-hosts): * lisp/files.el (remote-file-name-inhibit-cache) (find-file-noselect, insert-file-1, dir-locals-find-file) (dir-locals-read-from-dir, backup-buffer) (file-ownership-preserved-p, copy-directory) (read-file-modes): * lisp/find-lisp.el (find-lisp-format): * lisp/gnus/gnus-agent.el (gnus-agent-unfetch-articles) (gnus-agent-read-agentview, gnus-agent-expire-group-1) (gnus-agent-request-article, gnus-agent-regenerate-group) (gnus-agent-update-files-total-fetched-for) (gnus-agent-update-view-total-fetched-for): * lisp/gnus/gnus-cache.el (gnus-cache-read-active) (gnus-cache-update-file-total-fetched-for) (gnus-cache-update-overview-total-fetched-for): * lisp/gnus/gnus-cloud.el (gnus-cloud-file-new-p): * lisp/gnus/gnus-score.el (gnus-score-score-files): * lisp/gnus/gnus-start.el (gnus-save-newsrc-file) (gnus-master-read-slave-newsrc): * lisp/gnus/gnus-sum.el (gnus-summary-import-article): * lisp/gnus/gnus-util.el (gnus-file-newer-than) (gnus-cache-file-contents): * lisp/gnus/mail-source.el (mail-source-delete-old-incoming) (mail-source-callback, mail-source-movemail): * lisp/gnus/nneething.el (nneething-create-mapping) (nneething-make-head): * lisp/gnus/nnfolder.el (nnfolder-read-folder): * lisp/gnus/nnheader.el (nnheader-file-size) (nnheader-insert-nov-file): * lisp/gnus/nnmail.el (nnmail-activate): * lisp/gnus/nnmaildir.el (nnmaildir--group-maxnum) (nnmaildir--new-number, nnmaildir--update-nov) (nnmaildir--scan, nnmaildir-request-scan) (nnmaildir-request-update-info) (nnmaildir-request-expire-articles): * lisp/gnus/nnmh.el (nnmh-request-list-1) (nnmh-request-expire-articles, nnmh-update-gnus-unreads): * lisp/gnus/nnml.el (nnml-request-expire-articles): * lisp/gnus/spam-stat.el (spam-stat-save, spam-stat-load) (spam-stat-process-directory, spam-stat-test-directory): * lisp/ido.el (ido-directory-too-big-p) (ido-file-name-all-completions): * lisp/image-dired.el (image-dired-get-thumbnail-image) (image-dired-create-thumb-1): * lisp/info.el (info-insert-file-contents): * lisp/ls-lisp.el (ls-lisp-insert-directory) (ls-lisp-handle-switches, ls-lisp-classify-file) (ls-lisp-format): * lisp/mail/blessmail.el: * lisp/mail/feedmail.el (feedmail-default-date-generator) (feedmail-default-message-id-generator): * lisp/mail/mailabbrev.el (mail-abbrevs-sync-aliases) (mail-abbrevs-setup): * lisp/mail/mspools.el (mspools-size-folder): * lisp/mail/rmail.el (rmail-insert-inbox-text): * lisp/mail/sendmail.el (sendmail-sync-aliases): * lisp/mh-e/mh-alias.el (mh-alias-tstamp): * lisp/net/ange-ftp.el (ange-ftp-parse-netrc) (ange-ftp-write-region, ange-ftp-file-newer-than-file-p) (ange-ftp-cf1): * lisp/net/eudcb-mab.el (eudc-mab-query-internal): * lisp/net/eww.el (eww-read-bookmarks): * lisp/net/netrc.el (netrc-parse): * lisp/net/newst-backend.el (newsticker--image-get): * lisp/nxml/rng-loc.el (rng-get-parsed-schema-locating-file): * lisp/obsolete/fast-lock.el (fast-lock-save-cache): * lisp/obsolete/vc-arch.el (vc-arch-state) (vc-arch-diff3-rej-p): * lisp/org/ob-eval.el (org-babel--shell-command-on-region): * lisp/org/org-attach.el (org-attach-commit): * lisp/org/org-macro.el (org-macro-initialize-templates): * lisp/org/org.el (org-babel-load-file) (org-file-newer-than-p): * lisp/org/ox-html.el (org-html-format-spec): * lisp/org/ox-publish.el (org-publish-find-date) (org-publish-cache-ctime-of-src): * lisp/pcmpl-gnu.el (pcomplete/tar): * lisp/pcmpl-rpm.el (pcmpl-rpm-packages): * lisp/play/cookie1.el (cookie-snarf): * lisp/progmodes/cmacexp.el (c-macro-expansion): * lisp/ps-bdf.el (bdf-file-mod-time): * lisp/server.el (server-ensure-safe-dir): * lisp/simple.el (shell-command-on-region): * lisp/speedbar.el (speedbar-item-info-file-helper) (speedbar-check-obj-this-line): * lisp/thumbs.el (thumbs-cleanup-thumbsdir): * lisp/time.el (display-time-mail-check-directory) (display-time-file-nonempty-p): * lisp/url/url-cache.el (url-is-cached): * lisp/url/url-file.el (url-file-asynch-callback): * lisp/vc/diff-mode.el (diff-delete-if-empty): * lisp/vc/pcvs-info.el (cvs-fileinfo-from-entries): * lisp/vc/vc-bzr.el (vc-bzr-state-heuristic): * lisp/vc/vc-cvs.el (vc-cvs-checkout-model) (vc-cvs-state-heuristic, vc-cvs-merge-news) (vc-cvs-retrieve-tag, vc-cvs-parse-status, vc-cvs-parse-entry): * lisp/vc/vc-hg.el (vc-hg--slurp-hgignore-1) (vc-hg--ignore-patterns-valid-p) (vc-hg--cached-dirstate-search, vc-hg-state-fast): * lisp/vc/vc-hooks.el (vc-after-save): * lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer): * lisp/vc/vc-svn.el (vc-svn-merge-news, vc-svn-parse-status): * lisp/vc/vc.el (vc-checkout, vc-checkin, vc-revert-file): * lisp/xdg.el (xdg-mime-apps): Prefer (file-attribute-size A) to (nth 7 A), and similarly for other file attributes accessors. * doc/lispref/files.texi (File Attributes): * doc/lispref/intro.texi (Version Info): * doc/lispref/os.texi (Idle Timers): * lisp/erc/erc.el (erc-string-to-emacs-time): * lisp/files.el (file-attribute-access-time) (file-attribute-modification-time) (file-attribute-status-change-time): * lisp/net/tramp-compat.el: (tramp-compat-file-attribute-modification-time) (tramp-compat-file-attribute-size): * src/buffer.c (syms_of_buffer): * src/editfns.c (Fget_internal_run_time): * src/fileio.c (Fvisited_file_modtime) (Fset_visited_file_modtime): * src/keyboard.c (Fcurrent_idle_time): * src/process.c (Fprocess_attributes): Defer implementation details about timestamp format to the section that talks about timestamp format, to make it easier to change the documentation later if timestamp formats are extended. * lisp/gnus/gnus-util.el (gnus-file-newer-than): * lisp/speedbar.el (speedbar-check-obj-this-line): * lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer): Prefer time-less-p to doing it by hand. * lisp/ls-lisp.el (ls-lisp-format): Inode numbers are no longer conses. * lisp/vc/vc-bzr.el (vc-bzr-state-heuristic): Use eql, not eq, to compare integers that might be bignums. * lisp/org/ox-publish.el (org-publish-cache-ctime-of-src): Prefer float-time to doing time arithmetic by hand.
2018-09-23 18:30:46 -07:00
(< (file-attribute-size dirstate-attr) 40)
Performance improvements for vc-hg Teach vc-hg how to read some Mercurial internal data structures, allowing us to avoid the need to run hg status -A, which is very slow for large repositories. Fall back to running hg if anything looks funny. vc-hg now puts the _working directory_ revision in the modeline instead of the file revision, which greatly improves performance and which allows us to again skip running hg in the case that we have an active bookmark. * lisp/vc/vc-hg.el (vc-hg-state): Try calling `vc-hg-statefast' (vc-hg-symbolic-revision-styles) (vc-hg-use-file-version-for-mode-line-version) (vc-hg-parse-hg-data-structures): New user preferences (vc-hg--active-bookmark-internal, vc-hg--run-log) (vc-hg--symbolic-revision, vc-hg-mode-line-string) (vc-hg--read-u8, vc-hg--read-u32-be) (vc-hg--raw-dirstate-search, vc-hg--cached-dirstate-search) (vc-hg--parts-to-string, vc-hg--pcre-to-elisp-re) (vc-hg--glob-to-pcre, vc-hg--hgignore-add-pcre) (vc-hg--hgignore-add-glob, vc-hg--hgignore-add-path) (vc-hg--slurp-hgignore-1, vc-hg--slurp-hgignore) (vc-hg--ignore-patterns-valid-p) (vc-hg--ignore-patterns-ignored-p, vc-hg--time-to-fixnum) (vc-hg--file-ignored-p, vc-hg--read-repo-requirements) (vc-hg--requirements-understood-p, vc-hg--dirstate-scan-cache) (vc-hg-state-fast): New functions. (vc-hg--hgignore-patterns, vc-hg--hgignore-filenames) (vc-hg--cached-ignore-patterns, vc-hg--dirstate-scan-cache) (vc-hg--dirstate-scan-cache): New internal variables. * lisp/vc/vc-hooks.el (vc-refresh-state): Invoke vc find-file-hook before updating modeline.
2016-02-08 10:52:54 -08:00
(progn
(setf repo-relative-filename
(file-relative-name truename repo))
;; We only try dealing with ASCII filenames
(string-match-p "[^[:ascii:]]" repo-relative-filename)))
Performance improvements for vc-hg Teach vc-hg how to read some Mercurial internal data structures, allowing us to avoid the need to run hg status -A, which is very slow for large repositories. Fall back to running hg if anything looks funny. vc-hg now puts the _working directory_ revision in the modeline instead of the file revision, which greatly improves performance and which allows us to again skip running hg in the case that we have an active bookmark. * lisp/vc/vc-hg.el (vc-hg-state): Try calling `vc-hg-statefast' (vc-hg-symbolic-revision-styles) (vc-hg-use-file-version-for-mode-line-version) (vc-hg-parse-hg-data-structures): New user preferences (vc-hg--active-bookmark-internal, vc-hg--run-log) (vc-hg--symbolic-revision, vc-hg-mode-line-string) (vc-hg--read-u8, vc-hg--read-u32-be) (vc-hg--raw-dirstate-search, vc-hg--cached-dirstate-search) (vc-hg--parts-to-string, vc-hg--pcre-to-elisp-re) (vc-hg--glob-to-pcre, vc-hg--hgignore-add-pcre) (vc-hg--hgignore-add-glob, vc-hg--hgignore-add-path) (vc-hg--slurp-hgignore-1, vc-hg--slurp-hgignore) (vc-hg--ignore-patterns-valid-p) (vc-hg--ignore-patterns-ignored-p, vc-hg--time-to-fixnum) (vc-hg--file-ignored-p, vc-hg--read-repo-requirements) (vc-hg--requirements-understood-p, vc-hg--dirstate-scan-cache) (vc-hg-state-fast): New functions. (vc-hg--hgignore-patterns, vc-hg--hgignore-filenames) (vc-hg--cached-ignore-patterns, vc-hg--dirstate-scan-cache) (vc-hg--dirstate-scan-cache): New internal variables. * lisp/vc/vc-hooks.el (vc-refresh-state): Invoke vc find-file-hook before updating modeline.
2016-02-08 10:52:54 -08:00
'unsupported
(let* ((dirstate-entry
(vc-hg--cached-dirstate-search
dirstate dirstate-attr repo-relative-filename))
Performance improvements for vc-hg Teach vc-hg how to read some Mercurial internal data structures, allowing us to avoid the need to run hg status -A, which is very slow for large repositories. Fall back to running hg if anything looks funny. vc-hg now puts the _working directory_ revision in the modeline instead of the file revision, which greatly improves performance and which allows us to again skip running hg in the case that we have an active bookmark. * lisp/vc/vc-hg.el (vc-hg-state): Try calling `vc-hg-statefast' (vc-hg-symbolic-revision-styles) (vc-hg-use-file-version-for-mode-line-version) (vc-hg-parse-hg-data-structures): New user preferences (vc-hg--active-bookmark-internal, vc-hg--run-log) (vc-hg--symbolic-revision, vc-hg-mode-line-string) (vc-hg--read-u8, vc-hg--read-u32-be) (vc-hg--raw-dirstate-search, vc-hg--cached-dirstate-search) (vc-hg--parts-to-string, vc-hg--pcre-to-elisp-re) (vc-hg--glob-to-pcre, vc-hg--hgignore-add-pcre) (vc-hg--hgignore-add-glob, vc-hg--hgignore-add-path) (vc-hg--slurp-hgignore-1, vc-hg--slurp-hgignore) (vc-hg--ignore-patterns-valid-p) (vc-hg--ignore-patterns-ignored-p, vc-hg--time-to-fixnum) (vc-hg--file-ignored-p, vc-hg--read-repo-requirements) (vc-hg--requirements-understood-p, vc-hg--dirstate-scan-cache) (vc-hg-state-fast): New functions. (vc-hg--hgignore-patterns, vc-hg--hgignore-filenames) (vc-hg--cached-ignore-patterns, vc-hg--dirstate-scan-cache) (vc-hg--dirstate-scan-cache): New internal variables. * lisp/vc/vc-hooks.el (vc-refresh-state): Invoke vc find-file-hook before updating modeline.
2016-02-08 10:52:54 -08:00
(state (car dirstate-entry))
(stat (file-attributes
(concat repo repo-relative-filename))))
(cond ((eq state ?r) 'removed)
((and (not state) stat)
(condition-case nil
(if (vc-hg--file-ignored-p repo repo-relative-filename)
'ignored
'unregistered)
(vc-hg-unsupported-syntax 'unsupported)))
((and state (not stat)) 'missing)
((eq state ?n)
(let ((vc-hg-size (nth 2 dirstate-entry))
(vc-hg-mtime (nth 3 dirstate-entry))
file-attributes cleanup Mostly, this replaces magic-number calls like (nth 4 A) with more-informative calls like (file-attribute-access-time A). It also fixes some documentation and minor timestamp coding issues that I noticed while looking into this. * doc/lispref/files.texi (File Attributes): * lisp/files.el (file-attribute-size) (file-attribute-inode-number, file-attribute-device-number): * src/dired.c (Fdirectory_files_and_attributes) (Ffile_attributes): Mention which attributes must be integers, or nonnegative integers, as opposed to merely being numbers. Remove no-longer-correct talk about representing large integers as conses of integers. * doc/lispref/files.texi (Magic File Names): * doc/misc/gnus.texi (Low-level interface to the spam-stat dictionary): * lisp/autorevert.el (auto-revert-find-file-function) (auto-revert-tail-mode, auto-revert-handler): * lisp/auth-source.el (auth-source-netrc-parse): * lisp/cedet/ede/files.el (ede--inode-for-dir): * lisp/cedet/semantic/db-file.el (object-write): * lisp/cedet/semantic/db-mode.el (semanticdb-kill-hook): * lisp/cedet/semantic/db.el (semanticdb-needs-refresh-p) (semanticdb-synchronize): * lisp/cedet/srecode/table.el (srecode-mode-table-new): * lisp/desktop.el (desktop-save, desktop-read): * lisp/dired-aux.el (dired-file-set-difference) (dired-do-chxxx, dired-do-chmod, dired-copy-file-recursive) (dired-create-files): * lisp/dired.el (dired-directory-changed-p, dired-readin): * lisp/dos-w32.el (w32-direct-print-region-helper): * lisp/emacs-lisp/autoload.el (autoload-generate-file-autoloads) (autoload-find-destination, update-directory-autoloads): * lisp/emacs-lisp/shadow.el (load-path-shadows-same-file-or-nonexistent): * lisp/epg.el (epg--start, epg-wait-for-completion): * lisp/eshell/em-ls.el (eshell-ls-filetype-p) (eshell-ls-applicable, eshell-ls-size-string) (eshell-ls-file, eshell-ls-dir, eshell-ls-files) (eshell-ls-entries): * lisp/eshell/em-pred.el (eshell-predicate-alist) (eshell-pred-file-type, eshell-pred-file-links) (eshell-pred-file-size): * lisp/eshell/em-unix.el (eshell-shuffle-files, eshell/cat) (eshell-du-sum-directory, eshell/du): * lisp/eshell/esh-util.el (eshell-read-passwd) (eshell-read-hosts): * lisp/files.el (remote-file-name-inhibit-cache) (find-file-noselect, insert-file-1, dir-locals-find-file) (dir-locals-read-from-dir, backup-buffer) (file-ownership-preserved-p, copy-directory) (read-file-modes): * lisp/find-lisp.el (find-lisp-format): * lisp/gnus/gnus-agent.el (gnus-agent-unfetch-articles) (gnus-agent-read-agentview, gnus-agent-expire-group-1) (gnus-agent-request-article, gnus-agent-regenerate-group) (gnus-agent-update-files-total-fetched-for) (gnus-agent-update-view-total-fetched-for): * lisp/gnus/gnus-cache.el (gnus-cache-read-active) (gnus-cache-update-file-total-fetched-for) (gnus-cache-update-overview-total-fetched-for): * lisp/gnus/gnus-cloud.el (gnus-cloud-file-new-p): * lisp/gnus/gnus-score.el (gnus-score-score-files): * lisp/gnus/gnus-start.el (gnus-save-newsrc-file) (gnus-master-read-slave-newsrc): * lisp/gnus/gnus-sum.el (gnus-summary-import-article): * lisp/gnus/gnus-util.el (gnus-file-newer-than) (gnus-cache-file-contents): * lisp/gnus/mail-source.el (mail-source-delete-old-incoming) (mail-source-callback, mail-source-movemail): * lisp/gnus/nneething.el (nneething-create-mapping) (nneething-make-head): * lisp/gnus/nnfolder.el (nnfolder-read-folder): * lisp/gnus/nnheader.el (nnheader-file-size) (nnheader-insert-nov-file): * lisp/gnus/nnmail.el (nnmail-activate): * lisp/gnus/nnmaildir.el (nnmaildir--group-maxnum) (nnmaildir--new-number, nnmaildir--update-nov) (nnmaildir--scan, nnmaildir-request-scan) (nnmaildir-request-update-info) (nnmaildir-request-expire-articles): * lisp/gnus/nnmh.el (nnmh-request-list-1) (nnmh-request-expire-articles, nnmh-update-gnus-unreads): * lisp/gnus/nnml.el (nnml-request-expire-articles): * lisp/gnus/spam-stat.el (spam-stat-save, spam-stat-load) (spam-stat-process-directory, spam-stat-test-directory): * lisp/ido.el (ido-directory-too-big-p) (ido-file-name-all-completions): * lisp/image-dired.el (image-dired-get-thumbnail-image) (image-dired-create-thumb-1): * lisp/info.el (info-insert-file-contents): * lisp/ls-lisp.el (ls-lisp-insert-directory) (ls-lisp-handle-switches, ls-lisp-classify-file) (ls-lisp-format): * lisp/mail/blessmail.el: * lisp/mail/feedmail.el (feedmail-default-date-generator) (feedmail-default-message-id-generator): * lisp/mail/mailabbrev.el (mail-abbrevs-sync-aliases) (mail-abbrevs-setup): * lisp/mail/mspools.el (mspools-size-folder): * lisp/mail/rmail.el (rmail-insert-inbox-text): * lisp/mail/sendmail.el (sendmail-sync-aliases): * lisp/mh-e/mh-alias.el (mh-alias-tstamp): * lisp/net/ange-ftp.el (ange-ftp-parse-netrc) (ange-ftp-write-region, ange-ftp-file-newer-than-file-p) (ange-ftp-cf1): * lisp/net/eudcb-mab.el (eudc-mab-query-internal): * lisp/net/eww.el (eww-read-bookmarks): * lisp/net/netrc.el (netrc-parse): * lisp/net/newst-backend.el (newsticker--image-get): * lisp/nxml/rng-loc.el (rng-get-parsed-schema-locating-file): * lisp/obsolete/fast-lock.el (fast-lock-save-cache): * lisp/obsolete/vc-arch.el (vc-arch-state) (vc-arch-diff3-rej-p): * lisp/org/ob-eval.el (org-babel--shell-command-on-region): * lisp/org/org-attach.el (org-attach-commit): * lisp/org/org-macro.el (org-macro-initialize-templates): * lisp/org/org.el (org-babel-load-file) (org-file-newer-than-p): * lisp/org/ox-html.el (org-html-format-spec): * lisp/org/ox-publish.el (org-publish-find-date) (org-publish-cache-ctime-of-src): * lisp/pcmpl-gnu.el (pcomplete/tar): * lisp/pcmpl-rpm.el (pcmpl-rpm-packages): * lisp/play/cookie1.el (cookie-snarf): * lisp/progmodes/cmacexp.el (c-macro-expansion): * lisp/ps-bdf.el (bdf-file-mod-time): * lisp/server.el (server-ensure-safe-dir): * lisp/simple.el (shell-command-on-region): * lisp/speedbar.el (speedbar-item-info-file-helper) (speedbar-check-obj-this-line): * lisp/thumbs.el (thumbs-cleanup-thumbsdir): * lisp/time.el (display-time-mail-check-directory) (display-time-file-nonempty-p): * lisp/url/url-cache.el (url-is-cached): * lisp/url/url-file.el (url-file-asynch-callback): * lisp/vc/diff-mode.el (diff-delete-if-empty): * lisp/vc/pcvs-info.el (cvs-fileinfo-from-entries): * lisp/vc/vc-bzr.el (vc-bzr-state-heuristic): * lisp/vc/vc-cvs.el (vc-cvs-checkout-model) (vc-cvs-state-heuristic, vc-cvs-merge-news) (vc-cvs-retrieve-tag, vc-cvs-parse-status, vc-cvs-parse-entry): * lisp/vc/vc-hg.el (vc-hg--slurp-hgignore-1) (vc-hg--ignore-patterns-valid-p) (vc-hg--cached-dirstate-search, vc-hg-state-fast): * lisp/vc/vc-hooks.el (vc-after-save): * lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer): * lisp/vc/vc-svn.el (vc-svn-merge-news, vc-svn-parse-status): * lisp/vc/vc.el (vc-checkout, vc-checkin, vc-revert-file): * lisp/xdg.el (xdg-mime-apps): Prefer (file-attribute-size A) to (nth 7 A), and similarly for other file attributes accessors. * doc/lispref/files.texi (File Attributes): * doc/lispref/intro.texi (Version Info): * doc/lispref/os.texi (Idle Timers): * lisp/erc/erc.el (erc-string-to-emacs-time): * lisp/files.el (file-attribute-access-time) (file-attribute-modification-time) (file-attribute-status-change-time): * lisp/net/tramp-compat.el: (tramp-compat-file-attribute-modification-time) (tramp-compat-file-attribute-size): * src/buffer.c (syms_of_buffer): * src/editfns.c (Fget_internal_run_time): * src/fileio.c (Fvisited_file_modtime) (Fset_visited_file_modtime): * src/keyboard.c (Fcurrent_idle_time): * src/process.c (Fprocess_attributes): Defer implementation details about timestamp format to the section that talks about timestamp format, to make it easier to change the documentation later if timestamp formats are extended. * lisp/gnus/gnus-util.el (gnus-file-newer-than): * lisp/speedbar.el (speedbar-check-obj-this-line): * lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer): Prefer time-less-p to doing it by hand. * lisp/ls-lisp.el (ls-lisp-format): Inode numbers are no longer conses. * lisp/vc/vc-bzr.el (vc-bzr-state-heuristic): Use eql, not eq, to compare integers that might be bignums. * lisp/org/ox-publish.el (org-publish-cache-ctime-of-src): Prefer float-time to doing time arithmetic by hand.
2018-09-23 18:30:46 -07:00
(fs-size (file-attribute-size stat))
New function time-convert This replaces the awkward reuse of encode-time to both convert calendrical timestamps to Lisp timestamps, and to convert Lisp timestamps to other forms. Now, encode-time does just the former and the new function does just the latter. The new function builds on a suggestion by Lars Ingebrigtsen in: https://lists.gnu.org/r/emacs-devel/2019-07/msg00801.html and refined by Stefan Monnier in: https://lists.gnu.org/r/emacs-devel/2019-07/msg00803.html * doc/lispref/os.texi (Time of Day, Time Conversion): * doc/misc/emacs-mime.texi (time-date): * etc/NEWS: Update documentation. * lisp/calendar/cal-dst.el (calendar-next-time-zone-transition): * lisp/calendar/time-date.el (seconds-to-time, days-to-time): * lisp/calendar/timeclock.el (timeclock-seconds-to-time): * lisp/cedet/ede/detect.el (ede-detect-qtest): * lisp/completion.el (cmpl-hours-since-origin): * lisp/ecomplete.el (ecomplete-add-item): * lisp/emacs-lisp/cl-extra.el (cl--random-time): * lisp/emacs-lisp/timer.el (timer--time-setter) (timer-next-integral-multiple-of-time): * lisp/find-lisp.el (find-lisp-format-time): * lisp/gnus/gnus-diary.el (gnus-user-format-function-d): * lisp/gnus/gnus-group.el (gnus-group-set-timestamp): * lisp/gnus/gnus-icalendar.el (gnus-icalendar-show-org-agenda): * lisp/gnus/nnrss.el (nnrss-normalize-date): * lisp/gnus/nnspool.el (nnspool-request-newgroups): * lisp/net/ntlm.el (ntlm-compute-timestamp): * lisp/net/pop3.el (pop3-uidl-dele): * lisp/obsolete/vc-arch.el (vc-arch-add-tagline): * lisp/org/org-clock.el (org-clock-get-clocked-time) (org-clock-resolve, org-resolve-clocks, org-clock-in) (org-clock-out, org-clock-sum): * lisp/org/org-id.el (org-id-uuid, org-id-time-to-b36): * lisp/org/ox-publish.el (org-publish-cache-ctime-of-src): * lisp/proced.el (proced-format-time): * lisp/progmodes/cc-cmds.el (c-progress-init) (c-progress-update): * lisp/progmodes/cperl-mode.el (cperl-time-fontification): * lisp/progmodes/flymake.el (flymake--schedule-timer-maybe): * lisp/progmodes/vhdl-mode.el (vhdl-update-progress-info) (vhdl-fix-case-region-1): * lisp/tar-mode.el (tar-octal-time): * lisp/time.el (emacs-uptime): * lisp/url/url-auth.el (url-digest-auth-make-cnonce): * lisp/url/url-util.el (url-lazy-message): * lisp/vc/vc-cvs.el (vc-cvs-parse-entry): * lisp/vc/vc-hg.el (vc-hg-state-fast): * lisp/xt-mouse.el (xterm-mouse-event): * test/lisp/emacs-lisp/timer-tests.el: (timer-next-integral-multiple-of-time-2): Use time-convert, not encode-time. * lisp/calendar/icalendar.el (icalendar--decode-isodatetime): Don’t use now-removed FORM argument for encode-time. It wasn’t crucial anyway. * lisp/emacs-lisp/byte-opt.el (side-effect-free-fns): Add time-convert. * lisp/emacs-lisp/elint.el (elint-unknown-builtin-args): Update encode-time signature to match current arg set. * lisp/emacs-lisp/timer.el (timer-next-integral-multiple-of-time): Use timer-convert with t rather than doing it by hand. * src/timefns.c (time_hz_ticks, time_form_stamp, lisp_time_form_stamp): Remove; no longer needed. (decode_lisp_time): Rturn the form instead of having a *PFORM arg. All uses changed. (time_arith): Just return TICKS if HZ is 1. (Fencode_time): Remove argument FORM. All callers changed. Do not attempt to encode time values; just encode decoded (calendrical) times. Unless CURRENT_TIME_LIST, just return VALUE since HZ is 1. (Ftime_convert): New function, which does the time value conversion that bleeding-edge encode-time formerly did. Return TIME if it is easy to see that it is already of the correct form. (Fcurrent_time): Mention in doc that the form is planned to change. * test/src/timefns-tests.el (decode-then-encode-time): Don’t use (encode-time nil).
2019-08-05 17:38:52 -07:00
(fs-mtime (time-convert
(file-attribute-modification-time stat)
'integer)))
Performance improvements for vc-hg Teach vc-hg how to read some Mercurial internal data structures, allowing us to avoid the need to run hg status -A, which is very slow for large repositories. Fall back to running hg if anything looks funny. vc-hg now puts the _working directory_ revision in the modeline instead of the file revision, which greatly improves performance and which allows us to again skip running hg in the case that we have an active bookmark. * lisp/vc/vc-hg.el (vc-hg-state): Try calling `vc-hg-statefast' (vc-hg-symbolic-revision-styles) (vc-hg-use-file-version-for-mode-line-version) (vc-hg-parse-hg-data-structures): New user preferences (vc-hg--active-bookmark-internal, vc-hg--run-log) (vc-hg--symbolic-revision, vc-hg-mode-line-string) (vc-hg--read-u8, vc-hg--read-u32-be) (vc-hg--raw-dirstate-search, vc-hg--cached-dirstate-search) (vc-hg--parts-to-string, vc-hg--pcre-to-elisp-re) (vc-hg--glob-to-pcre, vc-hg--hgignore-add-pcre) (vc-hg--hgignore-add-glob, vc-hg--hgignore-add-path) (vc-hg--slurp-hgignore-1, vc-hg--slurp-hgignore) (vc-hg--ignore-patterns-valid-p) (vc-hg--ignore-patterns-ignored-p, vc-hg--time-to-fixnum) (vc-hg--file-ignored-p, vc-hg--read-repo-requirements) (vc-hg--requirements-understood-p, vc-hg--dirstate-scan-cache) (vc-hg-state-fast): New functions. (vc-hg--hgignore-patterns, vc-hg--hgignore-filenames) (vc-hg--cached-ignore-patterns, vc-hg--dirstate-scan-cache) (vc-hg--dirstate-scan-cache): New internal variables. * lisp/vc/vc-hooks.el (vc-refresh-state): Invoke vc find-file-hook before updating modeline.
2016-02-08 10:52:54 -08:00
(if (and (eql vc-hg-size fs-size) (eql vc-hg-mtime fs-mtime))
'up-to-date
'edited)))
((eq state ?a) 'added)
(state 'unsupported))))))
;;; Miscellaneous
(defun vc-hg-previous-revision (_file rev)
;; We can't simply decrement by 1, because that revision might be
;; e.g. on a different branch (bug#22032).
(with-temp-buffer
(and (eq 0
(vc-hg-command t nil nil "id" "-n" "-r" (concat rev "^")))
;; Trim the trailing newline.
(buffer-substring (point-min) (1- (point-max))))))
2007-06-20 05:59:41 +00:00
(defun vc-hg-next-revision (_file rev)
(let ((newrev (1+ (string-to-number rev)))
(tip-revision
(with-temp-buffer
(vc-hg-command t 0 nil "tip" "--style=default")
(goto-char (point-min))
(re-search-forward "^changeset:[ \t]*\\([0-9]+\\):")
(string-to-number (match-string-no-properties 1)))))
;; We don't want to exceed the maximum possible revision number, ie
;; the tip revision.
(when (<= newrev tip-revision)
(number-to-string newrev))))
2008-06-27 02:41:14 +00:00
;; Modeled after the similar function in vc-bzr.el
(defun vc-hg-delete-file (file)
"Delete FILE and delete it in the hg repository."
(condition-case ()
(delete-file file)
(file-error nil))
(vc-hg-command nil 0 file "remove" "--after" "--force"))
2008-06-27 02:41:14 +00:00
;; Modeled after the similar function in vc-bzr.el
(defun vc-hg-rename-file (old new)
"Rename file from OLD to NEW using `hg mv'."
(vc-hg-command nil 0 (expand-file-name new) "mv"
(expand-file-name old)))
(defun vc-hg-register (files &optional _comment)
"Register FILES under hg. COMMENT is ignored."
(vc-hg-command nil 0 files "add"))
(defun vc-hg-create-repo ()
"Create a new Mercurial repository."
(vc-hg-command nil 0 nil "init"))
(defalias 'vc-hg-responsible-p #'vc-hg-root)
(defun vc-hg-unregister (file)
"Unregister FILE from hg."
(vc-hg-command nil 0 file "forget"))
(declare-function log-edit-extract-headers "log-edit" (headers string))
(declare-function log-edit-mode "log-edit" ())
(declare-function log-edit--toggle-amend "log-edit" (last-msg-fn))
(defun vc-hg-log-edit-toggle-amend ()
"Toggle whether this will amend the previous commit.
If toggling on, also insert its message into the buffer."
(interactive)
(log-edit--toggle-amend
(lambda ()
(with-output-to-string
(vc-hg-command
standard-output 1 nil
"log" "--limit=1" "--template" "{desc}")))))
(defvar-keymap vc-hg-log-edit-mode-map
:name "Hg-Log-Edit"
"C-c C-e" #'vc-hg-log-edit-toggle-amend)
(define-derived-mode vc-hg-log-edit-mode log-edit-mode "Log-Edit/hg"
"Major mode for editing Hg log messages.
It is based on `log-edit-mode', and has Hg-specific extensions.")
(defun vc-hg-checkin (files comment &optional _rev)
"Hg-specific version of `vc-backend-checkin'.
REV is ignored."
(apply #'vc-hg-command nil 0 files
(nconc (list "commit" "-m")
(vc-hg--extract-headers comment))))
(defun vc-hg-checkin-patch (patch-string comment)
(let ((patch-file (make-temp-file "hg-patch")))
(write-region patch-string nil patch-file)
(unwind-protect
(progn
(apply #'vc-hg-command nil 0 nil
(nconc (list "import" "--bypass" patch-file "-m")
(vc-hg--extract-headers comment)))
(vc-hg-command nil 0 nil
"update"
"--merge" "--tool" "internal:local"
"tip"))
(delete-file patch-file))))
(defun vc-hg--extract-headers (comment)
(log-edit-extract-headers `(("Author" . "--user")
("Date" . "--date")
("Amend" . (lambda (value)
(when (equal value "yes")
(list "--amend")))))
comment))
2007-10-10 18:52:45 +00:00
(defun vc-hg-find-revision (file rev buffer)
(let ((coding-system-for-read 'binary)
(coding-system-for-write 'binary))
(if rev
(vc-hg-command buffer 0 file "cat" "-r" rev)
(vc-hg-command buffer 0 file "cat"))))
(defun vc-hg-find-ignore-file (file)
"Return the root directory of the repository of FILE."
(expand-file-name ".hgignore"
(vc-hg-root file)))
2008-06-27 02:41:14 +00:00
;; Modeled after the similar function in vc-bzr.el
(defun vc-hg-checkout (file &optional rev)
"Retrieve a revision of FILE.
EDITABLE is ignored.
REV is the revision to check out into WORKFILE."
(let ((coding-system-for-read 'binary)
(coding-system-for-write 'binary))
(with-current-buffer (or (get-file-buffer file) (current-buffer))
(if rev
(vc-hg-command t 0 file "cat" "-r" rev)
(vc-hg-command t 0 file "cat")))))
(defun vc-hg-resolve-when-done ()
"Call \"hg resolve -m\" if the conflict markers have been removed."
(save-excursion
(goto-char (point-min))
(unless (re-search-forward "^<<<<<<< " nil t)
(vc-hg-command nil 0 buffer-file-name "resolve" "-m")
;; Remove the hook so that it is not called multiple times.
(remove-hook 'after-save-hook #'vc-hg-resolve-when-done t))))
(defun vc-hg-find-file-hook ()
(when (and buffer-file-name
;; Hg does not seem to have a "conflict" status, eg
;; hg http://bz.selenic.com/show_bug.cgi?id=2724
(memq (vc-state buffer-file-name) '(edited conflict))
;; Maybe go on to check that "hg resolve -l" says "U"?
;; If "hg resolve -l" says there's a conflict but there are no
;; conflict markers, it's not clear what we should do.
(save-excursion
(goto-char (point-min))
(re-search-forward "^<<<<<<< " nil t)))
;; Hg may not recognize "conflict" as a state, but we can do better.
(vc-file-setprop buffer-file-name 'vc-state 'conflict)
(smerge-start-session)
(add-hook 'after-save-hook #'vc-hg-resolve-when-done nil t)
(vc-message-unresolved-conflicts buffer-file-name)))
(defun vc-hg-clone (remote directory rev)
(if rev
(vc-hg-command nil 0 '() "clone" "--rev" rev remote directory)
(vc-hg-command nil 0 '() "clone" remote directory))
directory)
2008-06-27 02:41:14 +00:00
;; Modeled after the similar function in vc-bzr.el
(defun vc-hg-revert (file &optional contents-done)
(unless contents-done
(with-temp-buffer
(apply #'vc-hg-command
t 0 file
"revert"
(append (vc-switches 'hg 'revert))))))
;;; Hg specific functionality.
(defvar-keymap vc-hg-extra-menu-map)
(defun vc-hg-extra-menu () vc-hg-extra-menu-map)
(defun vc-hg-extra-status-menu () vc-hg-extra-menu-map)
(defvar log-view-vc-backend)
More CL cleanups and reduction of use of cl.el. * woman.el, winner.el, vc/vc-rcs.el, vc/vc-hooks.el, vc/vc-hg.el: * vc/vc-git.el, vc/vc-dir.el, vc/vc-bzr.el, vc/vc-annotate.el: * textmodes/tex-mode.el, textmodes/sgml-mode.el, tar-mode.el: * strokes.el, ses.el, server.el, progmodes/js.el, progmodes/gdb-mi.el: * progmodes/flymake.el, progmodes/ebrowse.el, progmodes/compile.el: * play/tetris.el, play/snake.el, play/pong.el, play/landmark.el: * play/hanoi.el, play/decipher.el, play/5x5.el, nxml/nxml-mode.el: * net/secrets.el, net/quickurl.el, midnight.el, mail/footnote.el: * image-dired.el, ibuffer.el, ibuf-macs.el, ibuf-ext.el, hexl.el: * eshell/eshell.el, eshell/esh-io.el, eshell/esh-ext.el: * eshell/esh-cmd.el, eshell/em-ls.el, eshell/em-hist.el: * eshell/em-cmpl.el, eshell/em-banner.el: * url/url.el, url/url-queue.el, url/url-parse.el, url/url-http.el: * url/url-future.el, url/url-dav.el, url/url-cookie.el: * calendar/parse-time.el, test/eshell.el: Use cl-lib. * wid-browse.el, wdired.el, vc/vc.el, vc/vc-mtn.el, vc/vc-cvs.el: * vc/vc-arch.el, tree-widget.el, textmodes/texinfo.el: * textmodes/refill.el, textmodes/css-mode.el, term/tvi970.el: * term/ns-win.el, term.el, shell.el, ps-samp.el: * progmodes/perl-mode.el, progmodes/pascal.el, progmodes/gud.el: * progmodes/glasses.el, progmodes/etags.el, progmodes/cwarn.el: * play/gamegrid.el, play/bubbles.el, novice.el, notifications.el: * net/zeroconf.el, net/xesam.el, net/snmp-mode.el, net/mairix.el: * net/ldap.el, net/eudc.el, net/browse-url.el, man.el: * mail/mailheader.el, mail/feedmail.el: * url/url-util.el, url/url-privacy.el, url/url-nfs.el, url/url-misc.el: * url/url-methods.el, url/url-gw.el, url/url-file.el, url/url-expand.el: Dont use CL. * ibuf-ext.el (ibuffer-mark-old-buffers): Use float-time. * eshell/esh-opt.el (eshell-eval-using-options): Quote code with `lambda' rather than with `quote'. (eshell-do-opt): Adjust accordingly. (eshell-process-option): Simplify. * eshell/esh-var.el: * eshell/em-script.el: Require `esh-opt' for eshell-eval-using-options. * emacs-pcase.el (pcase--dontcare-upats, pcase--let*) (pcase--expand, pcase--u1): Rename pcase's internal `dontcare' pattern to `pcase--dontcare'. * emacs-cl.el (labels): Mark obsolete. (cl--letf, letf): Move to cl-lib. (cl--letf*, letf*): Remove. * emacs-cl-lib.el (cl-nth-value): Use defalias. * emacs-cl-macs.el (cl-dolist, cl-dotimes): Add indent rule. (cl-progv): Rewrite. (cl--letf, cl-letf): Move from cl.el. (cl-letf*): New macro. * emacs-cl-extra.el (cl--progv-before, cl--progv-after): Remove.
2012-07-11 19:13:41 -04:00
(cl-defstruct (vc-hg-extra-fileinfo
(:copier nil)
(:constructor vc-hg-create-extra-fileinfo (rename-state extra-name))
(:conc-name vc-hg-extra-fileinfo->))
rename-state ;; rename or copy state
extra-name) ;; original name for copies and rename targets, new name for
(declare-function vc-default-dir-printer "vc-dir" (backend fileentry))
(defun vc-hg-dir-printer (info)
"Pretty-printer for the vc-dir-fileinfo structure."
(let ((extra (vc-dir-fileinfo->extra info)))
(vc-default-dir-printer 'Hg info)
(when extra
(insert (propertize
(format " (%s %s)"
More CL cleanups and reduction of use of cl.el. * woman.el, winner.el, vc/vc-rcs.el, vc/vc-hooks.el, vc/vc-hg.el: * vc/vc-git.el, vc/vc-dir.el, vc/vc-bzr.el, vc/vc-annotate.el: * textmodes/tex-mode.el, textmodes/sgml-mode.el, tar-mode.el: * strokes.el, ses.el, server.el, progmodes/js.el, progmodes/gdb-mi.el: * progmodes/flymake.el, progmodes/ebrowse.el, progmodes/compile.el: * play/tetris.el, play/snake.el, play/pong.el, play/landmark.el: * play/hanoi.el, play/decipher.el, play/5x5.el, nxml/nxml-mode.el: * net/secrets.el, net/quickurl.el, midnight.el, mail/footnote.el: * image-dired.el, ibuffer.el, ibuf-macs.el, ibuf-ext.el, hexl.el: * eshell/eshell.el, eshell/esh-io.el, eshell/esh-ext.el: * eshell/esh-cmd.el, eshell/em-ls.el, eshell/em-hist.el: * eshell/em-cmpl.el, eshell/em-banner.el: * url/url.el, url/url-queue.el, url/url-parse.el, url/url-http.el: * url/url-future.el, url/url-dav.el, url/url-cookie.el: * calendar/parse-time.el, test/eshell.el: Use cl-lib. * wid-browse.el, wdired.el, vc/vc.el, vc/vc-mtn.el, vc/vc-cvs.el: * vc/vc-arch.el, tree-widget.el, textmodes/texinfo.el: * textmodes/refill.el, textmodes/css-mode.el, term/tvi970.el: * term/ns-win.el, term.el, shell.el, ps-samp.el: * progmodes/perl-mode.el, progmodes/pascal.el, progmodes/gud.el: * progmodes/glasses.el, progmodes/etags.el, progmodes/cwarn.el: * play/gamegrid.el, play/bubbles.el, novice.el, notifications.el: * net/zeroconf.el, net/xesam.el, net/snmp-mode.el, net/mairix.el: * net/ldap.el, net/eudc.el, net/browse-url.el, man.el: * mail/mailheader.el, mail/feedmail.el: * url/url-util.el, url/url-privacy.el, url/url-nfs.el, url/url-misc.el: * url/url-methods.el, url/url-gw.el, url/url-file.el, url/url-expand.el: Dont use CL. * ibuf-ext.el (ibuffer-mark-old-buffers): Use float-time. * eshell/esh-opt.el (eshell-eval-using-options): Quote code with `lambda' rather than with `quote'. (eshell-do-opt): Adjust accordingly. (eshell-process-option): Simplify. * eshell/esh-var.el: * eshell/em-script.el: Require `esh-opt' for eshell-eval-using-options. * emacs-pcase.el (pcase--dontcare-upats, pcase--let*) (pcase--expand, pcase--u1): Rename pcase's internal `dontcare' pattern to `pcase--dontcare'. * emacs-cl.el (labels): Mark obsolete. (cl--letf, letf): Move to cl-lib. (cl--letf*, letf*): Remove. * emacs-cl-lib.el (cl-nth-value): Use defalias. * emacs-cl-macs.el (cl-dolist, cl-dotimes): Add indent rule. (cl-progv): Rewrite. (cl--letf, cl-letf): Move from cl.el. (cl-letf*): New macro. * emacs-cl-extra.el (cl--progv-before, cl--progv-after): Remove.
2012-07-11 19:13:41 -04:00
(pcase (vc-hg-extra-fileinfo->rename-state extra)
Replace insignificant backquotes Replace most insignificant occurrences of '`' with a straight quote, sharp quote or nothing. This includes backquotes in 'pcase' patterns. * admin/admin.el: * lisp/apropos.el: * lisp/arc-mode.el: * lisp/auth-source.el: * lisp/avoid.el: * lisp/bindings.el: * lisp/bs.el: * lisp/calculator.el: * lisp/calendar/todo-mode.el: * lisp/cedet/semantic.el: * lisp/cedet/semantic/analyze/debug.el: * lisp/cedet/semantic/bovine.el: * lisp/cedet/semantic/dep.el: * lisp/cedet/semantic/grammar.el: * lisp/cedet/semantic/wisent/comp.el: * lisp/cedet/semantic/wisent/grammar.el: * lisp/cedet/srecode/mode.el: * lisp/cus-edit.el: * lisp/doc-view.el: * lisp/elec-pair.el: * lisp/electric.el: * lisp/emacs-lisp/autoload.el: * lisp/emacs-lisp/benchmark.el: * lisp/emacs-lisp/byte-opt.el: * lisp/emacs-lisp/bytecomp.el: * lisp/emacs-lisp/cconv.el: * lisp/emacs-lisp/cl-extra.el: * lisp/emacs-lisp/cl-generic.el: * lisp/emacs-lisp/cl-macs.el: * lisp/emacs-lisp/copyright.el: * lisp/emacs-lisp/debug.el: * lisp/emacs-lisp/eieio-compat.el: * lisp/emacs-lisp/ert.el: * lisp/emacs-lisp/generator.el: * lisp/emacs-lisp/inline.el: * lisp/emacs-lisp/macroexp.el: * lisp/emacs-lisp/map.el: * lisp/emacs-lisp/package-x.el: * lisp/emacs-lisp/package.el: * lisp/emacs-lisp/radix-tree.el: * lisp/emacs-lisp/smie.el: * lisp/epa.el: * lisp/erc/erc-dcc.el: * lisp/erc/erc-track.el: * lisp/erc/erc.el: * lisp/eshell/em-ls.el: * lisp/eshell/esh-cmd.el: * lisp/files.el: * lisp/filesets.el: * lisp/font-lock.el: * lisp/frameset.el: * lisp/gnus/gnus-agent.el: * lisp/gnus/gnus-art.el: * lisp/gnus/gnus-cite.el: * lisp/gnus/gnus-group.el: * lisp/gnus/gnus-msg.el: * lisp/gnus/gnus-salt.el: * lisp/gnus/gnus-srvr.el: * lisp/gnus/gnus-sum.el: * lisp/gnus/gnus-topic.el: * lisp/gnus/gnus-util.el: * lisp/gnus/gnus.el: * lisp/gnus/message.el: * lisp/gnus/mm-util.el: * lisp/gnus/mml.el: * lisp/gnus/nnheader.el: * lisp/gnus/nnimap.el: * lisp/gnus/nnmairix.el: * lisp/gnus/spam.el: * lisp/hexl.el: * lisp/hi-lock.el: * lisp/ibuf-ext.el: * lisp/ibuffer.el: * lisp/ido.el: * lisp/info.el: * lisp/international/mule-cmds.el: * lisp/international/mule-util.el: * lisp/json.el: * lisp/jsonrpc.el: * lisp/language/cyrillic.el: * lisp/language/european.el: * lisp/language/georgian.el: * lisp/language/tibetan.el: * lisp/language/utf-8-lang.el: * lisp/language/vietnamese.el: * lisp/ldefs-boot.el: * lisp/mail/mail-extr.el: * lisp/man.el: * lisp/menu-bar.el: * lisp/mh-e/mh-acros.el: * lisp/mh-e/mh-folder.el: * lisp/mh-e/mh-mime.el: * lisp/mh-e/mh-show.el: * lisp/mh-e/mh-speed.el: * lisp/minibuffer.el: * lisp/mpc.el: * lisp/net/ange-ftp.el: * lisp/net/hmac-def.el: * lisp/net/newst-backend.el: * lisp/net/quickurl.el: * lisp/net/tramp-archive.el: * lisp/net/tramp-compat.el: * lisp/notifications.el: * lisp/obsolete/pgg-parse.el: * lisp/obsolete/vc-arch.el: * lisp/obsolete/xesam.el: * lisp/org/ob-C.el: * lisp/org/ob-core.el: * lisp/org/ob-exp.el: * lisp/org/ob-groovy.el: * lisp/org/ob-haskell.el: * lisp/org/ob-io.el: * lisp/org/ob-lisp.el: * lisp/org/ob-lob.el: * lisp/org/ob-lua.el: * lisp/org/ob-octave.el: * lisp/org/ob-perl.el: * lisp/org/ob-python.el: * lisp/org/ob-ref.el: * lisp/org/ob-ruby.el: * lisp/org/ob-sql.el: * lisp/org/org-agenda.el: * lisp/org/org-capture.el: * lisp/org/org-clock.el: * lisp/org/org-colview.el: * lisp/org/org-duration.el: * lisp/org/org-element.el: * lisp/org/org-entities.el: * lisp/org/org-gnus.el: * lisp/org/org-indent.el: * lisp/org/org-info.el: * lisp/org/org-inlinetask.el: * lisp/org/org-lint.el: * lisp/org/org-list.el: * lisp/org/org-mouse.el: * lisp/org/org-plot.el: * lisp/org/org-src.el: * lisp/org/org-table.el: * lisp/org/org.el: * lisp/org/ox-ascii.el: * lisp/org/ox-html.el: * lisp/org/ox-latex.el: * lisp/org/ox-man.el: * lisp/org/ox-md.el: * lisp/org/ox-org.el: * lisp/org/ox-publish.el: * lisp/org/ox-texinfo.el: * lisp/org/ox.el: * lisp/play/bubbles.el: * lisp/play/gamegrid.el: * lisp/progmodes/autoconf.el: * lisp/progmodes/cc-defs.el: * lisp/progmodes/cc-engine.el: * lisp/progmodes/cc-fonts.el: * lisp/progmodes/cc-langs.el: * lisp/progmodes/cperl-mode.el: * lisp/progmodes/ebrowse.el: * lisp/progmodes/elisp-mode.el: * lisp/progmodes/flymake-cc.el: * lisp/progmodes/flymake.el: * lisp/progmodes/fortran.el: * lisp/progmodes/grep.el: * lisp/progmodes/gud.el: * lisp/progmodes/idlwave.el: * lisp/progmodes/js.el: * lisp/progmodes/m4-mode.el: * lisp/progmodes/make-mode.el: * lisp/progmodes/mixal-mode.el: * lisp/progmodes/modula2.el: * lisp/progmodes/octave.el: * lisp/progmodes/opascal.el: * lisp/progmodes/prolog.el: * lisp/progmodes/ps-mode.el: * lisp/progmodes/python.el: * lisp/progmodes/ruby-mode.el: * lisp/progmodes/sh-script.el: * lisp/progmodes/sql.el: * lisp/progmodes/verilog-mode.el: * lisp/ps-mule.el: * lisp/rtree.el: * lisp/ruler-mode.el: * lisp/ses.el: * lisp/simple.el: * lisp/startup.el: * lisp/subr.el: * lisp/term/ns-win.el: * lisp/textmodes/bibtex.el: * lisp/textmodes/conf-mode.el: * lisp/textmodes/css-mode.el: * lisp/textmodes/refill.el: * lisp/textmodes/sgml-mode.el: * lisp/textmodes/tex-mode.el: * lisp/tutorial.el: * lisp/url/url-dav.el: * lisp/url/url-gw.el: * lisp/url/url-http.el: * lisp/url/url-methods.el: * lisp/url/url-privacy.el: * lisp/vc/cvs-status.el: * lisp/vc/diff-mode.el: * lisp/vc/ediff-init.el: * lisp/vc/ediff-ptch.el: * lisp/vc/log-edit.el: * lisp/vc/log-view.el: * lisp/vc/pcvs-info.el: * lisp/vc/pcvs.el: * lisp/vc/smerge-mode.el: * lisp/vc/vc-git.el: * lisp/vc/vc-hg.el: * lisp/vc/vc-mtn.el: * lisp/vc/vc-rcs.el: * lisp/whitespace.el: * lisp/window.el: * test/lisp/electric-tests.el: * test/lisp/emacs-lisp/cl-lib-tests.el: * test/lisp/emacs-lisp/ert-tests.el: * test/lisp/epg-tests.el: * test/lisp/jsonrpc-tests.el: * test/src/data-tests.el: * test/src/json-tests.el: Replace most insignificant backquotes.
2018-11-05 01:22:15 +01:00
('copied "copied from")
('renamed-from "renamed from")
('renamed-to "renamed to"))
(vc-hg-extra-fileinfo->extra-name extra))
'face 'font-lock-comment-face)))))
(defun vc-hg-after-dir-status (update-function)
(let ((file nil)
(translation '((?= . up-to-date)
(?C . up-to-date)
(?A . added)
(?R . removed)
(?M . edited)
(?I . ignored)
(?! . missing)
(? . copy-rename-line)
(?? . unregistered)))
(translated nil)
(result nil)
(last-added nil)
(last-line-copy nil))
(goto-char (point-min))
(while (not (eobp))
(setq translated (cdr (assoc (char-after) translation)))
(setq file
(buffer-substring-no-properties (+ (point) 2)
(line-end-position)))
(cond ((not translated)
(setq last-line-copy nil))
((eq translated 'up-to-date)
(setq last-line-copy nil))
((eq translated 'copy-rename-line)
;; For copied files the output looks like this:
;; A COPIED_FILE_NAME
;; ORIGINAL_FILE_NAME
(setf (nth 2 last-added)
(vc-hg-create-extra-fileinfo 'copied file))
(setq last-line-copy t))
((and last-line-copy (eq translated 'removed))
;; For renamed files the output looks like this:
;; A NEW_FILE_NAME
;; ORIGINAL_FILE_NAME
;; R ORIGINAL_FILE_NAME
;; We need to adjust the previous entry to not think it is a copy.
(setf (vc-hg-extra-fileinfo->rename-state (nth 2 last-added))
'renamed-from)
(push (list file translated
(vc-hg-create-extra-fileinfo
'renamed-to (nth 0 last-added))) result)
(setq last-line-copy nil))
(t
(setq last-added (list file translated nil))
(push last-added result)
(setq last-line-copy nil)))
(forward-line))
(funcall update-function result)))
;; Follows vc-hg-command (or vc-do-async-command), which uses vc-do-command
;; from vc-dispatcher.
(declare-function vc-exec-after "vc-dispatcher" (code &optional success))
;; Follows vc-exec-after.
(declare-function vc-set-async-update "vc-dispatcher" (process-buffer))
(defun vc-hg-dir-status-files (dir files update-function)
;; XXX: We can't pass DIR directly to 'hg status' because that
;; returns all ignored files if FILES is non-nil (bug#22481).
(let ((default-directory dir))
2020-02-12 00:19:25 +02:00
;; TODO: Use "--config 'status.relative=1'" instead of "re:"
;; when we're allowed to depend on Mercurial 4.2+
;; (it's a bit faster).
(vc-hg-command (current-buffer) 'async files
"status" "re:" "-I" "."
(concat "-mardu" (if files "i"))
"-C"))
(vc-run-delayed
(vc-hg-after-dir-status update-function)))
(defun vc-hg-dir-extra-headers (dir)
"Generate extra status headers for a repository in DIR.
This runs the command \"hg summary\"."
(let ((default-directory dir))
(with-temp-buffer
(vc-hg-command t 0 nil "summary")
(goto-char (point-min))
(mapconcat
#'identity
(let (result)
(while (not (eobp))
(push
(let ((entry (if (looking-at "\\([^ ].*\\): \\(.*\\)")
(cons (capitalize (match-string 1)) (match-string 2))
(cons "" (buffer-substring (point) (line-end-position))))))
(concat
(propertize (format "%-11s: " (car entry)) 'face 'vc-dir-header)
(propertize (cdr entry) 'face 'vc-dir-header-value)))
result)
(forward-line))
(nreverse result))
"\n"))))
(defun vc-hg-log-incoming (buffer remote-location)
(vc-setup-buffer buffer)
(vc-hg-command buffer 1 nil "incoming" "-n" (unless (string= remote-location "")
remote-location)))
(defun vc-hg-log-outgoing (buffer remote-location)
(vc-setup-buffer buffer)
(vc-hg-command buffer 1 nil "outgoing" "-n" (unless (string= remote-location "")
remote-location)))
(defvar vc-hg-error-regexp-alist
'(("^M \\(.+\\)" 1 nil nil 0))
"Value of `compilation-error-regexp-alist' in *vc-hg* buffers.")
(autoload 'vc-do-async-command "vc-dispatcher")
(autoload 'log-view-get-marked "log-view")
(defvar compilation-directory)
(defvar compilation-arguments) ; defined in compile.el
(defun vc-hg--pushpull (command prompt post-processing &optional obsolete)
"Run COMMAND (a string; either push or pull) on the current Hg branch.
If PROMPT is non-nil, prompt for the Hg command to run.
POST-PROCESSING is a list of commands to execute after the command.
If OBSOLETE is non-nil, behave like the old versions of the Hg push/pull
commands, which only operated on marked files."
(let (marked-list)
;; The `vc-hg-pull' and `vc-hg-push' commands existed before the
;; `pull'/`push' VC actions were implemented.
;; The following is for backwards compatibility.
(if (and obsolete (setq marked-list (log-view-get-marked)))
(apply #'vc-hg-command
nil 0 nil
command
(apply #'nconc
(mapcar (lambda (arg) (list "-r" arg)) marked-list)))
(let* ((root (vc-hg-root default-directory))
(buffer (format "*vc-hg : %s*" (expand-file-name root)))
;; Disable pager.
(process-environment (cons "HGPLAIN=1" process-environment))
(hg-program vc-hg-program)
args)
;; If necessary, prompt for the exact command.
;; TODO if pushing, prompt if no default push location - cf bzr.
(when prompt
(setq args (split-string
(read-shell-command
(format "Hg %s command: " command)
(format "%s %s" hg-program command)
'vc-hg-history)
" " t))
(setq hg-program (car args)
command (cadr args)
args (cddr args)))
(apply #'vc-do-async-command buffer root hg-program command args)
(with-current-buffer buffer
(vc-run-delayed
(dolist (cmd post-processing)
(apply #'vc-do-command buffer nil hg-program nil cmd))
(vc-compilation-mode 'hg)
(setq-local compile-command
(concat hg-program " " command " "
(mapconcat #'identity args " ")
(mapconcat (lambda (args)
(concat " && " hg-program " "
(mapconcat #'identity
args " ")))
post-processing "")))
(setq-local compilation-directory root)
;; Either set `compilation-buffer-name-function' locally to nil
;; or use `compilation-arguments' to set `name-function'.
;; See `compilation-buffer-name'.
(setq-local compilation-arguments
(list compile-command nil
(lambda (_name-of-mode) buffer)
nil))))
(vc-set-async-update buffer)))))
(defun vc-hg-pull (prompt)
"Issue a Mercurial pull command.
If called interactively with a set of marked Log View buffers,
call \"hg pull -r REVS\" to pull in the specified revisions REVS.
With a prefix argument or if PROMPT is non-nil, prompt for a
specific Mercurial pull command. The default is \"hg pull -u\",
which fetches changesets from the default remote repository and
then attempts to update the working directory."
(interactive "P")
(vc-hg--pushpull "pull" prompt
;; Fixme: before updating the working copy to the latest
;; state, should check if it's visiting an old revision.
;; post-processing: list modified files and update
;; NB: this will not work with "pull = --rebase"
;; or "pull = --update" in hgrc.
'(("--pager" "no" "status" "--rev" "." "--rev" "tip")
("update"))
(called-interactively-p 'interactive)))
(defun vc-hg-push (prompt)
"Push changes from the current Mercurial branch.
Normally, this runs \"hg push\". If PROMPT is non-nil, prompt
for the Hg command to run.
If called interactively with a set of marked Log View buffers,
call \"hg push -r REVS\" to push the specified revisions REVS."
(interactive "P")
(vc-hg--pushpull "push" prompt nil (called-interactively-p 'interactive)))
(defun vc-hg-merge-branch ()
"Prompt for revision and merge it into working directory.
This runs the command \"hg merge\"."
(let* ((root (vc-hg-root default-directory))
(buffer (format "*vc-hg : %s*" (expand-file-name root)))
;; Disable pager.
(process-environment (cons "HGPLAIN=1" process-environment))
(branch (vc-read-revision "Revision to merge: ")))
(apply #'vc-do-async-command buffer root vc-hg-program
(append '("--config" "ui.report_untrusted=0" "merge")
(unless (string= branch "") (list branch))))
(with-current-buffer buffer (vc-run-delayed (vc-compilation-mode 'hg)))
(vc-set-async-update buffer)))
(defun vc-hg-prepare-patch (rev)
(with-current-buffer (generate-new-buffer " *vc-hg-prepare-patch*")
(vc-hg-command t 0 '() "export" "--rev" rev)
(let (subject)
;; Extract the subject line
(goto-char (point-min))
(search-forward-regexp "^[^#].*")
(setq subject (match-string 0))
;; Return the extracted data
(list :subject subject :buffer (current-buffer)))))
2007-06-20 05:59:41 +00:00
;;; Internal functions
(defun vc-hg-command (buffer okstatus file-or-list &rest flags)
2007-06-20 05:59:41 +00:00
"A wrapper around `vc-do-command' for use in vc-hg.el.
This function differs from vc-do-command in that it invokes
`vc-hg-program', and passes `vc-hg-global-switches' to it before FLAGS."
;; Disable pager.
(let ((process-environment (cons "HGPLAIN=1" process-environment))
(flags (append '("--config" "ui.report_untrusted=0") flags)))
(apply #'vc-do-command (or buffer "*vc*")
okstatus vc-hg-program file-or-list
(if (stringp vc-hg-global-switches)
(cons vc-hg-global-switches flags)
(append vc-hg-global-switches
flags)))))
2007-06-20 05:59:41 +00:00
(defun vc-hg-root (file)
(vc-find-root file ".hg"))
(defun vc-hg-repository-url (file-or-dir &optional remote-name)
(let ((default-directory (vc-hg-root file-or-dir)))
(with-temp-buffer
(vc-hg-command (current-buffer) 0 nil
"config"
(concat "paths." (or remote-name "default")))
(buffer-substring-no-properties (point-min) (1- (point-max))))))
2007-06-20 05:59:41 +00:00
(provide 'vc-hg)
;;; vc-hg.el ends here