Still more updates to 'p'
[wiggle.git] / notes
blobe5922d2f60fb8476df71c103b634802a2072a01e
2 Wiggle - wiggle a mis-match patch into a file.
4 Given 
5   1/ a file
6   2/ a patch - which is two file fragments
8  find the minimal differences between the fragments in the patch
9  and apply those to the file.
10  This requires us to do a word-diff of file with frag-A, and 
11  frag-A with frag-B, and the merge the result.
13  We read in the file and 2 frags and break them into words and keeping
14  an index and hash for each.
16  We then perform the two diffs producing lists of inserts and deletes.
20 ToDo
22  implement --replace
23  describe and implement correct replacement procedure
24  Reject matches that have a dis-proportionate cost
25  implement testing structure. DONE
29 Testing:
30  A directory tree containing tests.  We look for key files
31  and run the appropriate test.
32  Key files are:
33    script : run that script in that directory
34    diff   : if new exists, diff orig with new
35             else diff 'orig' with -1 of 'patch'
36    ldiff  : as above, but lines
37    rediff : rediff 'patch'
38    merge  : if 'patch'  merge 'orig' with 'patch'
39             else merge 'orig' 'new' 'new2'
42 Replacement procedure:
44  Goal: Every change between A' and B' must be merged into
45        A somehow to produce B.
47         We can think of changes as additions, deletions, or replacements.
49         Every addition must be inserted somewhere, at the site of 
50         best match for the context.  If there is no good match...
51         I guess we insert at start or finish.
53         Every deletion is merged either by deleting matching text,
54         or inserting the string <<<---deleted-text--->>> and some
55         reasonably appropriate location.
57         Every replacement is merged either by removing the original 
58         and replacing by the new, or by inserting 
59         <<<---oldtext///newtext+++>>>
62        For each difference b->c between B and C:
63          if b precisely aligns with a in A, then replace a with c
64          else find some set of lines that b maybe is in and produce:
66                 <<<<<<<<<<
67                 segment from A
68                 ||||||||||
69                 b, upto newlines
70                 ==========
71                 c, upto newlines
72                 >>>>>>>>>>
75         Maybe several (two?) passes.
77 -mw orig new new2 in tests/test dies. - FIXED
79 in test5, -dw orig new
80  produces strange output FIXED
83 if no matches are found, core is domps as lcsl is NULL FIXED
85 wdiff to look more like udiff
86  unchanged
87 +addition
88 -deletion
89 |change<<<+++additions+++>>> and <<<---deletions--->>>>
92 @@ line,numbers @@ in diff output
94 Speed: us aproxword for pdiff lineup.DONE
96 "refine" takes a diff and refines it, sortof
98 return a lcsl when reading a patch and refine that
99 rather than computing from scratch.
101 FIXME: pdiff should pick best bit, and rediff the two sides. DONE