aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--etc/NEWS7
-rw-r--r--lisp/vc/vc.el47
2 files changed, 40 insertions, 14 deletions
diff --git a/etc/NEWS b/etc/NEWS
index fa8b0bf89a8..71eada99ed8 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1505,6 +1505,13 @@ behavior or dispense with the prompting.
1505These correspond to the existing 'z p' to pop a stash and 'P' to pop the 1505These correspond to the existing 'z p' to pop a stash and 'P' to pop the
1506stash at point (deleting the stash at point is also bound to C-k). 1506stash at point (deleting the stash at point is also bound to C-k).
1507 1507
1508---
1509*** VC-Dir now offers to register files when checking in mixed filesets.
1510Previously, if some files to be checked in were unregistered but others
1511were added, removed or edited, Emacs would refuse to proceed.
1512Now Emacs prompts to first register the unregistered files, so that all
1513files in the fileset are in a compatible state for a checkin.
1514
1508** Diff mode 1515** Diff mode
1509 1516
1510+++ 1517+++
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index bc3d4cdbb68..12f86907470 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -1288,17 +1288,40 @@ BEWARE: this function may change the current buffer."
1288 "Compute last three `vc-deduce-fileset' return value elements for FILES. 1288 "Compute last three `vc-deduce-fileset' return value elements for FILES.
1289FILES should be a pair, or list of pairs, of files and their VC states. 1289FILES should be a pair, or list of pairs, of files and their VC states.
1290BACKEND is the VC backend responsible for FILES." 1290BACKEND is the VC backend responsible for FILES."
1291 (let ((state (cdar files)) 1291 (let* ((files (if (proper-list-p files) files (list files)))
1292 (files* (mapcar #'car 1292 files* states-alist states state)
1293 (if (proper-list-p files) files (list files)))))
1294 ;; Check that all files are in a consistent state, since we use that 1293 ;; Check that all files are in a consistent state, since we use that
1295 ;; state to decide which operation to perform. 1294 ;; state to decide which operation to perform.
1296 (dolist (crt (cdr files)) 1295 (pcase-dolist (`(,file . ,state) files)
1297 (unless (vc-compatible-state (cdr crt) state) 1296 (push file files*)
1298 (error "\ 1297 (push file (alist-get state states-alist nil nil #'eq)))
1298 (setq states (mapcar #'car states-alist))
1299 (cond ((length= states 1)
1300 (setq state (car states)))
1301 ((cl-subsetp states '(added removed edited))
1302 (setq state 'edited))
1303
1304 ;; Special, but common case:
1305 ;; checking in both changes and new files at once.
1306 ((and (cl-subsetp states '(added removed edited unregistered))
1307 (y-or-n-p "Some files are unregistered; register them first?"))
1308 (vc-register (list backend
1309 (cdr (assq 'unregistered states-alist))))
1310 (setq state 'edited))
1311
1312 (t
1313 (let* ((pred (lambda (elt)
1314 (memq (car elt) '(added removed edited))))
1315 (compat-alist (cl-remove-if-not pred states-alist))
1316 (other-alist (cl-remove-if pred states-alist))
1317 (first (car (or compat-alist other-alist)))
1318 (second (if compat-alist
1319 (car other-alist)
1320 (cadr other-alist))))
1321 (error "\
1299To apply VC operations to multiple files, the files must be in similar VC states. 1322To apply VC operations to multiple files, the files must be in similar VC states.
1300%s in state %s clashes with %s in state %s" 1323%s in state %s clashes with %s in state %s"
1301 (car crt) (cdr crt) (caar files) state))) 1324 (cadr first) (car first) (cadr second) (car second)))))
1302 (list files* state 1325 (list files* state
1303 (and state (not (eq state 'unregistered)) 1326 (and state (not (eq state 'unregistered))
1304 (vc-checkout-model backend files*))))) 1327 (vc-checkout-model backend files*)))))
@@ -1314,12 +1337,6 @@ To apply VC operations to multiple files, the files must be in similar VC states
1314 (or (eq (vc-checkout-model backend (list file)) 'implicit) 1337 (or (eq (vc-checkout-model backend (list file)) 'implicit)
1315 (memq (vc-state file) '(edited needs-merge conflict)))))) 1338 (memq (vc-state file) '(edited needs-merge conflict))))))
1316 1339
1317(defun vc-compatible-state (p q)
1318 "Control which states can be in the same commit."
1319 (or
1320 (eq p q)
1321 (and (member p '(edited added removed)) (member q '(edited added removed)))))
1322
1323(defun vc-read-backend (prompt &optional backends default) 1340(defun vc-read-backend (prompt &optional backends default)
1324 (let ((backends (or backends vc-handled-backends)) 1341 (let ((backends (or backends vc-handled-backends))
1325 (completion-ignore-case t)) 1342 (completion-ignore-case t))
@@ -1344,6 +1361,8 @@ For modern merging-based version control systems:
1344 backend with which to register the fileset. 1361 backend with which to register the fileset.
1345 If every work file in the VC fileset is either added or modified, 1362 If every work file in the VC fileset is either added or modified,
1346 pop up a *vc-log* buffer to commit the fileset changes. 1363 pop up a *vc-log* buffer to commit the fileset changes.
1364 (If some are added or modified and some are unregistered, offer to
1365 register the unregistered ones, first.)
1347 For a centralized version control system, if any work file in 1366 For a centralized version control system, if any work file in
1348 the VC fileset is out of date, offer to update the fileset. 1367 the VC fileset is out of date, offer to update the fileset.
1349 1368
@@ -1432,7 +1451,7 @@ from which to check out the file(s)."
1432 ;; do nothing 1451 ;; do nothing
1433 (message "Fileset is up-to-date")))) 1452 (message "Fileset is up-to-date"))))
1434 ;; Files have local changes 1453 ;; Files have local changes
1435 ((vc-compatible-state state 'edited) 1454 ((memq state '(added removed edited))
1436 (let ((ready-for-commit files)) 1455 (let ((ready-for-commit files))
1437 ;; CVS, SVN and bzr don't care about read-only (bug#9781). 1456 ;; CVS, SVN and bzr don't care about read-only (bug#9781).
1438 ;; RCS does, SCCS might (someone should check...). 1457 ;; RCS does, SCCS might (someone should check...).