aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl Heuer1996-01-24 23:32:49 +0000
committerKarl Heuer1996-01-24 23:32:49 +0000
commitf008ca5831aaae7cd2947b0ff2cab11f57dde178 (patch)
tree57930a7d077fc68f657d46f35384fbb373b5ebf8
parenta538e583cabbee47bba3e650e3fb795b65bad200 (diff)
downloademacs-f008ca5831aaae7cd2947b0ff2cab11f57dde178.tar.gz
emacs-f008ca5831aaae7cd2947b0ff2cab11f57dde178.zip
* vc.el (vc-backend-checkout): Use let to restore default-directory.
(vc-next-action-dired): Likewise.
-rw-r--r--lisp/vc.el284
1 files changed, 144 insertions, 140 deletions
diff --git a/lisp/vc.el b/lisp/vc.el
index e03f5fdeba5..ca4b70bd4de 100644
--- a/lisp/vc.el
+++ b/lisp/vc.el
@@ -711,7 +711,8 @@ to an optional list of FLAGS."
711 (dired-buffer (current-buffer)) 711 (dired-buffer (current-buffer))
712 (dired-dir default-directory)) 712 (dired-dir default-directory))
713 (dired-map-over-marks 713 (dired-map-over-marks
714 (let ((file (dired-get-filename)) p) 714 (let ((file (dired-get-filename)) p
715 (default-directory default-directory))
715 (message "Processing %s..." file) 716 (message "Processing %s..." file)
716 ;; Adjust the default directory so that checkouts 717 ;; Adjust the default directory so that checkouts
717 ;; go to the right place. 718 ;; go to the right place.
@@ -1851,7 +1852,6 @@ From a program, any arguments are passed to the `rcs2log' script."
1851 ;; Retrieve a copy of a saved version into a workfile 1852 ;; Retrieve a copy of a saved version into a workfile
1852 (let ((filename (or workfile file)) 1853 (let ((filename (or workfile file))
1853 (file-buffer (get-file-buffer file)) 1854 (file-buffer (get-file-buffer file))
1854 (old-default-dir default-directory)
1855 switches) 1855 switches)
1856 (message "Checking out %s..." filename) 1856 (message "Checking out %s..." filename)
1857 (save-excursion 1857 (save-excursion
@@ -1860,148 +1860,152 @@ From a program, any arguments are passed to the `rcs2log' script."
1860 (setq switches (if (stringp vc-checkout-switches) 1860 (setq switches (if (stringp vc-checkout-switches)
1861 (list vc-checkout-switches) 1861 (list vc-checkout-switches)
1862 vc-checkout-switches)) 1862 vc-checkout-switches))
1863 ;; Adjust the default-directory so that the check-out creates 1863 ;; Save this buffer's default-directory
1864 ;; the file in the right place. The old value is restored below. 1864 ;; and use save-excursion to make sure it is restored
1865 (setq default-directory (file-name-directory filename)) 1865 ;; in the same buffer it was saved in.
1866 (vc-backend-dispatch file 1866 (let ((default-directory default-directory))
1867 (progn ;; SCCS 1867 (save-excursion
1868 (and rev (string= rev "") (setq rev nil)) 1868 ;; Adjust the default-directory so that the check-out creates
1869 (if workfile 1869 ;; the file in the right place.
1870 ;; Some SCCS implementations allow checking out directly to a 1870 (setq default-directory (file-name-directory filename))
1871 ;; file using the -G option, but then some don't so use the 1871 (vc-backend-dispatch file
1872 ;; least common denominator approach and use the -p option 1872 (progn ;; SCCS
1873 ;; ala RCS. 1873 (and rev (string= rev "") (setq rev nil))
1874 (let ((vc-modes (logior (file-modes (vc-name file)) 1874 (if workfile
1875 (if writable 128 0))) 1875 ;; Some SCCS implementations allow checking out directly to a
1876 (failed t)) 1876 ;; file using the -G option, but then some don't so use the
1877 (unwind-protect 1877 ;; least common denominator approach and use the -p option
1878 (progn 1878 ;; ala RCS.
1879 (apply 'vc-do-command 1879 (let ((vc-modes (logior (file-modes (vc-name file))
1880 nil 0 "/bin/sh" file 'MASTER "-c" 1880 (if writable 128 0)))
1881 ;; Some shells make the "" dummy argument into $0 1881 (failed t))
1882 ;; while others use the shell's name as $0 and 1882 (unwind-protect
1883 ;; use the "" as $1. The if-statement 1883 (progn
1884 ;; converts the latter case to the former. 1884 (apply 'vc-do-command
1885 (format "if [ x\"$1\" = x ]; then shift; fi; \ 1885 nil 0 "/bin/sh" file 'MASTER "-c"
1886 ;; Some shells make the "" dummy argument into $0
1887 ;; while others use the shell's name as $0 and
1888 ;; use the "" as $1. The if-statement
1889 ;; converts the latter case to the former.
1890 (format "if [ x\"$1\" = x ]; then shift; fi; \
1886 umask %o; exec >\"$1\" || exit; \ 1891 umask %o; exec >\"$1\" || exit; \
1887 shift; umask %o; exec get \"$@\"" 1892 shift; umask %o; exec get \"$@\""
1888 (logand 511 (lognot vc-modes)) 1893 (logand 511 (lognot vc-modes))
1889 (logand 511 (lognot (default-file-modes)))) 1894 (logand 511 (lognot (default-file-modes))))
1890 "" ; dummy argument for shell's $0 1895 "" ; dummy argument for shell's $0
1891 filename 1896 filename
1892 (if writable "-e") 1897 (if writable "-e")
1893 "-p" 1898 "-p"
1894 (and rev 1899 (and rev
1895 (concat "-r" (vc-lookup-triple file rev))) 1900 (concat "-r" (vc-lookup-triple file rev)))
1896 switches) 1901 switches)
1897 (setq failed nil)) 1902 (setq failed nil))
1898 (and failed (file-exists-p filename) 1903 (and failed (file-exists-p filename)
1899 (delete-file filename)))) 1904 (delete-file filename))))
1900 (apply 'vc-do-command nil 0 "get" file 'MASTER ;; SCCS 1905 (apply 'vc-do-command nil 0 "get" file 'MASTER ;; SCCS
1901 (if writable "-e") 1906 (if writable "-e")
1902 (and rev (concat "-r" (vc-lookup-triple file rev))) 1907 (and rev (concat "-r" (vc-lookup-triple file rev)))
1903 switches) 1908 switches)
1904 (vc-file-setprop file 'vc-workfile-version nil))) 1909 (vc-file-setprop file 'vc-workfile-version nil)))
1905 (if workfile ;; RCS 1910 (if workfile ;; RCS
1906 ;; RCS doesn't let us check out into arbitrary file names directly. 1911 ;; RCS doesn't let us check out into arbitrary file names directly.
1907 ;; Use `co -p' and make stdout point to the correct file. 1912 ;; Use `co -p' and make stdout point to the correct file.
1908 (let ((vc-modes (logior (file-modes (vc-name file)) 1913 (let ((vc-modes (logior (file-modes (vc-name file))
1909 (if writable 128 0))) 1914 (if writable 128 0)))
1910 (failed t)) 1915 (failed t))
1911 (unwind-protect 1916 (unwind-protect
1912 (progn 1917 (progn
1913 (apply 'vc-do-command 1918 (apply 'vc-do-command
1914 nil 0 "/bin/sh" file 'MASTER "-c" 1919 nil 0 "/bin/sh" file 'MASTER "-c"
1915 ;; See the SCCS case, above, regarding the 1920 ;; See the SCCS case, above, regarding the
1916 ;; if-statement. 1921 ;; if-statement.
1917 (format "if [ x\"$1\" = x ]; then shift; fi; \ 1922 (format "if [ x\"$1\" = x ]; then shift; fi; \
1918 umask %o; exec >\"$1\" || exit; \ 1923 umask %o; exec >\"$1\" || exit; \
1919 shift; umask %o; exec co \"$@\"" 1924 shift; umask %o; exec co \"$@\""
1920 (logand 511 (lognot vc-modes)) 1925 (logand 511 (lognot vc-modes))
1921 (logand 511 (lognot (default-file-modes)))) 1926 (logand 511 (lognot (default-file-modes))))
1922 "" ; dummy argument for shell's $0 1927 "" ; dummy argument for shell's $0
1923 filename 1928 filename
1924 (if writable "-l") 1929 (if writable "-l")
1925 (concat "-p" rev) 1930 (concat "-p" rev)
1926 switches) 1931 switches)
1927 (setq failed nil)) 1932 (setq failed nil))
1928 (and failed (file-exists-p filename) (delete-file filename)))) 1933 (and failed (file-exists-p filename) (delete-file filename))))
1929 (let (new-version) 1934 (let (new-version)
1930 ;; if we should go to the head of the trunk, 1935 ;; if we should go to the head of the trunk,
1931 ;; clear the default branch first 1936 ;; clear the default branch first
1932 (and rev (string= rev "") 1937 (and rev (string= rev "")
1933 (vc-do-command nil 0 "rcs" file 'MASTER "-b")) 1938 (vc-do-command nil 0 "rcs" file 'MASTER "-b"))
1934 ;; now do the checkout 1939 ;; now do the checkout
1935 (apply 'vc-do-command 1940 (apply 'vc-do-command
1936 nil 0 "co" file 'MASTER 1941 nil 0 "co" file 'MASTER
1937 ;; If locking is not strict, force to overwrite 1942 ;; If locking is not strict, force to overwrite
1938 ;; the writable workfile. 1943 ;; the writable workfile.
1939 (if (eq (vc-checkout-model file) 'implicit) "-f") 1944 (if (eq (vc-checkout-model file) 'implicit) "-f")
1940 (if writable "-l") 1945 (if writable "-l")
1941 (if rev (concat "-r" rev) 1946 (if rev (concat "-r" rev)
1942 ;; if no explicit revision was specified, 1947 ;; if no explicit revision was specified,
1943 ;; check out that of the working file 1948 ;; check out that of the working file
1944 (let ((workrev (vc-workfile-version file))) 1949 (let ((workrev (vc-workfile-version file)))
1945 (if workrev (concat "-r" workrev) 1950 (if workrev (concat "-r" workrev)
1946 nil))) 1951 nil)))
1947 switches) 1952 switches)
1948 ;; determine the new workfile version 1953 ;; determine the new workfile version
1949 (save-excursion 1954 (save-excursion
1950 (set-buffer "*vc*") 1955 (set-buffer "*vc*")
1951 (goto-char (point-min)) 1956 (goto-char (point-min))
1952 (setq new-version 1957 (setq new-version
1953 (if (re-search-forward "^revision \\([0-9.]+\\).*\n" nil t) 1958 (if (re-search-forward "^revision \\([0-9.]+\\).*\n" nil t)
1954 (buffer-substring (match-beginning 1) (match-end 1))))) 1959 (buffer-substring (match-beginning 1) (match-end 1)))))
1955 (vc-file-setprop file 'vc-workfile-version new-version) 1960 (vc-file-setprop file 'vc-workfile-version new-version)
1956 ;; if necessary, adjust the default branch 1961 ;; if necessary, adjust the default branch
1957 (and rev (not (string= rev "")) 1962 (and rev (not (string= rev ""))
1958 (vc-do-command nil 0 "rcs" file 'MASTER 1963 (vc-do-command nil 0 "rcs" file 'MASTER
1959 (concat "-b" (if (vc-latest-on-branch-p file) 1964 (concat "-b" (if (vc-latest-on-branch-p file)
1960 (if (vc-trunk-p new-version) nil 1965 (if (vc-trunk-p new-version) nil
1961 (vc-branch-part new-version)) 1966 (vc-branch-part new-version))
1962 new-version)))))) 1967 new-version))))))
1963 (if workfile ;; CVS 1968 (if workfile ;; CVS
1964 ;; CVS is much like RCS 1969 ;; CVS is much like RCS
1965 (let ((failed t)) 1970 (let ((failed t))
1966 (unwind-protect 1971 (unwind-protect
1967 (progn 1972 (progn
1968 (apply 'vc-do-command 1973 (apply 'vc-do-command
1969 nil 0 "/bin/sh" file 'WORKFILE "-c" 1974 nil 0 "/bin/sh" file 'WORKFILE "-c"
1970 "exec >\"$1\" || exit; shift; exec cvs update \"$@\"" 1975 "exec >\"$1\" || exit; shift; exec cvs update \"$@\""
1971 "" ; dummy argument for shell's $0 1976 "" ; dummy argument for shell's $0
1972 workfile 1977 workfile
1973 (concat "-r" rev) 1978 (concat "-r" rev)
1974 "-p" 1979 "-p"
1975 switches) 1980 switches)
1976 (setq failed nil)) 1981 (setq failed nil))
1977 (and failed (file-exists-p filename) (delete-file filename)))) 1982 (and failed (file-exists-p filename) (delete-file filename))))
1978 ;; default for verbose checkout: clear the sticky tag 1983 ;; default for verbose checkout: clear the sticky tag
1979 ;; so that the actual update will get the head of the trunk 1984 ;; so that the actual update will get the head of the trunk
1980 (and rev (string= rev "") 1985 (and rev (string= rev "")
1981 (vc-do-command nil 0 "cvs" file 'WORKFILE "update" "-A")) 1986 (vc-do-command nil 0 "cvs" file 'WORKFILE "update" "-A"))
1982 ;; If a revision was specified, check that out. 1987 ;; If a revision was specified, check that out.
1983 (if rev 1988 (if rev
1984 (apply 'vc-do-command nil 0 "cvs" file 'WORKFILE 1989 (apply 'vc-do-command nil 0 "cvs" file 'WORKFILE
1985 (and writable (eq (vc-checkout-model file) 'manual) "-w") 1990 (and writable (eq (vc-checkout-model file) 'manual) "-w")
1986 "update" 1991 "update"
1987 (and rev (not (string= rev "")) 1992 (and rev (not (string= rev ""))
1988 (concat "-r" rev)) 1993 (concat "-r" rev))
1989 switches) 1994 switches)
1990 ;; If no revision was specified, simply make the file writable. 1995 ;; If no revision was specified, simply make the file writable.
1991 (and writable 1996 (and writable
1992 (or (eq (vc-checkout-model file) 'manual) 1997 (or (eq (vc-checkout-model file) 'manual)
1993 (zerop (logand 128 (file-modes file)))) 1998 (zerop (logand 128 (file-modes file))))
1994 (set-file-modes file (logior 128 (file-modes file))))) 1999 (set-file-modes file (logior 128 (file-modes file)))))
1995 (if rev (vc-file-setprop file 'vc-workfile-version nil)))) 2000 (if rev (vc-file-setprop file 'vc-workfile-version nil))))
1996 (setq default-directory old-default-dir) 2001 (cond
1997 (cond 2002 ((not workfile)
1998 ((not workfile) 2003 (vc-file-clear-masterprops file)
1999 (vc-file-clear-masterprops file) 2004 (if writable
2000 (if writable 2005 (vc-file-setprop file 'vc-locking-user (user-login-name)))
2001 (vc-file-setprop file 'vc-locking-user (user-login-name))) 2006 (vc-file-setprop file
2002 (vc-file-setprop file 2007 'vc-checkout-time (nth 5 (file-attributes file)))))
2003 'vc-checkout-time (nth 5 (file-attributes file))))) 2008 (message "Checking out %s...done" filename))))))
2004 (message "Checking out %s...done" filename))))
2005 2009
2006(defun vc-backend-logentry-check (file) 2010(defun vc-backend-logentry-check (file)
2007 (vc-backend-dispatch file 2011 (vc-backend-dispatch file