Mercurial > emacs
annotate admin/bzrmerge.el @ 112425:9f7614f1a892
Merge from emacs-23
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Sat, 22 Jan 2011 11:36:45 -0800 |
parents | c22f11c3d8ba |
children |
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 |
112194
978fe18f0882
* admin/bzrmerge.el: Standardize copyright and license headers.
Glenn Morris <rgm@gnu.org>
parents:
112018
diff
changeset
|
3 ;; Copyright (C) 2010, 2011 Free Software Foundation, Inc. |
112018
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 |
112194
978fe18f0882
* admin/bzrmerge.el: Standardize copyright and license headers.
Glenn Morris <rgm@gnu.org>
parents:
112018
diff
changeset
|
8 ;; GNU Emacs is free software: you can redistribute it and/or modify |
112018
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 |
112194
978fe18f0882
* admin/bzrmerge.el: Standardize copyright and license headers.
Glenn Morris <rgm@gnu.org>
parents:
112018
diff
changeset
|
13 ;; GNU Emacs is distributed in the hope that it will be useful, |
112018
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 |
112194
978fe18f0882
* admin/bzrmerge.el: Standardize copyright and license headers.
Glenn Morris <rgm@gnu.org>
parents:
112018
diff
changeset
|
19 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
112018
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 |
112215
1fd3710e6845
* admin/bzrmerge.el: Require cl when compiling.
Glenn Morris <rgm@gnu.org>
parents:
112194
diff
changeset
|
27 (eval-when-compile |
1fd3710e6845
* admin/bzrmerge.el: Require cl when compiling.
Glenn Morris <rgm@gnu.org>
parents:
112194
diff
changeset
|
28 (require 'cl)) ; assert |
1fd3710e6845
* admin/bzrmerge.el: Require cl when compiling.
Glenn Morris <rgm@gnu.org>
parents:
112194
diff
changeset
|
29 |
112018
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
30 (defun bzrmerge-merges () |
112215
1fd3710e6845
* admin/bzrmerge.el: Require cl when compiling.
Glenn Morris <rgm@gnu.org>
parents:
112194
diff
changeset
|
31 "Return the list of already merged (not yet committed) revisions. |
112018
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
32 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
|
33 (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
|
34 (erase-buffer) |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
35 ;; 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
|
36 ;; 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
|
37 ;; not yet committed). |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
38 (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
|
39 (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
|
40 (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
|
41 (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
|
42 (let ((merges ())) |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
43 (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
|
44 (when (save-excursion |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
45 (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
|
46 (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
|
47 (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
|
48 ;; 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
|
49 ;; 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
|
50 ;; 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
|
51 ;; very machine-friendly. |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
52 (while (not (eobp)) |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
53 (skip-chars-forward " ") |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
54 (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
|
55 (forward-line 1))) |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
56 merges))) |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
57 |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
58 (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
|
59 ;; 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
|
60 ;; 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
|
61 ;; "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
|
62 ;; 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
|
63 (let ((author |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
64 (or |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
65 (save-excursion |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
66 (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
|
67 nil t) |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
68 (match-string 1))) |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
69 (save-excursion |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
70 (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
|
71 "^committer: *\\([^<]*[^< ]\\) +<" nil t) |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
72 (match-string 1))))) |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
73 (timestamp |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
74 (save-excursion |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
75 (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
|
76 "^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
|
77 (match-string 1)))) |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
78 (line1 |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
79 (save-excursion |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
80 (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
|
81 (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
|
82 ;; 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
|
83 ;; 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
|
84 (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
|
85 (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
|
86 (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
|
87 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
|
88 (string-prefix-p |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
89 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
|
90 |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
91 (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
|
92 "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
|
93 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
|
94 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
|
95 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
|
96 (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
|
97 (erase-buffer) |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
98 (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
|
99 (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
|
100 (let ((revnos ()) (skipped ())) |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
101 (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
|
102 (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
|
103 (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
|
104 (save-excursion |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
105 (if merges |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
106 (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
|
107 (unless merges |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
108 (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
|
109 (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
|
110 (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
|
111 (skip nil)) |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
112 (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
|
113 (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
|
114 (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
|
115 (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
|
116 (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
|
117 (re-search-forward |
112271 | 118 "back[- ]?port\\|merge\\|sync\\|re-?generate\\|bump version" nil t)) |
112018
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
119 (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
|
120 (line-end-position)))) |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
121 (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
|
122 (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
|
123 (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
|
124 (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
|
125 (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
|
126 (setq skip t)))) |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
127 (if skip |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
128 (push revno skipped) |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
129 (push revno revnos))))) |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
130 (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
|
131 (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
|
132 |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
133 (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
|
134 (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
|
135 (with-demoted-errors |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
136 (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
|
137 (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
|
138 (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
|
139 (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
|
140 (save-excursion |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
141 (cond |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
142 ((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
|
143 ;; 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
|
144 (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
|
145 (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
|
146 (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
|
147 (smerge-match-conflict) |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
148 (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
|
149 (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
|
150 (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
|
151 (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
|
152 (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
|
153 (goto-char start3) |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
154 (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
|
155 (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
|
156 (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
|
157 (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
|
158 (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
|
159 (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
|
160 (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
|
161 ;; 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
|
162 ;; 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
|
163 ;; 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
|
164 (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
|
165 (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
|
166 (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
|
167 (goto-char start3) |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
168 (insert match1) |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
169 (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
|
170 (goto-char start1) |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
171 (insert match3))))) |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
172 ;; (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
|
173 )) |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
174 ;; 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
|
175 (cond |
112271 | 176 ((member file '("configure" "lisp/ldefs-boot.el" |
177 "lisp/emacs-lisp/cl-loaddefs.el")) | |
112018
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
178 (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
|
179 (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
|
180 (t |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
181 (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
|
182 (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
|
183 (save-excursion |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
184 (ignore-errors |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
185 (smerge-match-conflict) |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
186 (smerge-resolve)))) |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
187 ;; (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
|
188 ;; (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
|
189 (save-buffer))) |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
190 (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
|
191 (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
|
192 (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
|
193 |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
194 (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
|
195 "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
|
196 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
|
197 (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
|
198 (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
|
199 (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
|
200 (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
|
201 (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
|
202 (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
|
203 "-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
|
204 (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
|
205 (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
|
206 "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
|
207 (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
|
208 (call-process "bzr" nil t nil "unshelve"))) |
112194
978fe18f0882
* admin/bzrmerge.el: Standardize copyright and license headers.
Glenn Morris <rgm@gnu.org>
parents:
112018
diff
changeset
|
209 |
112018
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
210 (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
|
211 |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
212 (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
|
213 (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
|
214 (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
|
215 (erase-buffer) |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
216 (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
|
217 (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
|
218 (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
|
219 (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
|
220 (skip (cdr missing)) |
112336
7e5855ddf3f2
* admin/bzrmerge.el (bzrmerge-apply): Warn the user when the tree might be in
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
112271
diff
changeset
|
221 (unsafe nil) |
112018
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
222 beg end) |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
223 (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
|
224 (cond |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
225 ((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
|
226 ;; 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
|
227 (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
|
228 (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
|
229 (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
|
230 (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
|
231 (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
|
232 (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
|
233 |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
234 (t |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
235 ;; 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
|
236 (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
|
237 (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
|
238 (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
|
239 (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
|
240 (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
|
241 (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
|
242 (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
|
243 (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
|
244 (zerop (buffer-size))) |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
245 (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
|
246 "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
|
247 ;; 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
|
248 ;; 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
|
249 (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
|
250 "--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
|
251 ;; 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
|
252 ;; around to update it (as a "skip"). |
112336
7e5855ddf3f2
* admin/bzrmerge.el (bzrmerge-apply): Warn the user when the tree might be in
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
112271
diff
changeset
|
253 (setq unsafe t) |
112018
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
254 (push end skip)) |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
255 (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
|
256 (sit-for 1) |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
257 ;; (debug 'after-merge) |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
258 ;; Check the conflicts. |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
259 (let ((conflicted nil) |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
260 (files ())) |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
261 (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
|
262 (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
|
263 (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
|
264 (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
|
265 (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
|
266 (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
|
267 (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
|
268 (setq conflicted t)) |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
269 (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
|
270 (dolist (file files) |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
271 (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
|
272 (setq conflicted t))) |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
273 (when conflicted |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
274 (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
|
275 (list (cons merge skip) from missing)) |
112336
7e5855ddf3f2
* admin/bzrmerge.el (bzrmerge-apply): Warn the user when the tree might be in
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
112271
diff
changeset
|
276 (if unsafe |
7e5855ddf3f2
* admin/bzrmerge.el (bzrmerge-apply): Warn the user when the tree might be in
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
112271
diff
changeset
|
277 ;; FIXME: Obviously, we'd rather make it right rather |
7e5855ddf3f2
* admin/bzrmerge.el (bzrmerge-apply): Warn the user when the tree might be in
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
112271
diff
changeset
|
278 ;; than output such a warning. But I don't know how to add |
7e5855ddf3f2
* admin/bzrmerge.el (bzrmerge-apply): Warn the user when the tree might be in
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
112271
diff
changeset
|
279 ;; the metadata to bzr's since the technique used in |
7e5855ddf3f2
* admin/bzrmerge.el (bzrmerge-apply): Warn the user when the tree might be in
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
112271
diff
changeset
|
280 ;; bzrmerge-add-metadata does not work when there |
7e5855ddf3f2
* admin/bzrmerge.el (bzrmerge-apply): Warn the user when the tree might be in
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
112271
diff
changeset
|
281 ;; are conflicts. |
7e5855ddf3f2
* admin/bzrmerge.el (bzrmerge-apply): Warn the user when the tree might be in
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
112271
diff
changeset
|
282 (display-warning 'bzrmerge "Resolve conflicts manually. |
7e5855ddf3f2
* admin/bzrmerge.el (bzrmerge-apply): Warn the user when the tree might be in
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
112271
diff
changeset
|
283 ¡BEWARE! Important metadata is kept in this Emacs session! |
112342
c22f11c3d8ba
* admin/bzrmerge.el: Fix paren typo in previous.
Glenn Morris <rgm@gnu.org>
parents:
112336
diff
changeset
|
284 Do not commit without re-running `M-x bzrmerge' first!")) |
112018
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
285 (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
|
286 (cons merge skip))))) |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
287 |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
288 (defun bzrmerge (from) |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
289 "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
|
290 (interactive |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
291 (list |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
292 (let ((def |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
293 (with-temp-buffer |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
294 (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
|
295 (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
|
296 (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
|
297 (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
|
298 (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
|
299 (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
|
300 (require 'vc-bzr) |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
301 (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
|
302 (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
|
303 ;; 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
|
304 (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
|
305 ;; 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
|
306 (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
|
307 (while missing |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
308 (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
|
309 |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
310 (provide 'bzrmerge) |
b0a317b18658
* admin/bzrmerge.el: New file to help merge branches while skipping
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
311 ;;; bzrmerge.el ends here |