changeset 62:c82a8743fd48

taking notes on how to merge
author Henry S. Thompson <ht@inf.ed.ac.uk>
date Thu, 14 Dec 2023 00:13:19 +0000
parents 19262b15a099
children 721bd7a04efb
files repair.py
diffstat 1 files changed, 47 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/repair.py	Wed Dec 13 17:32:38 2023 +0000
+++ b/repair.py	Thu Dec 14 00:13:19 2023 +0000
@@ -13,10 +13,18 @@
     k = ll.pop(0)
     n = ll.pop(0)
     t = ll.pop(0)
-    pp = dict((a[0],a[1:]) for a in ll.pop(0)) if ll else None
+    if ll:
+      pp = ll.pop(0)
+      if pp[0] == '(':
+        pp = dict((a[0],a[1:]) for a in pp)
+      # Otherwise only "nil", I think, so pass through
+    else:
+      pp = None
     res[eval(k)]=(n, t, pp, ll)
   return res
 
+# alist fields are: group, rank, read, marks, method, params
+                                                    
 def p2l(pl, f, top = False):
   if isinstance(pl,list) or isinstance(pl,tuple):
     if len(pl) == 0:
@@ -44,11 +52,18 @@
         space = True
       if top:
         f.write('"%s"'%k)
+        for e in v[:3]: # v is [n, t, pp, ll], pp may be None
+          if e:
+            f.write(' ')
+            p2l(e,f)
+        # ll may be empty
+        for e in v[3]:
+          if e:
+            f.write(' ')
+            p2l(e,f)
       else:
         f.write(k)
-      for e in v:
-        if e:
-          # 4th tuple, from tail of original (ref 'll' in alist), may be empty
+        for e in v:
           f.write(' ')
           p2l(e,f)
       f.write(')')
@@ -64,6 +79,33 @@
         int(pl)
         f.write(pl)
       except ValueError:
-        f.write('"%s"'%pl)
+        f.write(pl)
   else:
     f.write(pl)
+
+def merge(gnus, mail):
+  '''
+   rank, read, marks, method, params
+   
+   read is everything that is unmarked (nothing in left column)
+   marks.seen is everything that has ever been looked it and not DELETED
+   marks.tick is a !, marks.forward is F, marks.reply is A.
+
+   rank: deeper in gnus wins
+   read: if unequal
+           if mail is nil, use gnus
+           otherwise use mail
+   marks: merge unseen keys, unequal values for same key prefer gnus
+          EXCEPT bogus, w3c-ac-forum, handle by hand
+   method: change "ht" to "nnml+ht", flag anything else
+   params: TBD
+
+ Comparison tool:
+
+   export P='\(nil\|(\(\([0-9]\+\|([^)]*)\) \?\)*)\)'
+   paste <(cat shared) <(fgrep -f shared mail/alist.fixed | sed 's/ \([0-9]\) '"$P $P/ \1  \2      \5      /g" | cut -f 3)  <(fgrep -f shared gnus/alist.fixed | sed 's/ \([0-9]\) '"$P $P/ \1     \2      \5      /g" | cut -f 3) | { IFS='       ' ; while read gn g m; do if [ "$g" != "$m" ]; then printf "=----%s------\n%s\n%s\n" "$gn" "$g" "$m"; fi; done ; } | less
+
+ Watch out for tabs!
+ To look for overlap, change 2nd \n in printf to \t
+
+'''