40 |
;; 3. Provide a list of pairs or triples of file names (or buffers, |
;; 3. Provide a list of pairs or triples of file names (or buffers, |
41 |
;; depending on the particular Ediff operation you want to invoke) |
;; depending on the particular Ediff operation you want to invoke) |
42 |
;; in the following format: |
;; in the following format: |
43 |
;; (descriptor-header (nil nil (obj1 nil) (obj2 nil) (obj3 nil)) |
;; (HEADER (nil nil (obj1 nil) (obj2 nil) (obj3 nil)) |
44 |
;; (...) ...) |
;; (...) ...) |
45 |
;; The function ediff-make-new-meta-list-element can be used to create |
;; The function ediff-make-new-meta-list-element can be used to create |
46 |
;; 2nd and subsequent elements of that list. |
;; 2nd and subsequent elements of that list (i.e., after the |
47 |
;; Actually, the format of this list is pretty much up to the |
;; description header). See ediff-make-new-meta-list-element for the |
48 |
;; developer. The only thing is that it must be a list of lists, |
;; explanation of the two nil placeholders in such elements. |
49 |
;; and the first list must describe the meta session, and subsequent |
;; |
50 |
;; elements must describe individual sessions. |
;; There is API for extracting the components of the members of the |
51 |
;; This descriptor-header must be a list of SIX elements (nil or |
;; above list. Search for `API for ediff-meta-list' for details. |
52 |
;; string). The function ediff-redraw-registry-buffer displays the |
;; |
53 |
|
;; HEADER must be a list of SIX elements (nil or string): |
54 |
|
;; (regexp metaobj1 metaobj2 metaobj3 merge-save-buffer |
55 |
|
;; comparison-function) |
56 |
|
;; The function ediff-redraw-registry-buffer displays the |
57 |
;; 1st - 4th of these in the registry buffer. |
;; 1st - 4th of these in the registry buffer. |
58 |
|
;; For some jobs some of the members of the header might be nil. |
59 |
|
;; The meaning of metaobj1, metaobj2, and metaobj3 depend on the job. |
60 |
|
;; Typically these are directories where the files to be compared are |
61 |
|
;; found. |
62 |
;; Also, keep in mind that the function ediff-prepare-meta-buffer |
;; Also, keep in mind that the function ediff-prepare-meta-buffer |
63 |
;; (which see) prepends the session group buffer to the descriptor, so |
;; (which see) prepends the session group buffer to the descriptor, so |
64 |
;; the descriptor becomes 7-long. |
;; the descriptor becomes 7-long. |
69 |
;; to any of Ediff major entries (such as ediff-files, epatch, etc.). |
;; to any of Ediff major entries (such as ediff-files, epatch, etc.). |
70 |
;; See how this is done in ediff-filegroup-action. |
;; See how this is done in ediff-filegroup-action. |
71 |
;; |
;; |
72 |
;; Session descriptions are of the form (obj1 obj2 obj3), which |
;; Session descriptions are of the form |
73 |
;; describe objects relevant to the session. Usually they are names of |
;; (nil nil (obj1 . nil) (obj2 . nil) (obj3 . nil)) |
74 |
;; files, but sometimes they may be other things. For instance, obj3 |
;; which describe the objects relevant to the session. |
75 |
;; is nil for jobs that involve only two files. For patch jobs, obj2 |
;; Use ediff-make-new-meta-list-element to create these things. |
76 |
;; and obj3 are markers that specify the patch corresponding to the |
;; Usually obj1/2/3 are names of files, but they may also be other |
77 |
;; file (whose name is obj1). |
;; things for some jobs. For instance, obj3 is nil for jobs that |
78 |
|
;; involve only two files. For patch jobs, obj2 and obj3 are markers |
79 |
|
;; that specify the patch corresponding to the file |
80 |
|
;; (whose name is obj1). |
81 |
|
;; The nil's are placeholders, which are used internally by ediff. |
82 |
;; 4. Write a function that makes a call to ediff-prepare-meta-buffer |
;; 4. Write a function that makes a call to ediff-prepare-meta-buffer |
83 |
;; passing all this info. |
;; passing all this info. |
84 |
;; You may be able to use ediff-directories-internal as a template. |
;; You may be able to use ediff-directories-internal as a template. |
290 |
(nth 3 elt)) |
(nth 3 elt)) |
291 |
(defsubst ediff-get-session-objC (elt) |
(defsubst ediff-get-session-objC (elt) |
292 |
(nth 4 elt)) |
(nth 4 elt)) |
293 |
|
;; Take the "name" component of the object into acount. ObjA/C/B is of the form |
294 |
|
;; (name . equality-indicator) |
295 |
(defsubst ediff-get-session-objA-name (elt) |
(defsubst ediff-get-session-objA-name (elt) |
296 |
(car (nth 2 elt))) |
(car (nth 2 elt))) |
297 |
(defsubst ediff-get-session-objB-name (elt) |
(defsubst ediff-get-session-objB-name (elt) |
307 |
;; Create a new element for the meta list out of obj1/2/3, which usually are |
;; Create a new element for the meta list out of obj1/2/3, which usually are |
308 |
;; files |
;; files |
309 |
;; |
;; |
310 |
;; The first nil in such an is later replaced with the session buffer. The |
;; The first nil in such an element is later replaced with the session buffer. |
311 |
;; second nil is reserved for session status. |
;; The second nil is reserved for session status. |
312 |
;; |
;; |
313 |
;; Also, session objects A/B/C are turned into lists of the form (obj nil). |
;; Also, session objects A/B/C are turned into lists of the form (obj nil). |
314 |
;; This nill is a placeholder for eq-indicator. It is either nil or =. |
;; This nil is a placeholder for eq-indicator. It is either nil or =. |
315 |
;; If it is discovered that this file is = to some other |
;; If it is discovered that this file is = to some other |
316 |
;; file in the same session, eq-indicator is changed to `='. |
;; file in the same session, eq-indicator is changed to `='. |
317 |
;; Curently, the eq-indicator is used only for 2 and 3-file jobs. |
;; Curently, the eq-indicator is used only for 2 and 3-file jobs. |
318 |
(defun ediff-make-new-meta-list-element (obj1 obj2 obj3) |
(defun ediff-make-new-meta-list-element (obj1 obj2 obj3) |
319 |
(list nil nil (list obj1 nil) (list obj2 nil) (list obj3 nil))) |
(list nil nil (list obj1 nil) (list obj2 nil) (list obj3 nil))) |
320 |
|
|
321 |
|
;; Constructs a meta list header. |
322 |
|
;; OBJA, OBJB, OBJC are usually directories involved, but can be different for |
323 |
|
;; different jobs. For instance, multifile patch has only OBJA, which is the |
324 |
|
;; patch buffer. |
325 |
|
(defun ediff-make-new-meta-list-header (regexp |
326 |
|
objA objB objC |
327 |
|
merge-auto-store-dir |
328 |
|
comparison-func) |
329 |
|
(list regexp objA objB objC merge-auto-store-dir comparison-func)) |
330 |
|
|
331 |
;; The activity marker is either or + (active session, i.e., ediff is currently |
;; The activity marker is either or + (active session, i.e., ediff is currently |
332 |
;; run in it), or - (finished session, i.e., we've ran ediff in it and then |
;; run in it), or - (finished session, i.e., we've ran ediff in it and then |
333 |
;; exited). Return nil, if session is neither active nor finished |
;; exited). Return nil, if session is neither active nor finished |
509 |
;; If a file is a directory in dir1 but not dir2 (or vice versa), it is not |
;; If a file is a directory in dir1 but not dir2 (or vice versa), it is not |
510 |
;; included in the intersection. However, a regular file that is a dir in dir3 |
;; included in the intersection. However, a regular file that is a dir in dir3 |
511 |
;; is included, since dir3 files are supposed to be ancestors for merging. |
;; is included, since dir3 files are supposed to be ancestors for merging. |
|
;; Returns a list of the form: |
|
|
;; (DIFF-LIST META-HEADER (f1 f2 f3) (f1 f2 f3) ...) |
|
|
;; dir3, f3 can be nil if intersecting only 2 directories. |
|
512 |
;; If COMPARISON-FUNC is given, use it. Otherwise, use string= |
;; If COMPARISON-FUNC is given, use it. Otherwise, use string= |
513 |
|
;; |
514 |
|
;; Returns a list of the form: |
515 |
|
;; (COMMON-PART DIFF-LIST) |
516 |
|
;; COMMON-PART is car and DIFF-LIST is cdr. |
517 |
|
;; |
518 |
|
;; COMMON-PART is of the form: |
519 |
|
;; (META-HEADER (f1 f2 f3) (f1 f2 f3) ...) |
520 |
|
;; f3 can be nil if intersecting only 2 directories. |
521 |
|
;; Each triple (f1 f2 f3) represents the files to be compared in the |
522 |
|
;; corresponding ediff subsession. |
523 |
|
;; |
524 |
;; DIFF-LIST is of the form: |
;; DIFF-LIST is of the form: |
525 |
;; (META-HEADER (file . num) (file . num)...) |
;; (META-HEADER (file . num) (file . num)...) |
526 |
;; where num encodes the set of dirs where the file is found: |
;; where num encodes the set of dirs where the file is found: |
527 |
;; 2 - only dir1; 3 - only dir2; 5 - only dir3; 6 - dir1&2; 10 - dir1&3; etc. |
;; 2 - only dir1; 3 - only dir2; 5 - only dir3; 6 - dir1&2; 10 - dir1&3; etc. |
528 |
;; META-HEADER is of the form |
;; META-HEADER: |
529 |
;; It contains the meta info about this ediff operation |
;; Contains the meta info about this ediff operation |
530 |
;; (regexp dir1 dir2 dir3 merge-auto-store-dir comparison-func) |
;; (regexp dir1 dir2 dir3 merge-auto-store-dir comparison-func) |
531 |
;; Later the meta-buffer is prepended to this list. |
;; Later the meta-buffer is prepended to this list. |
532 |
|
;; |
533 |
|
;; Some operations might use a different meta header. For instance, |
534 |
|
;; ediff-multifile-patch doesn't have dir2 and dir3, and regexp, |
535 |
|
;; comparison-func don't apply. |
536 |
|
;; |
537 |
(defun ediff-intersect-directories (jobname |
(defun ediff-intersect-directories (jobname |
538 |
regexp dir1 dir2 |
regexp dir1 dir2 |
539 |
&optional |
&optional |
609 |
difflist) |
difflist) |
610 |
(setq difflist (cons |
(setq difflist (cons |
611 |
;; diff metalist header |
;; diff metalist header |
612 |
(list regexp |
(ediff-make-new-meta-list-header regexp |
613 |
auxdir1 auxdir2 auxdir3 |
auxdir1 auxdir2 auxdir3 |
614 |
merge-autostore-dir |
merge-autostore-dir |
615 |
comparison-func) |
comparison-func) |
616 |
difflist)) |
difflist)) |
617 |
|
|
618 |
(setq common-part |
(setq common-part |
619 |
(cons |
(cons |
620 |
;; metalist header |
;; metalist header |
621 |
(list regexp |
(ediff-make-new-meta-list-header regexp |
622 |
auxdir1 auxdir2 auxdir3 |
auxdir1 auxdir2 auxdir3 |
623 |
merge-autostore-dir |
merge-autostore-dir |
624 |
comparison-func) |
comparison-func) |
625 |
(mapcar |
(mapcar |
626 |
(lambda (elt) |
(lambda (elt) |
627 |
(ediff-make-new-meta-list-element |
(ediff-make-new-meta-list-element |
689 |
(cons |
(cons |
690 |
;; header -- has 6 elements. Meta buffer is prepended later by |
;; header -- has 6 elements. Meta buffer is prepended later by |
691 |
;; ediff-prepare-meta-buffer |
;; ediff-prepare-meta-buffer |
692 |
(list regexp auxdir1 nil nil merge-autostore-dir nil) |
(ediff-make-new-meta-list-header regexp |
693 |
|
auxdir1 nil nil |
694 |
|
merge-autostore-dir nil) |
695 |
(mapcar (lambda (elt) (ediff-make-new-meta-list-element |
(mapcar (lambda (elt) (ediff-make-new-meta-list-element |
696 |
(concat auxdir1 elt) nil nil)) |
(concat auxdir1 elt) nil nil)) |
697 |
common)) |
common)) |
2261 |
(or (ediff-buffer-live-p session-buf) ; either an active patch session |
(or (ediff-buffer-live-p session-buf) ; either an active patch session |
2262 |
(null session-buf) ; or it is a virgin session |
(null session-buf) ; or it is a virgin session |
2263 |
(error |
(error |
2264 |
"Patch has been already applied to this file--cannot be repeated!")) |
"Patch has already been applied to this file -- can't repeat!")) |
2265 |
|
|
2266 |
(ediff-with-current-buffer meta-patchbuf |
(ediff-with-current-buffer meta-patchbuf |
2267 |
(save-restriction |
(save-restriction |