File: notes

package info (click to toggle)
wiggle 1.0%2B20140408%2Bgit920f58a-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 3,872 kB
  • ctags: 752
  • sloc: ansic: 13,408; sh: 1,179; makefile: 167
file content (134 lines) | stat: -rw-r--r-- 3,518 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134

Wiggle - wiggle a mis-match patch into a file.

Given 
  1/ a file
  2/ a patch - which is two file fragments

 find the minimal differences between the fragments in the patch
 and apply those to the file.
 This requires us to do a word-diff of file with frag-A, and 
 frag-A with frag-B, and the merge the result.

 We read in the file and 2 frags and break them into words and keeping
 an index and hash for each.

 We then perform the two diffs producing lists of inserts and deletes.



ToDo

 implement --replace
 describe and implement correct replacement procedure
 Reject matches that have a dis-proportionate cost
 implement testing structure. DONE



Testing:
 A directory tree containing tests.  We look for key files
 and run the appropriate test.
 Key files are:
   script : run that script in that directory
   diff   : if new exists, diff orig with new
            else diff 'orig' with -1 of 'patch'
   ldiff  : as above, but lines
   rediff : rediff 'patch'
   merge  : if 'patch'  merge 'orig' with 'patch'
	    else merge 'orig' 'new' 'new2'


Replacement procedure:

 Goal: Every change between A' and B' must be merged into
       A somehow to produce B.

	We can think of changes as additions, deletions, or replacements.

	Every addition must be inserted somewhere, at the site of 
	best match for the context.  If there is no good match...
	I guess we insert at start or finish.

	Every deletion is merged either by deleting matching text,
	or inserting the string <<<---deleted-text--->>> and some
	reasonably appropriate location.

	Every replacement is merged either by removing the original 
	and replacing by the new, or by inserting 
	<<<---oldtext///newtext+++>>>


       For each difference b->c between B and C:
         if b precisely aligns with a in A, then replace a with c
	 else find some set of lines that b maybe is in and produce:

              	<<<<<<<<<<
		segment from A
		||||||||||
		b, upto newlines
		==========
		c, upto newlines
		>>>>>>>>>>


	Maybe several (two?) passes.

-mw orig new new2 in tests/test dies. - FIXED

in test5, -dw orig new
 produces strange output FIXED


if no matches are found, core is domps as lcsl is NULL FIXED

wdiff to look more like udiff
 unchanged
+addition
-deletion
|change<<<+++additions+++>>> and <<<---deletions--->>>>


@@ line,numbers @@ in diff output

Speed: us aproxword for pdiff lineup.DONE

"refine" takes a diff and refines it, sortof

return a lcsl when reading a patch and refine that
rather than computing from scratch.

FIXME: pdiff should pick best bit, and rediff the two sides. DONE

---------------------------------
Thoughts about editing a merge.

When viewing a merge we might decide that:

 - a change is not wanted
 - a conflict should be resolved for the original
 - a conflict should be resolved for the new

 - some text needs to be edited in place
 - a change should be applied against a different place in the original

 - These can apply to a single change, to a line, or to
   a chunk

We can achieve most of these by changing the merge result,
e.g. Changed to Unchanged or Conflict to one of the above.

Moving a chunk will require shuffling the merger array.

Replacing text is probably best done with a special merge type??

Selecting the region to act on is awkward.  Need to track 'current'
merge point for cursor.  Maybe insert  $$ at other end??

How about:
 press E
 current change is surrounded with '$'
 cursor movement can extend the range
 K to keep original
 C to change
 R to retype