emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r103620: Fix package.el handling of v


From: Chong Yidong
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r103620: Fix package.el handling of version numbers like 1.0pre6.
Date: Thu, 10 Mar 2011 18:40:46 -0500
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 103620
committer: Chong Yidong <address@hidden>
branch nick: trunk
timestamp: Thu 2011-03-10 18:40:46 -0500
message:
  Fix package.el handling of version numbers like 1.0pre6.
  
  * lisp/emacs-lisp/package.el (package-version-join): Impose a standard
  string representation for pre/alpha/beta version lists.
  (package-unpack-single): Standardize the directory name by passing
  it through package-version-join.
modified:
  lisp/ChangeLog
  lisp/emacs-lisp/package.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2011-03-10 21:51:26 +0000
+++ b/lisp/ChangeLog    2011-03-10 23:40:46 +0000
@@ -1,7 +1,11 @@
 2011-03-10  Chong Yidong  <address@hidden>
 
-       * emacs-lisp/package.el (package-strip-rcs-id): Accept any version
-       string that does not signal an error in version-to-list.
+       * emacs-lisp/package.el (package-version-join): Impose a standard
+       string representation for pre/alpha/beta version lists.
+       (package-unpack-single): Standardize the directory name by passing
+       it through package-version-join.
+       (package-strip-rcs-id): Accept any version string that does not
+       signal an error in version-to-list.
 
 2011-03-10  Michael Albinus  <address@hidden>
 

=== modified file 'lisp/emacs-lisp/package.el'
--- a/lisp/emacs-lisp/package.el        2011-03-10 21:51:26 +0000
+++ b/lisp/emacs-lisp/package.el        2011-03-10 23:40:46 +0000
@@ -320,14 +320,39 @@
 (put 'package-obsolete-alist 'risky-local-variable t)
 
 (defconst package-subdirectory-regexp
-  "^\\([^.].*\\)-\\([0-9]+\\(?:[.][0-9]+\\)*\\)$"
+  
"\\`\\([^.].*?\\)-\\([0-9]+\\(?:[.][0-9]+\\|\\(?:pre\\|beta\\|alpha\\)[0-9]+\\)*\\)\\'"
   "Regular expression matching the name of a package subdirectory.
 The first subexpression is the package name.
 The second subexpression is the version string.")
 
-(defun package-version-join (l)
-  "Turn a list of version numbers into a version string."
-  (mapconcat 'int-to-string l "."))
+(defun package-version-join (vlist)
+  "Return the version string corresponding to the list VLIST.
+This is, approximately, the inverse of `version-to-list'.
+\(Actually, it returns only one of the possible inverses, since
+`version-to-list' is a many-to-one operation.)"
+  (if (null vlist)
+      ""
+    (let ((str-list (list "." (int-to-string (car vlist)))))
+      (dolist (num (cdr vlist))
+       (cond
+        ((>= num 0)
+         (push (int-to-string num) str-list)
+         (push "." str-list))
+        ((< num -3)
+         (error "Invalid version list `%s'" vlist))
+        (t
+         ;; pre, or beta, or alpha
+         (cond ((equal "." (car str-list))
+                (pop str-list))
+               ((not (string-match "[0-9]+" (car str-list)))
+                (error "Invalid version list `%s'" vlist)))
+         (push (cond ((= num -1) "pre")
+                     ((= num -2) "beta")
+                     ((= num -3) "alpha"))
+               str-list))))
+      (if (equal "." (car str-list))
+         (pop str-list))
+      (apply 'concat (nreverse str-list)))))
 
 (defun package-strip-version (dirname)
   "Strip the version from a combined package name and version.
@@ -592,7 +617,9 @@
   (if (string= file-name "package")
       (package--write-file-no-coding
        (expand-file-name (concat file-name ".el") package-user-dir))
-    (let* ((pkg-dir  (expand-file-name (concat file-name "-" version)
+    (let* ((pkg-dir  (expand-file-name (concat file-name "-"
+                                              (package-version-join
+                                               (version-to-list version)))
                                       package-user-dir))
           (el-file  (expand-file-name (concat file-name ".el") pkg-dir))
           (pkg-file (expand-file-name (concat file-name "-pkg.el") pkg-dir)))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]