aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Gutov2016-04-24 23:32:48 +0300
committerDmitry Gutov2016-04-24 23:34:09 +0300
commit1face76ba6d19b269310ddbb0a6a618a3bfe54a2 (patch)
treeae4c3973dba7915bdf2053f76b871e5feaeb2f54
parentdba65ec99361a534042e3a1ade4d08b0f40481d1 (diff)
downloademacs-1face76ba6d19b269310ddbb0a6a618a3bfe54a2.tar.gz
emacs-1face76ba6d19b269310ddbb0a6a618a3bfe54a2.zip
Revert the disputed VC change and update the tests
* lisp/vc/vc-hooks.el (vc-working-revision): Remove the previous change. (vc-state): Same. And update the old, incorrect comment about unregistered files (http://lists.gnu.org/archive/html/emacs-devel/2016-04/msg00526.html). * test/lisp/vc/vc-tests.el (vc-test--state): Remove the check calling `vc-state' on default-directory (VC state is undefined for directories). Check that `vc-state' returns nil where it returned `unregistered' before. Remove all checks comparing invocations with the backend passed in explictly and without. (vc-test--working-revision): Remove all checks comparing invocations with the backend passed in explictly and without. Update comments, and add a new one.
-rw-r--r--lisp/vc/vc-hooks.el30
-rw-r--r--test/lisp/vc/vc-tests.el55
2 files changed, 32 insertions, 53 deletions
diff --git a/lisp/vc/vc-hooks.el b/lisp/vc/vc-hooks.el
index 4047bca046a..6b4cd6acd03 100644
--- a/lisp/vc/vc-hooks.el
+++ b/lisp/vc/vc-hooks.el
@@ -468,18 +468,21 @@ status of this file. Otherwise, the value returned is one of:
468 468
469 `unregistered' The file is not under version control." 469 `unregistered' The file is not under version control."
470 470
471 ;; Note: in Emacs 22 and older, return of nil meant the file was 471 ;; Note: we usually return nil here for unregistered files anyway
472 ;; unregistered. This is potentially a source of 472 ;; when called with only one argument. This doesn't seem to cause
473 ;; backward-compatibility bugs. 473 ;; any problems. But if we wanted to change that, we should
474 ;; probably opt for redefining the `registered' command to return
475 ;; non-nil even for unregistered files (maybe also rename it), and
476 ;; then make sure that all `state' implementations handle
477 ;; unregistered file appropriately.
474 478
475 ;; FIXME: New (sub)states needed (?): 479 ;; FIXME: New (sub)states needed (?):
476 ;; - `copied' and `moved' (might be handled by `removed' and `added') 480 ;; - `copied' and `moved' (might be handled by `removed' and `added')
477 (or (vc-file-getprop file 'vc-state) 481 (or (vc-file-getprop file 'vc-state)
478 (and (not (vc-registered file)) 'unregistered)
479 (when (> (length file) 0) ;Why?? --Stef 482 (when (> (length file) 0) ;Why?? --Stef
480 (setq backend (or backend (vc-responsible-backend file))) 483 (setq backend (or backend (vc-backend file)))
481 (when backend 484 (when backend
482 (vc-state-refresh file backend))))) 485 (vc-state-refresh file backend)))))
483 486
484(defun vc-state-refresh (file backend) 487(defun vc-state-refresh (file backend)
485 "Quickly recompute the `state' of FILE." 488 "Quickly recompute the `state' of FILE."
@@ -495,13 +498,12 @@ status of this file. Otherwise, the value returned is one of:
495 "Return the repository version from which FILE was checked out. 498 "Return the repository version from which FILE was checked out.
496If FILE is not registered, this function always returns nil." 499If FILE is not registered, this function always returns nil."
497 (or (vc-file-getprop file 'vc-working-revision) 500 (or (vc-file-getprop file 'vc-working-revision)
498 (and (vc-registered file) 501 (progn
499 (progn 502 (setq backend (or backend (vc-backend file)))
500 (setq backend (or backend (vc-responsible-backend file))) 503 (when backend
501 (when backend 504 (vc-file-setprop file 'vc-working-revision
502 (vc-file-setprop file 'vc-working-revision 505 (vc-call-backend
503 (vc-call-backend 506 backend 'working-revision file))))))
504 backend 'working-revision file)))))))
505 507
506;; Backward compatibility. 508;; Backward compatibility.
507(define-obsolete-function-alias 509(define-obsolete-function-alias
diff --git a/test/lisp/vc/vc-tests.el b/test/lisp/vc/vc-tests.el
index 793ad82c74f..ac10ce2337a 100644
--- a/test/lisp/vc/vc-tests.el
+++ b/test/lisp/vc/vc-tests.el
@@ -316,46 +316,31 @@ This checks also `vc-backend' and `vc-responsible-backend'."
316 'vc-test--cleanup-hook 316 'vc-test--cleanup-hook
317 `(lambda () (delete-directory ,default-directory 'recursive))) 317 `(lambda () (delete-directory ,default-directory 'recursive)))
318 318
319 ;; Create empty repository. Check repository state. 319 ;; Create empty repository.
320 (make-directory default-directory) 320 (make-directory default-directory)
321 (vc-test--create-repo-function backend) 321 (vc-test--create-repo-function backend)
322 322
323 ;; FIXME: The state shall be unregistered only.
324 ;; nil: RCS
325 ;; unregistered: Bzr CVS Git Hg Mtn SCCS SRC
326 ;; up-to-date: SVN
327 (message "vc-state1 %s" (vc-state default-directory))
328 (should (eq (vc-state default-directory)
329 (vc-state default-directory backend)))
330 (should (memq (vc-state default-directory)
331 '(nil unregistered up-to-date)))
332
333 (let ((tmp-name (expand-file-name "foo" default-directory))) 323 (let ((tmp-name (expand-file-name "foo" default-directory)))
334 ;; Check state of a nonexistent file. 324 ;; Check state of a nonexistent file.
335 325
336 ;; unregistered: Bzr CVS Git Hg Mtn RCS SCCS SRC SVN
337 (message "vc-state2 %s" (vc-state tmp-name)) 326 (message "vc-state2 %s" (vc-state tmp-name))
338 (should (eq (vc-state tmp-name) (vc-state tmp-name backend))) 327 (should (null (vc-state tmp-name)))
339 (should (eq (vc-state tmp-name) 'unregistered))
340 328
341 ;; Write a new file. Check state. 329 ;; Write a new file. Check state.
342 (write-region "foo" nil tmp-name nil 'nomessage) 330 (write-region "foo" nil tmp-name nil 'nomessage)
343 331
344 ;; unregistered: Bzr CVS Git Hg Mtn RCS SCCS SRC SVN
345 (message "vc-state3 %s" (vc-state tmp-name)) 332 (message "vc-state3 %s" (vc-state tmp-name))
346 (should (eq (vc-state tmp-name) (vc-state tmp-name backend))) 333 (should (null (vc-state tmp-name)))
347 (should (eq (vc-state tmp-name) 'unregistered))
348 334
349 ;; Register a file. Check state. 335 ;; Register a file. Check state.
350 (vc-register 336 (vc-register
351 (list backend (list (file-name-nondirectory tmp-name)))) 337 (list backend (list (file-name-nondirectory tmp-name))))
352 338
353 ;; FIXME: nil seems to be wrong. 339 ;; FIXME: nil is definitely wrong.
354 ;; nil: SRC 340 ;; nil: SRC
355 ;; added: Bzr CVS Git Hg Mtn SVN 341 ;; added: Bzr CVS Git Hg Mtn SVN
356 ;; up-to-date: RCS SCCS 342 ;; up-to-date: RCS SCCS
357 (message "vc-state4 %s" (vc-state tmp-name)) 343 (message "vc-state4 %s" (vc-state tmp-name))
358 (should (eq (vc-state tmp-name) (vc-state tmp-name backend)))
359 (should (memq (vc-state tmp-name) '(nil added up-to-date))) 344 (should (memq (vc-state tmp-name) '(nil added up-to-date)))
360 345
361 ;; Unregister the file. Check state. 346 ;; Unregister the file. Check state.
@@ -363,11 +348,10 @@ This checks also `vc-backend' and `vc-responsible-backend'."
363 'vc-test--unregister-function backend tmp-name) 348 'vc-test--unregister-function backend tmp-name)
364 'vc-not-supported) 349 'vc-not-supported)
365 (message "vc-state5 unsupported") 350 (message "vc-state5 unsupported")
366 ;; unregistered: Bzr Git Hg RCS 351 ;; nil: Bzr Git Hg RCS
367 ;; unsupported: CVS Mtn SCCS SRC SVN 352 ;; unsupported: CVS Mtn SCCS SRC SVN
368 (message "vc-state5 %s" (vc-state tmp-name)) 353 (message "vc-state5 %s" (vc-state tmp-name))
369 (should (eq (vc-state tmp-name) (vc-state tmp-name backend))) 354 (should (null (vc-state tmp-name))))))
370 (should (memq (vc-state tmp-name) '(unregistered))))))
371 355
372 ;; Save exit. 356 ;; Save exit.
373 (ignore-errors (run-hooks 'vc-test--cleanup-hook))))) 357 (ignore-errors (run-hooks 'vc-test--cleanup-hook)))))
@@ -399,41 +383,36 @@ This checks also `vc-backend' and `vc-responsible-backend'."
399 ;; "0": SVN 383 ;; "0": SVN
400 (message 384 (message
401 "vc-working-revision1 %s" (vc-working-revision default-directory)) 385 "vc-working-revision1 %s" (vc-working-revision default-directory))
402 (should (eq (vc-working-revision default-directory) 386 (should (member (vc-working-revision default-directory) '(nil "0")))
403 (vc-working-revision default-directory backend)))
404 (should (member (vc-working-revision default-directory) '(nil "0")))
405 387
406 (let ((tmp-name (expand-file-name "foo" default-directory))) 388 (let ((tmp-name (expand-file-name "foo" default-directory)))
407 ;; Check initial working revision, should be nil until 389 ;; Check initial working revision, should be nil until
408 ;; it's registered. 390 ;; it's registered.
409 391
410 ;; nil: Bzr CVS Git Hg Mtn RCS SCCS SRC SVN
411 (message "vc-working-revision2 %s" (vc-working-revision tmp-name)) 392 (message "vc-working-revision2 %s" (vc-working-revision tmp-name))
412 (should (eq (vc-working-revision tmp-name) 393 (should-not (vc-working-revision tmp-name))
413 (vc-working-revision tmp-name backend)))
414 (should-not (vc-working-revision tmp-name))
415 394
416 ;; Write a new file. Check working revision. 395 ;; Write a new file. Check working revision.
417 (write-region "foo" nil tmp-name nil 'nomessage) 396 (write-region "foo" nil tmp-name nil 'nomessage)
418 397
419 ;; nil: Bzr CVS Git Hg Mtn RCS SCCS SRC SVN
420 (message "vc-working-revision3 %s" (vc-working-revision tmp-name)) 398 (message "vc-working-revision3 %s" (vc-working-revision tmp-name))
421 (should (eq (vc-working-revision tmp-name) 399 (should-not (vc-working-revision tmp-name))
422 (vc-working-revision tmp-name backend)))
423 (should-not (vc-working-revision tmp-name))
424 400
425 ;; Register a file. Check working revision. 401 ;; Register a file. Check working revision.
426 (vc-register 402 (vc-register
427 (list backend (list (file-name-nondirectory tmp-name)))) 403 (list backend (list (file-name-nondirectory tmp-name))))
428 404
429 ;; FIXME: nil doesn't seem to be proper. 405 ;; XXX: nil is fine, at least in Git's case, because
406 ;; `vc-register' only makes the file `added' in this case.
430 ;; nil: Git Mtn 407 ;; nil: Git Mtn
431 ;; "0": Bzr CVS Hg SRC SVN 408 ;; "0": Bzr CVS Hg SRC SVN
432 ;; "1.1": RCS SCCS 409 ;; "1.1": RCS SCCS
433 (message "vc-working-revision4 %s" (vc-working-revision tmp-name)) 410 (message "vc-working-revision4 %s" (vc-working-revision tmp-name))
434 (should (eq (vc-working-revision tmp-name) 411 (should (member (vc-working-revision tmp-name) '(nil "0" "1.1")))
435 (vc-working-revision tmp-name backend))) 412
436 (should (member (vc-working-revision tmp-name) '(nil "0" "1.1"))) 413 ;; TODO: Call `vc-checkin', and check the resulting
414 ;; working revision. None of the return values should be
415 ;; nil then.
437 416
438 ;; Unregister the file. Check working revision. 417 ;; Unregister the file. Check working revision.
439 (if (eq (vc-test--run-maybe-unsupported-function 418 (if (eq (vc-test--run-maybe-unsupported-function
@@ -443,8 +422,6 @@ This checks also `vc-backend' and `vc-responsible-backend'."
443 ;; nil: Bzr Git Hg RCS 422 ;; nil: Bzr Git Hg RCS
444 ;; unsupported: CVS Mtn SCCS SRC SVN 423 ;; unsupported: CVS Mtn SCCS SRC SVN
445 (message "vc-working-revision5 %s" (vc-working-revision tmp-name)) 424 (message "vc-working-revision5 %s" (vc-working-revision tmp-name))
446 (should (eq (vc-working-revision tmp-name)
447 (vc-working-revision tmp-name backend)))
448 (should-not (vc-working-revision tmp-name))))) 425 (should-not (vc-working-revision tmp-name)))))
449 426
450 ;; Save exit. 427 ;; Save exit.