[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/debbugs 082b9e6 257/311: Try harder to find the file to
From: |
Stefan Monnier |
Subject: |
[elpa] externals/debbugs 082b9e6 257/311: Try harder to find the file to patch in debbugs-gnu |
Date: |
Sun, 29 Nov 2020 18:42:24 -0500 (EST) |
branch: externals/debbugs
commit 082b9e63ed95e620e7457684693f18cd69ee9833
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Try harder to find the file to patch in debbugs-gnu
* packages/debbugs/debbugs-gnu.el (debbugs-gnu-apply-patch):
Decode charsets and transfer encoding correctly.
(debbugs-gnu-diff-hunk-target-name): Separate out into its own
function and really try to ensure that single-file patches get the
correct corresponding file.
---
debbugs-gnu.el | 69 +++++++++++++++++++++++++++++++---------------------------
1 file changed, 37 insertions(+), 32 deletions(-)
diff --git a/debbugs-gnu.el b/debbugs-gnu.el
index caf9dea..716c37d 100644
--- a/debbugs-gnu.el
+++ b/debbugs-gnu.el
@@ -2182,7 +2182,8 @@ If given a prefix, patch in the branch directory instead."
patch-buffers))))
(unless patch-buffers
(gnus-summary-show-article 'raw)
- (article-decode-charset)
+ (with-current-buffer gnus-article-buffer
+ (article-decode-charset))
(push (cons nil gnus-article-buffer) patch-buffers))
(dolist (elem patch-buffers)
(with-current-buffer (generate-new-buffer "*debbugs input patch*")
@@ -2230,43 +2231,47 @@ If given a prefix, patch in the branch directory
instead."
(switch-to-buffer "*vc-diff*")
(goto-char (point-min))))
-(defun debbugs-gnu-fix-patch (dir)
- (require 'diff-mode)
- (setq dir (directory-file-name (expand-file-name dir)))
- (goto-char (point-min))
- (while (re-search-forward diff-file-header-re nil t)
- (goto-char (match-beginning 0))
- (let ((target-name (cl-loop for name in (diff-hunk-file-names)
- ;; The target names are usually actual
- ;; file names, but they can also be
- ;; things like "#<buffer eww.el>".
- unless (string-match "[ #<>]" name)
- return name)))
- (when target-name
- (when (string-match "\\`/" target-name)
+(defun debbugs-gnu-diff-hunk-target-name (dir)
+ (let ((names nil))
+ (dolist (name (diff-hunk-file-names))
+ (unless (string-match "[ #<>]" name)
+ (when (string-match "\\`/" name)
;; This is an absolute path, so try to find the target.
- (while (and (not (file-exists-p (expand-file-name target-name dir)))
- (string-match "\\`[^/]*/" target-name))
- (setq target-name (replace-match "" t t target-name))))
+ (while (and (not (file-exists-p (expand-file-name name dir)))
+ (string-match "\\`[^/]*/" name))
+ (setq name (replace-match "" t t name))))
;; See whether we can find the file.
- (when (or (not (string-match "/" target-name))
- (and (string-match "^[ab]/" target-name)
+ (when (or (not (string-match "/" name))
+ (and (string-match "^[ab]/" name)
(not (file-exists-p
- (expand-file-name (substring target-name 2)
+ (expand-file-name (substring name 2)
dir))))
- (file-exists-p (expand-file-name target-name dir)))
+ (file-exists-p (expand-file-name name dir)))
;; We have a simple patch that refers to a file somewhere in the
;; tree. Find it.
- (when-let ((files (directory-files-recursively
- dir
- (concat "^" (regexp-quote
- (file-name-nondirectory target-name))
- "$"))))
- (when (re-search-forward "^[+]+ .*" nil t)
- (replace-match (concat "+++ a"
- (substring (car files) (length dir))
- (match-string 1))
- nil t))))))
+ (setq name (car (sort (directory-files-recursively
+ dir
+ (concat "^" (regexp-quote
+ (file-name-nondirectory name))
+ "$"))
+ #'string>))))
+ (when name
+ (push name names))))
+ ;; Return any of the guessed names.
+ (car names)))
+
+(defun debbugs-gnu-fix-patch (dir)
+ (require 'diff-mode)
+ (setq dir (directory-file-name (expand-file-name dir)))
+ (goto-char (point-min))
+ (while (re-search-forward diff-file-header-re nil t)
+ (goto-char (match-beginning 0))
+ (when-let ((target-name (debbugs-gnu-diff-hunk-target-name dir)))
+ (when (re-search-forward "^\\([+]+\\|-+\\) .*" nil t)
+ (replace-match (concat (match-string 1)
+ " a"
+ (substring target-name (length dir)))
+ nil t)))
(forward-line 2)))
(defun debbugs-gnu-find-contributor (string)
- [elpa] externals/debbugs 636511a 232/311: Support "forwarded" in debbugs, (continued)
- [elpa] externals/debbugs 636511a 232/311: Support "forwarded" in debbugs, Stefan Monnier, 2020/11/29
- [elpa] externals/debbugs 1b1f19b 229/311: Not all bug reports have a subject, apparently., Stefan Monnier, 2020/11/29
- [elpa] externals/debbugs c304562 233/311: Release debbugs 0.16, Stefan Monnier, 2020/11/29
- [elpa] externals/debbugs 04f0926 230/311: Avoid double entries in debbugs, Stefan Monnier, 2020/11/29
- [elpa] externals/debbugs 8e2d3ed 235/311: * packages/debbugs/instructions.texi: Add @anchor{}., Stefan Monnier, 2020/11/29
- [elpa] externals/debbugs ba4b447 239/311: New command debbugs-control-make-message (Bug#33225), Stefan Monnier, 2020/11/29
- [elpa] externals/debbugs d92eade 238/311: Release debbugs 0.17, Stefan Monnier, 2020/11/29
- [elpa] externals/debbugs 6751c76 243/311: * packages/debbugs/instructions.texi: Sync with https://www.debian.org/Bugs/server-control., Stefan Monnier, 2020/11/29
- [elpa] externals/debbugs 07bf4e1 244/311: Search further if d-g-cur-status is nil (Bug#35121), Stefan Monnier, 2020/11/29
- [elpa] externals/debbugs 0dfc1d6 256/311: * packages/debbugs/debbugs-gnu.el (debbugs-gnu-fix-patch): Simplify a bit, Stefan Monnier, 2020/11/29
- [elpa] externals/debbugs 082b9e6 257/311: Try harder to find the file to patch in debbugs-gnu,
Stefan Monnier <=
- [elpa] externals/debbugs edc792e 253/311: * packages/debbugs/debbugs-gnu.el (debbugs-gnu-show-reports):, Stefan Monnier, 2020/11/29
- [elpa] externals/debbugs 889d1dc 263/311: Use pop-to-buffer-same-window in debbugs-gnu-show-reports, Stefan Monnier, 2020/11/29
- [elpa] externals/debbugs c654a6c 264/311: Add progress reporter to debbugs, Stefan Monnier, 2020/11/29
- [elpa] externals/debbugs 79b7316 271/311: * packages/debbugs/debbugs-ug.texi (Searching Bugs): Precise search conditions., Stefan Monnier, 2020/11/29
- [elpa] externals/debbugs ea21a32 276/311: * debbugs-gnu.el (debbugs-gnu-rescan): Make NOCACHE optional., Stefan Monnier, 2020/11/29
- [elpa] externals/debbugs 26bbff4 277/311: Remove inconsistencies in debbugs, Stefan Monnier, 2020/11/29
- [elpa] externals/debbugs 0083f0b 278/311: Add debbugs-*-tagged commands, Stefan Monnier, 2020/11/29
- [elpa] externals/debbugs 8d7dcea 147/311: Minor debbugs tweak, Stefan Monnier, 2020/11/29
- [elpa] externals/debbugs 0947e1c 170/311: Add the "retitle" control, Stefan Monnier, 2020/11/29
- [elpa] externals/debbugs 4a42ac4 171/311: * packages/debbugs/debbugs-ug.texi (Control Messages): Add retitle., Stefan Monnier, 2020/11/29