Fossil

Diff
Login

Differences From Artifact [b873b0bdd0]:

To Artifact [08f55239e2]:


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
50
51
52
53
54
55
56

57

58
59

60

61
62
63

64

65
66
67
68
69
70
71







-
+
-


-
+
-



-
+
-







*/
void delta_create_cmd(void){
  Blob orig, target, delta;
  if( g.argc!=5 ){
    usage("ORIGIN TARGET DELTA");
  }
  if( blob_read_from_file(&orig, g.argv[2])<0 ){
    fprintf(stderr,"cannot read %s\n", g.argv[2]);
    fossil_fatal("cannot read %s\n", g.argv[2]);
    fossil_exit(1);
  }
  if( blob_read_from_file(&target, g.argv[3])<0 ){
    fprintf(stderr,"cannot read %s\n", g.argv[3]);
    fossil_fatal("cannot read %s\n", g.argv[3]);
    fossil_exit(1);
  }
  blob_delta_create(&orig, &target, &delta);
  if( blob_write_to_file(&delta, g.argv[4])<blob_size(&delta) ){
    fprintf(stderr,"cannot write %s\n", g.argv[4]);
    fossil_fatal("cannot write %s\n", g.argv[4]);
    fossil_exit(1);
  }
  blob_reset(&orig);
  blob_reset(&target);
  blob_reset(&delta);
}

/*
112
113
114
115
116
117
118
119

120
121
122
123

124
125
126
127
128

129
130
131
132
133
134
135
136
109
110
111
112
113
114
115

116

117
118

119

120
121
122

123

124
125
126
127
128
129
130







-
+
-


-
+
-



-
+
-







*/
void delta_apply_cmd(void){
  Blob orig, target, delta;
  if( g.argc!=5 ){
    usage("ORIGIN DELTA TARGET");
  }
  if( blob_read_from_file(&orig, g.argv[2])<0 ){
    fprintf(stderr,"cannot read %s\n", g.argv[2]);
    fossil_fatal("cannot read %s\n", g.argv[2]);
    fossil_exit(1);
  }
  if( blob_read_from_file(&delta, g.argv[3])<0 ){
    fprintf(stderr,"cannot read %s\n", g.argv[3]);
    fossil_fatal("cannot read %s\n", g.argv[3]);
    fossil_exit(1);
  }
  blob_delta_apply(&orig, &delta, &target);
  if( blob_write_to_file(&target, g.argv[4])<blob_size(&target) ){
    fprintf(stderr,"cannot write %s\n", g.argv[4]);
    fossil_fatal("cannot write %s\n", g.argv[4]);
    fossil_exit(1);
  }
  blob_reset(&orig);
  blob_reset(&target);
  blob_reset(&delta);
}

/*
150
151
152
153
154
155
156
157

158
144
145
146
147
148
149
150

151
152







-
+

  blob_delta_create(&f1, &f2, &d12);
  blob_delta_create(&f2, &f1, &d21);
  blob_delta_apply(&f1, &d12, &a2);
  blob_delta_apply(&f2, &d21, &a1);
  if( blob_compare(&f1,&a1) || blob_compare(&f2, &a2) ){
    fossil_panic("delta test failed");
  }
  printf("ok\n");
  fossil_print("ok\n");
}