emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/ebdb be9464d 319/350: When merging organization records


From: Eric Abrahamsen
Subject: [elpa] externals/ebdb be9464d 319/350: When merging organization records, possibly merge role fields
Date: Mon, 14 Aug 2017 11:47:02 -0400 (EDT)

branch: externals/ebdb
commit be9464d940ef53213e31db94510ed44ee85a9e1f
Author: Eric Abrahamsen <address@hidden>
Commit: Eric Abrahamsen <address@hidden>

    When merging organization records, possibly merge role fields
    
    * ebdb.el (ebdb-merge): When two organizations are merged, it's
      reasonable to expect that role fields pointing to both orgs should
      be preserved and moved to point to the "new" org. Ask the user if
      that's the case.
---
 ebdb.el | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/ebdb.el b/ebdb.el
index 583794d..3181591 100644
--- a/ebdb.el
+++ b/ebdb.el
@@ -2648,12 +2648,22 @@ priority."
                          (right ebdb-record-organization)
                          &optional auto)
   "Merge organization RIGHT into LEFT, and return LEFT."
-  (with-slots (name domain) right
-    (when (or auto (yes-or-no-p (format "Use name %s? " (ebdb-string name))))
-      (ebdb-record-change-name left name))
-    (when (and domain
-              (or auto (yes-or-no-p (format "Use domain %s? " domain))))
-      (setf (slot-value left 'domain) domain)))
+  (let ((roles (append (gethash (ebdb-record-uuid left) ebdb-org-hashtable)
+                      (gethash (ebdb-record-uuid right) ebdb-org-hashtable)))
+       (l-uuid (ebdb-record-uuid left)))
+    (with-slots (name domain) right
+      (when (or auto (yes-or-no-p (format "Use name %s? " (ebdb-string name))))
+       (ebdb-record-change-name left name))
+      (when (and domain
+                (or auto (yes-or-no-p (format "Use domain %s? " domain))))
+       (setf (slot-value left 'domain) domain)))
+    (when (and roles (or auto (yes-or-no-p
+                              (format "Move all person roles from %s to %s"
+                                      (ebdb-string right)
+                                      (ebdb-string left)))))
+      (dolist (r roles)
+       (setf (slot-value r 'org-uuid) l-uuid))
+      (puthash l-uuid roles ebdb-org-hashtable)))
   (cl-call-next-method))
 
 (cl-defmethod ebdb-record-field-slot-query ((class (subclass 
ebdb-record-organization))



reply via email to

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