Subject: bug#15108: [Patch] Updated package dependencies

From: Tom Willemse <[email-masked]>
Date: Wed, 11 Dec 2013 21:29:58 +0100

Hey,

I've been meaning to send this for a couple of weeks, but I was unable
to. I apologize.

A while ago the patch I sent last time broke, I fixed it and now here
I'm sending it again, hoping there is still some interest in this or
need for it. I've removed the changes to the ChangeLog (or at least, I'm
not sending them again), since I've lost confidence in it being my place
to do so.

I've tested it most recently bzr trunk revision 115470. All the ways to
specify dependencies work as described before:

;; Package-Requires: foo
;; Package-Requires: (foo bar)
;; Package-Requires: (foo (baz "1.1.0") bar)
;; Package-Requires: (baz "1.1.0")

These would all be valid after this patch.

As before, any comments, criticisms and considerations would be greatly
appreciated.

=== modified file 'lisp/emacs-lisp/package.el'
--- lisp/emacs-lisp/package.el	2013-08-03 02:34:22 +0000
+++ lisp/emacs-lisp/package.el	2013-08-16 20:40:09 +0000
@@ -973,6 +973,17 @@
 	    str)
       (error nil))))

+(defun package--prepare-dependencies (deps)
+  "Turn DEPS into an acceptable list of dependencies.
+
+Any parts missing a version string get a default version string
+of \"0\" (meaning any version) and an appropriate level of lists
+is wrapped around any parts requiring it."
+  (cond
+   ((symbolp deps) `((,deps "0")))
+   ((stringp (cadr deps)) `(,deps))
+   (t (mapcar (lambda (dep) (if (symbolp dep) `(,dep "0") dep)) deps))))
+
 (defun package-buffer-info ()
   "Return a `package-desc' describing the package in the current buffer.

@@ -1003,7 +1014,9 @@
 	 "Package lacks a \"Version\" or \"Package-Version\" header"))
       (package-desc-from-define
        file-name pkg-version desc
-       (if requires-str (package-read-from-string requires-str))
+       (if requires-str
+           (package--prepare-dependencies
+            (package-read-from-string requires-str)))
        :kind 'single
        :url homepage))))