annotate admin/bzrmerge.el @ 112137:151a90b20289

Use __builtin_unwind_init in the MSDOS build. msdos/sed2v2.inp (HAVE___BUILTIN_UNWIND_INIT): Define.
author Eli Zaretskii <eliz@gnu.org>
date Fri, 07 Jan 2011 12:47:44 +0200
parents b0a317b18658
children 978fe18f0882
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
112018
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1 ;;; bzrmerge.el ---
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
3 ;; Copyright (C) 2010 Stefan Monnier
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
4
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
5 ;; Author: Stefan Monnier <monnier@iro.umontreal.ca>
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
6 ;; Keywords:
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
7
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
8 ;; This program is free software; you can redistribute it and/or modify
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
9 ;; it under the terms of the GNU General Public License as published by
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
10 ;; the Free Software Foundation, either version 3 of the License, or
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
11 ;; (at your option) any later version.
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
12
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
13 ;; This program is distributed in the hope that it will be useful,
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
16 ;; GNU General Public License for more details.
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
17
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
18 ;; You should have received a copy of the GNU General Public License
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
19 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
20
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
21 ;;; Commentary:
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
22
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
23 ;;
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
24
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
25 ;;; Code:
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
26
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
27 (defun bzrmerge-merges ()
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
28 "Return the list of already merged (not not committed) revisions.
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
29 The list returned is sorted by oldest-first."
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
30 (with-current-buffer (get-buffer-create "*bzrmerge*")
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
31 (erase-buffer)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
32 ;; We generally want to make sure we start with a clean tree, but we also
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
33 ;; want to allow restarts (i.e. with some part of FROM already merged but
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
34 ;; not yet committed).
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
35 (call-process "bzr" nil t nil "status" "-v")
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
36 (goto-char (point-min))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
37 (when (re-search-forward "^conflicts:\n" nil t)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
38 (error "You still have unresolved conflicts"))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
39 (let ((merges ()))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
40 (if (not (re-search-forward "^pending merges:\n" nil t))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
41 (when (save-excursion
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
42 (goto-char (point-min))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
43 (re-search-forward "^[a-z ]*:\n" nil t))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
44 (error "You still have uncommitted changes"))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
45 ;; This is really stupid, but it seems there's no easy way to figure
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
46 ;; out which revisions have been merged already. The only info I can
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
47 ;; find is the "pending merges" from "bzr status -v", which is not
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
48 ;; very machine-friendly.
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
49 (while (not (eobp))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
50 (skip-chars-forward " ")
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
51 (push (buffer-substring (point) (line-end-position)) merges)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
52 (forward-line 1)))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
53 merges)))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
54
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
55 (defun bzrmerge-check-match (merge)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
56 ;; Make sure the MERGES match the revisions on the FROM branch.
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
57 ;; Stupidly the best form of MERGES I can find is the one from
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
58 ;; "bzr status -v" which is very machine non-friendly, so I have
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
59 ;; to do some fuzzy matching.
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
60 (let ((author
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
61 (or
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
62 (save-excursion
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
63 (if (re-search-forward "^author: *\\([^<]*[^ ]\\) +<.*"
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
64 nil t)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
65 (match-string 1)))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
66 (save-excursion
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
67 (if (re-search-forward
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
68 "^committer: *\\([^<]*[^< ]\\) +<" nil t)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
69 (match-string 1)))))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
70 (timestamp
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
71 (save-excursion
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
72 (if (re-search-forward
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
73 "^timestamp:[^0-9]*\\([-0-9]+\\)" nil t)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
74 (match-string 1))))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
75 (line1
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
76 (save-excursion
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
77 (if (re-search-forward "^message:[ \n]*" nil t)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
78 (buffer-substring (point) (line-end-position))))))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
79 ;; The `merge' may have a truncated line1 with "...", so get
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
80 ;; rid of any "..." and then look for a prefix match.
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
81 (when (string-match "\\.+\\'" merge)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
82 (setq merge (substring merge 0 (match-beginning 0))))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
83 (or (string-prefix-p
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
84 merge (concat author " " timestamp " " line1))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
85 (string-prefix-p
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
86 merge (concat author " " timestamp " [merge] " line1)))))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
87
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
88 (defun bzrmerge-missing (from merges)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
89 "Return the list of revisions that need to be merged.
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
90 MERGES is the revisions already merged but not yet committed.
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
91 The result is of the form (TOMERGE . TOSKIP) where TOMERGE and TOSKIP
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
92 are both lists of revnos, in oldest-first order."
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
93 (with-current-buffer (get-buffer-create "*bzrmerge*")
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
94 (erase-buffer)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
95 (call-process "bzr" nil t nil "missing" "--theirs-only"
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
96 (expand-file-name from))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
97 (let ((revnos ()) (skipped ()))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
98 (pop-to-buffer (current-buffer))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
99 (goto-char (point-max))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
100 (while (re-search-backward "^------------------------------------------------------------\nrevno: \\([0-9.]+\\).*" nil t)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
101 (save-excursion
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
102 (if merges
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
103 (while (not (bzrmerge-check-match (pop merges)))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
104 (unless merges
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
105 (error "Unmatched tip of merged revisions")))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
106 (let ((case-fold-search t)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
107 (revno (match-string 1))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
108 (skip nil))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
109 (if (string-match "\\." revno)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
110 (error "Unexpected dotted revno!")
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
111 (setq revno (string-to-number revno)))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
112 (re-search-forward "^message:\n")
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
113 (while (and (not skip)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
114 (re-search-forward
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
115 "back[- ]?port\\|merge\\|re-?generate\\|bump version" nil t))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
116 (let ((str (buffer-substring (line-beginning-position)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
117 (line-end-position))))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
118 (when (string-match "\\` *" str)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
119 (setq str (substring str (match-end 0))))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
120 (when (string-match "[.!;, ]+\\'" str)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
121 (setq str (substring str 0 (match-beginning 0))))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
122 (if (save-excursion (y-or-n-p (concat str ": Skip? ")))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
123 (setq skip t))))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
124 (if skip
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
125 (push revno skipped)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
126 (push revno revnos)))))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
127 (delete-region (point) (point-max)))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
128 (cons (nreverse revnos) (nreverse skipped)))))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
129
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
130 (defun bzrmerge-resolve (file)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
131 (unless (file-exists-p file) (error "Bzrmerge-resolve: Can't find %s" file))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
132 (with-demoted-errors
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
133 (let ((exists (find-buffer-visiting file)))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
134 (with-current-buffer (find-file-noselect file)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
135 (if (buffer-modified-p)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
136 (error "Unsaved changes in %s" (current-buffer)))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
137 (save-excursion
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
138 (cond
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
139 ((derived-mode-p 'change-log-mode)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
140 ;; Fix up dates before resolving the conflicts.
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
141 (goto-char (point-min))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
142 (let ((diff-auto-refine-mode nil))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
143 (while (re-search-forward smerge-begin-re nil t)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
144 (smerge-match-conflict)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
145 (smerge-ensure-match 3)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
146 (let ((start1 (match-beginning 1))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
147 (end1 (match-end 1))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
148 (start3 (match-beginning 3))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
149 (end3 (copy-marker (match-end 3) t)))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
150 (goto-char start3)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
151 (while (re-search-forward change-log-start-entry-re end3 t)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
152 (let* ((str (match-string 0))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
153 (newstr (save-match-data
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
154 (concat (add-log-iso8601-time-string)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
155 (when (string-match " *\\'" str)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
156 (match-string 0 str))))))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
157 (replace-match newstr t t)))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
158 ;; change-log-resolve-conflict prefers to put match-1's
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
159 ;; elements first (for equal dates), whereas we want to put
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
160 ;; match-3's first.
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
161 (let ((match3 (buffer-substring start3 end3))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
162 (match1 (buffer-substring start1 end1)))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
163 (delete-region start3 end3)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
164 (goto-char start3)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
165 (insert match1)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
166 (delete-region start1 end1)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
167 (goto-char start1)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
168 (insert match3)))))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
169 ;; (pop-to-buffer (current-buffer)) (debug 'before-resolve)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
170 ))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
171 ;; Try to resolve the conflicts.
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
172 (cond
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
173 ((member file '("configure" "lisp/ldefs-boot.el"))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
174 (call-process "bzr" nil t nil "revert" file)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
175 (revert-buffer nil 'noconfirm))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
176 (t
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
177 (goto-char (point-max))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
178 (while (re-search-backward smerge-begin-re nil t)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
179 (save-excursion
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
180 (ignore-errors
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
181 (smerge-match-conflict)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
182 (smerge-resolve))))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
183 ;; (when (derived-mode-p 'change-log-mode)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
184 ;; (pop-to-buffer (current-buffer)) (debug 'after-resolve))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
185 (save-buffer)))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
186 (goto-char (point-min))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
187 (prog1 (re-search-forward smerge-begin-re nil t)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
188 (unless exists (kill-buffer))))))))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
189
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
190 (defun bzrmerge-add-metadata (from endrevno)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
191 "Add the metadata for a merge of FROM upto ENDREVNO.
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
192 Does not make other difference."
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
193 (if (with-temp-buffer
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
194 (call-process "bzr" nil t nil "status")
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
195 (goto-char (point-min))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
196 (re-search-forward "^conflicts:\n" nil t))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
197 (error "Don't know how to add metadata in the presence of conflicts")
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
198 (call-process "bzr" nil t nil "shelve" "--all"
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
199 "-m" "Bzrmerge shelved merge during skipping")
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
200 (call-process "bzr" nil t nil "revert")
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
201 (call-process "bzr" nil t nil
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
202 "merge" "-r" (format "%s" endrevno) from)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
203 (call-process "bzr" nil t nil "revert" ".")
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
204 (call-process "bzr" nil t nil "unshelve")))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
205
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
206 (defvar bzrmerge-already-done nil)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
207
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
208 (defun bzrmerge-apply (missing from)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
209 (setq from (expand-file-name from))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
210 (with-current-buffer (get-buffer-create "*bzrmerge*")
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
211 (erase-buffer)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
212 (when (equal (cdr bzrmerge-already-done) (list from missing))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
213 (setq missing (car bzrmerge-already-done)))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
214 (setq bzrmerge-already-done nil)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
215 (let ((merge (car missing))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
216 (skip (cdr missing))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
217 beg end)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
218 (when (or merge skip)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
219 (cond
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
220 ((and skip (or (null merge) (< (car skip) (car merge))))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
221 ;; Do a "skip" (i.e. merge the meta-data only).
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
222 (setq beg (1- (car skip)))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
223 (while (and skip (or (null merge) (< (car skip) (car merge))))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
224 (assert (> (car skip) (or end beg)))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
225 (setq end (pop skip)))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
226 (message "Skipping %s..%s" beg end)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
227 (bzrmerge-add-metadata from end))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
228
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
229 (t
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
230 ;; Do a "normal" merge.
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
231 (assert (or (null skip) (< (car merge) (car skip))))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
232 (setq beg (1- (car merge)))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
233 (while (and merge (or (null skip) (< (car merge) (car skip))))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
234 (assert (> (car merge) (or end beg)))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
235 (setq end (pop merge)))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
236 (message "Merging %s..%s" beg end)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
237 (if (with-temp-buffer
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
238 (call-process "bzr" nil t nil "status")
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
239 (zerop (buffer-size)))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
240 (call-process "bzr" nil t nil
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
241 "merge" "-r" (format "%s" end) from)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
242 ;; Stupidly, "bzr merge --force -r A..B" dos not maintain the
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
243 ;; metadata properly except when the checkout is clean.
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
244 (call-process "bzr" nil t nil "merge"
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
245 "--force" "-r" (format "%s..%s" beg end) from)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
246 ;; The merge did not update the metadata, so force the next time
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
247 ;; around to update it (as a "skip").
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
248 (push end skip))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
249 (pop-to-buffer (current-buffer))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
250 (sit-for 1)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
251 ;; (debug 'after-merge)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
252 ;; Check the conflicts.
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
253 (let ((conflicted nil)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
254 (files ()))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
255 (goto-char (point-min))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
256 (when (re-search-forward "bzr: ERROR:" nil t)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
257 (error "Internal Bazaar error!!"))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
258 (while (re-search-forward "^Text conflict in " nil t)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
259 (push (buffer-substring (point) (line-end-position)) files))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
260 (if (re-search-forward "^\\([0-9]+\\) conflicts encountered" nil t)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
261 (if (/= (length files) (string-to-number (match-string 1)))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
262 (setq conflicted t))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
263 (if files (setq conflicted t)))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
264 (dolist (file files)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
265 (if (bzrmerge-resolve file)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
266 (setq conflicted t)))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
267 (when conflicted
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
268 (setq bzrmerge-already-done
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
269 (list (cons merge skip) from missing))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
270 (error "Resolve conflicts manually")))))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
271 (cons merge skip)))))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
272
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
273 (defun bzrmerge (from)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
274 "Merge from branch FROM into `default-directory'."
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
275 (interactive
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
276 (list
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
277 (let ((def
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
278 (with-temp-buffer
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
279 (call-process "bzr" nil t nil "info")
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
280 (goto-char (point-min))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
281 (when (re-search-forward "submit branch: *" nil t)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
282 (buffer-substring (point) (line-end-position))))))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
283 (read-file-name "From branch: " nil nil nil def))))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
284 (message "Merging from %s..." from)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
285 (require 'vc-bzr)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
286 (let ((default-directory (or (vc-bzr-root default-directory)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
287 (error "Not in a Bzr tree"))))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
288 ;; First, check the status.
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
289 (let* ((merges (bzrmerge-merges))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
290 ;; OK, we have the status, now check the missing data.
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
291 (missing (bzrmerge-missing from merges)))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
292 (while missing
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
293 (setq missing (bzrmerge-apply missing from))))))
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
294
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
295 (provide 'bzrmerge)
b0a317b18658 * admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
296 ;;; bzrmerge.el ends here