[darcs-users] vc-darcs.el and the length of hashes (cons: Args out of range)

Ivan Zakharyaschev imz at altlinux.org
Tue Dec 15 01:13:40 UTC 2015


Hello!

As a darcs user from time to time (and sympathizer), I have recently 
started to use vc-darcs.el in Emacs. (I know there are other darcs 
libraries for Emacs, but I'm interested in the Emacs VC interface, too, 
because I'm accustomed to using it in certain situations.)

I want to share some observations about a discovered bug in one of the 
implementations of vc-darcs (which I'm left with as the only one, because 
the other link is dead).

Perhaps, this will help make it better.

I'm not sure about where this inconsistency comes from. Perhaps, an older 
version of darcs had a different interface w.r.t. the ids of patches. 
Understanding this would make it clearer how to proceed with a possible 
fix (keep both variants or not, check versions,...). Do you have any 
suggestions?

Best regards,
Ivan

---------- Forwarded message ----------
Date: Tue, 8 Dec 2015 13:18:54 +0300
From: Ivan Zakharyaschev <imz@>
To: jch@
Subject: vc-darcs: cons: Args out of range

Hello!

I've just installed your vc-darcs.el from your repo. (BTW, the second
implementation mentioned at http://darcs.net/RelatedSoftware/Emacs and
http://www.emacswiki.org/emacs/DaRcs --
http://www.loveshack.ukfsn.org/emacs/vc-darcs.el -- is not available
because the site doesn't open.)

When I call

C-x v l
in a file under darcs control, I get the error message:

cons: Args out of range: "33336119dca7cd08261f99cecc2643451601ad6d", 0, 61

I'm using:

$ darcs --version
2.10.0 (release)

Best regarads,
-- 
Ivan



---------- Forwarded message ----------
Date: Tue, 8 Dec 2015 13:20:41 +0300
From: Ivan Zakharyaschev <imz@>
To: jch@
Subject: Re: vc-darcs: cons: Args out of range

$ emacs --version
GNU Emacs 24.3.1
Copyright (C) 2013 Free Software Foundation, Inc.

---------- Forwarded message ----------
Date: Wed, 9 Dec 2015 02:34:42 +0300
From: Ivan Zakharyaschev <imz@>
To: Juliusz Chroboczek <jch@>
Subject: Re: vc-darcs: cons: Args out of range

2015-12-08 18:20 UTC+03:00, Juliusz Chroboczek <jch at pps.univ-paris-diderot.fr>:
> Could you please say
>
>   M-: (setq debug-on-error t) RET
>
> and send me a backtrace?

Sure. I'm attaching it.

---------- Forwarded message ----------
Date: Wed, 9 Dec 2015 03:37:02 +0300
From: Ivan Zakharyaschev <imz at altlinux.org>
To: Juliusz Chroboczek <jch@>
Subject: Re: vc-darcs: cons: Args out of range

So,

the patch hash is SHA1 -- http://darcs.net/Internals/NamedPatch (via
http://darcs.net/Internals/Hashes ).

SHA1 is 40 hexadecimal digits long -- https://en.wikipedia.org/wiki/SHA-1 .

And vc-darcs.el tries to get 62 symbols of `h' in `vc-darcs-changes'...

So, is `h' the hash?..

               (let ((h (cdr (assoc 'hash (cadr e)))))
                 (when h
                   (push (substring h 0 61) l))))))

Probably, yes. So, something is wrong (40 vs 62)...

-- 
Ivan
-------------- next part --------------
Debugger entered--Lisp error: (args-out-of-range "fa1eff0e1163fc2c716cccb2f4ab9bffe21597c1" 0 61)
  substring("fa1eff0e1163fc2c716cccb2f4ab9bffe21597c1" 0 61)
  (cons (substring h 0 61) l)
  (setq l (cons (substring h 0 61) l))
  (progn (setq l (cons (substring h 0 61) l)))
  (if h (progn (setq l (cons (substring h 0 61) l))))
  (let ((h (cdr (assoc (quote hash) (cadr e))))) (if h (progn (setq l (cons (substring h 0 61) l)))))
  (progn (let ((h (cdr (assoc (quote hash) (cadr e))))) (if h (progn (setq l (cons (substring h 0 61) l))))))
  (if (and (consp e) (eq (car e) (quote patch))) (progn (let ((h (cdr (assoc (quote hash) (cadr e))))) (if h (progn (setq l (cons (substring h 0 61) l)))))))
  (let ((e (car (prog1 ch (setq ch (cdr ch)))))) (if (and (consp e) (eq (car e) (quote patch))) (progn (let ((h (cdr (assoc ... ...)))) (if h (progn (setq l (cons ... l))))))))
  (while (not (null ch)) (let ((e (car (prog1 ch (setq ch (cdr ch)))))) (if (and (consp e) (eq (car e) (quote patch))) (progn (let ((h (cdr ...))) (if h (progn (setq l ...))))))))
  (let ((ch (cddr (car changes))) (l (quote nil))) (while (not (null ch)) (let ((e (car (prog1 ch (setq ch ...))))) (if (and (consp e) (eq (car e) (quote patch))) (progn (let ((h ...)) (if h (progn ...))))))) (nreverse l))
  (let ((changes (xml-parse-region 1 (point-max)))) (if (and (null (cdr changes)) (eq (quote changelog) (car (car changes)))) nil (error "Unexpected output from darcs changes --xml.")) (let ((ch (cddr (car changes))) (l (quote nil))) (while (not (null ch)) (let ((e (car (prog1 ch ...)))) (if (and (consp e) (eq (car e) (quote patch))) (progn (let (...) (if h ...)))))) (nreverse l)))
  (progn (apply (function vc-do-command) t 0 vc-darcs-program-name files "changes" "--xml" flags) (let ((changes (xml-parse-region 1 (point-max)))) (if (and (null (cdr changes)) (eq (quote changelog) (car (car changes)))) nil (error "Unexpected output from darcs changes --xml.")) (let ((ch (cddr (car changes))) (l (quote nil))) (while (not (null ch)) (let ((e (car ...))) (if (and (consp e) (eq ... ...)) (progn (let ... ...))))) (nreverse l))))
  (unwind-protect (progn (apply (function vc-do-command) t 0 vc-darcs-program-name files "changes" "--xml" flags) (let ((changes (xml-parse-region 1 (point-max)))) (if (and (null (cdr changes)) (eq (quote changelog) (car (car changes)))) nil (error "Unexpected output from darcs changes --xml.")) (let ((ch (cddr (car changes))) (l (quote nil))) (while (not (null ch)) (let ((e ...)) (if (and ... ...) (progn ...)))) (nreverse l)))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer)))
  (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (apply (function vc-do-command) t 0 vc-darcs-program-name files "changes" "--xml" flags) (let ((changes (xml-parse-region 1 (point-max)))) (if (and (null (cdr changes)) (eq (quote changelog) (car ...))) nil (error "Unexpected output from darcs changes --xml.")) (let ((ch (cddr ...)) (l (quote nil))) (while (not (null ch)) (let (...) (if ... ...))) (nreverse l)))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer))))
  (let ((temp-buffer (generate-new-buffer " *temp*"))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (apply (function vc-do-command) t 0 vc-darcs-program-name files "changes" "--xml" flags) (let ((changes (xml-parse-region 1 ...))) (if (and (null ...) (eq ... ...)) nil (error "Unexpected output from darcs changes --xml.")) (let ((ch ...) (l ...)) (while (not ...) (let ... ...)) (nreverse l)))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer)))))
  vc-darcs-changes("/home/imz/TOOLS/prog/language-c/src/Language/C/Analysis/TypeCheck.hs" "--max-count" "1")
  (car (vc-darcs-changes file "--max-count" "1"))
  vc-darcs-working-revision("/home/imz/TOOLS/prog/language-c/src/Language/C/Analysis/TypeCheck.hs")
  apply(vc-darcs-working-revision "/home/imz/TOOLS/prog/language-c/src/Language/C/Analysis/TypeCheck.hs")
  vc-call-backend(DARCS working-revision "/home/imz/TOOLS/prog/language-c/src/Language/C/Analysis/TypeCheck.hs")
  vc-working-revision("/home/imz/TOOLS/prog/language-c/src/Language/C/Analysis/TypeCheck.hs")
  vc-print-log(nil 2000)
  call-interactively(vc-print-log nil nil)


More information about the darcs-users mailing list