]> git.neil.brown.name Git - wiggle.git/blob - notes
Disable *all* backups when --no-backups used
[wiggle.git] / notes
1
2 Wiggle - wiggle a mis-match patch into a file.
3
4 Given 
5   1/ a file
6   2/ a patch - which is two file fragments
7
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.
12
13  We read in the file and 2 frags and break them into words and keeping
14  an index and hash for each.
15
16  We then perform the two diffs producing lists of inserts and deletes.
17
18
19
20 ToDo
21
22  implement --replace
23  describe and implement correct replacement procedure
24  Reject matches that have a dis-proportionate cost
25  implement testing structure. DONE
26
27
28
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'
40
41
42 Replacement procedure:
43
44  Goal: Every change between A' and B' must be merged into
45        A somehow to produce B.
46
47         We can think of changes as additions, deletions, or replacements.
48
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.
52
53         Every deletion is merged either by deleting matching text,
54         or inserting the string <<<---deleted-text--->>> and some
55         reasonably appropriate location.
56
57         Every replacement is merged either by removing the original 
58         and replacing by the new, or by inserting 
59         <<<---oldtext///newtext+++>>>
60
61
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:
65
66                 <<<<<<<<<<
67                 segment from A
68                 ||||||||||
69                 b, upto newlines
70                 ==========
71                 c, upto newlines
72                 >>>>>>>>>>
73
74
75         Maybe several (two?) passes.
76
77 -mw orig new new2 in tests/test dies. - FIXED
78
79 in test5, -dw orig new
80  produces strange output FIXED
81
82
83 if no matches are found, core is domps as lcsl is NULL FIXED
84
85 wdiff to look more like udiff
86  unchanged
87 +addition
88 -deletion
89 |change<<<+++additions+++>>> and <<<---deletions--->>>>
90
91
92 @@ line,numbers @@ in diff output
93
94 Speed: us aproxword for pdiff lineup.DONE
95
96 "refine" takes a diff and refines it, sortof
97
98 return a lcsl when reading a patch and refine that
99 rather than computing from scratch.
100
101 FIXME: pdiff should pick best bit, and rediff the two sides. DONE
102
103 ---------------------------------
104 Thoughts about editing a merge.
105
106 When viewing a merge we might decide that:
107
108  - a change is not wanted
109  - a conflict should be resolved for the original
110  - a conflict should be resolved for the new
111
112  - some text needs to be edited in place
113  - a change should be applied against a different place in the original
114
115  - These can apply to a single change, to a line, or to
116    a chunk
117
118 We can achieve most of these by changing the merge result,
119 e.g. Changed to Unchanged or Conflict to one of the above.
120
121 Moving a chunk will require shuffling the merger array.
122
123 Replacing text is probably best done with a special merge type??
124
125 Selecting the region to act on is awkward.  Need to track 'current'
126 merge point for cursor.  Maybe insert  $$ at other end??
127
128 How about:
129  press E
130  current change is surrounded with '$'
131  cursor movement can extend the range
132  K to keep original
133  C to change
134  R to retype