Fossil SCM

Added a gdiff command. diff command now runs config diff-command, gdiff command (graphical diff) now runs config gdiff-command. With both, if -i is supplied, internal diff is used. With both, if they are not configured, internal diff is used. Fixed bug with internal diff giving files in reverse order. Also put div id="sub-menu" inside of submenu if, as to not display the sub menu if no sub menu items exist

jnc 2007-09-24 14:02 trunk
Commit 01ce2cf3dc8949a16646fecaa3f48bd353fe12d7
2 files changed +28 -14 +2 -2
+28 -14
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -42,49 +42,63 @@
4242
}
4343
}
4444
4545
/*
4646
** COMMAND: diff
47
+** COMMAND: gdiff
4748
**
48
-** Usage: %fossil diff ?-i FILE...
49
+** Usage: %fossil diff|gdiff ?-i FILE...
4950
**
5051
** Show the difference between the current version of a file (as it
5152
** exists on disk) and that same file as it was checked out.
52
-** If -i is supplied, the internal diff command will be executed
53
-** otherwise, fossil attempts to use the user configured diff-command.
53
+**
54
+** diff will show a textual diff while gdiff will attempt to run a
55
+** graphical diff command that you have setup. If the choosen command
56
+** is not yet configured, the internal textual diff command will be
57
+** used.
58
+**
59
+** If -i is supplied for either diff or gdiff, the internal textual
60
+** diff command will be executed.
5461
**
5562
** Here are a few external diff command settings, for example:
5663
**
57
-** %fossil config diff-command=tkdiff
58
-** %fossil config diff-command=eskill22
59
-** %fossil config diff-command=tortoisemerge
60
-** %fossil config diff-command=meld
61
-** %fossil config diff-command=xxdiff
62
-** %fossil config diff-command=kdiff3
64
+** %fossil config diff-command=diff
65
+**
66
+** %fossil config gdiff-command=tkdiff
67
+** %fossil config gdiff-command=eskill22
68
+** %fossil config gdiff-command=tortoisemerge
69
+** %fossil config gdiff-command=meld
70
+** %fossil config gdiff-command=xxdiff
71
+** %fossil config gdiff-command=kdiff3
6372
*/
6473
void diff_cmd(void){
6574
const char *zFile;
6675
Blob cmd;
6776
Blob fname;
6877
int i, internalDiff;
6978
char *zV1 = 0;
7079
char *zV2 = 0;
7180
72
- internalDiff = find_option("intertal","i",0)!=0;
81
+ internalDiff = find_option("internal","i",0)!=0;
7382
7483
if( g.argc<3 ){
7584
usage("?OPTIONS? FILE");
7685
}
7786
db_must_be_within_tree();
7887
7988
if( internalDiff==0 ){
80
- const char *zExternalCommand = db_global_get("diff-command", 0);
89
+ const char *zExternalCommand;
90
+ if( strcmp(g.argv[1], "diff")==0 ){
91
+ zExternalCommand = db_global_get("diff-command", 0);
92
+ }else{
93
+ zExternalCommand = db_global_get("gdiff-command", 0);
94
+ }
8195
if( zExternalCommand==0 ){
8296
internalDiff=1;
8397
}
84
- blob_zero(&cmd);
85
- blob_appendf(&cmd, "%s ", zExternalCommand);
98
+ blob_zero(&cmd);
99
+ blob_appendf(&cmd, "%s ", zExternalCommand);
86100
}
87101
for(i=2; i<g.argc-1; i++){
88102
const char *z = g.argv[i];
89103
if( (strcmp(z,"-v")==0 || strcmp(z,"--version")==0) && i<g.argc-2 ){
90104
if( zV1==0 ){
@@ -123,11 +137,11 @@
123137
Blob current;
124138
Blob out;
125139
blob_zero(&current);
126140
blob_read_from_file(&current, zFile);
127141
blob_zero(&out);
128
- unified_diff(&current, &record, 5, &out);
142
+ unified_diff(&record, &current, 5, &out);
129143
printf("%s\n", blob_str(&out));
130144
blob_reset(&current);
131145
blob_reset(&out);
132146
}else{
133147
blob_write_to_file(&record, blob_str(&vname));
134148
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -42,49 +42,63 @@
42 }
43 }
44
45 /*
46 ** COMMAND: diff
 
47 **
48 ** Usage: %fossil diff ?-i FILE...
49 **
50 ** Show the difference between the current version of a file (as it
51 ** exists on disk) and that same file as it was checked out.
52 ** If -i is supplied, the internal diff command will be executed
53 ** otherwise, fossil attempts to use the user configured diff-command.
 
 
 
 
 
 
54 **
55 ** Here are a few external diff command settings, for example:
56 **
57 ** %fossil config diff-command=tkdiff
58 ** %fossil config diff-command=eskill22
59 ** %fossil config diff-command=tortoisemerge
60 ** %fossil config diff-command=meld
61 ** %fossil config diff-command=xxdiff
62 ** %fossil config diff-command=kdiff3
 
 
63 */
64 void diff_cmd(void){
65 const char *zFile;
66 Blob cmd;
67 Blob fname;
68 int i, internalDiff;
69 char *zV1 = 0;
70 char *zV2 = 0;
71
72 internalDiff = find_option("intertal","i",0)!=0;
73
74 if( g.argc<3 ){
75 usage("?OPTIONS? FILE");
76 }
77 db_must_be_within_tree();
78
79 if( internalDiff==0 ){
80 const char *zExternalCommand = db_global_get("diff-command", 0);
 
 
 
 
 
81 if( zExternalCommand==0 ){
82 internalDiff=1;
83 }
84 blob_zero(&cmd);
85 blob_appendf(&cmd, "%s ", zExternalCommand);
86 }
87 for(i=2; i<g.argc-1; i++){
88 const char *z = g.argv[i];
89 if( (strcmp(z,"-v")==0 || strcmp(z,"--version")==0) && i<g.argc-2 ){
90 if( zV1==0 ){
@@ -123,11 +137,11 @@
123 Blob current;
124 Blob out;
125 blob_zero(&current);
126 blob_read_from_file(&current, zFile);
127 blob_zero(&out);
128 unified_diff(&current, &record, 5, &out);
129 printf("%s\n", blob_str(&out));
130 blob_reset(&current);
131 blob_reset(&out);
132 }else{
133 blob_write_to_file(&record, blob_str(&vname));
134
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -42,49 +42,63 @@
42 }
43 }
44
45 /*
46 ** COMMAND: diff
47 ** COMMAND: gdiff
48 **
49 ** Usage: %fossil diff|gdiff ?-i FILE...
50 **
51 ** Show the difference between the current version of a file (as it
52 ** exists on disk) and that same file as it was checked out.
53 **
54 ** diff will show a textual diff while gdiff will attempt to run a
55 ** graphical diff command that you have setup. If the choosen command
56 ** is not yet configured, the internal textual diff command will be
57 ** used.
58 **
59 ** If -i is supplied for either diff or gdiff, the internal textual
60 ** diff command will be executed.
61 **
62 ** Here are a few external diff command settings, for example:
63 **
64 ** %fossil config diff-command=diff
65 **
66 ** %fossil config gdiff-command=tkdiff
67 ** %fossil config gdiff-command=eskill22
68 ** %fossil config gdiff-command=tortoisemerge
69 ** %fossil config gdiff-command=meld
70 ** %fossil config gdiff-command=xxdiff
71 ** %fossil config gdiff-command=kdiff3
72 */
73 void diff_cmd(void){
74 const char *zFile;
75 Blob cmd;
76 Blob fname;
77 int i, internalDiff;
78 char *zV1 = 0;
79 char *zV2 = 0;
80
81 internalDiff = find_option("internal","i",0)!=0;
82
83 if( g.argc<3 ){
84 usage("?OPTIONS? FILE");
85 }
86 db_must_be_within_tree();
87
88 if( internalDiff==0 ){
89 const char *zExternalCommand;
90 if( strcmp(g.argv[1], "diff")==0 ){
91 zExternalCommand = db_global_get("diff-command", 0);
92 }else{
93 zExternalCommand = db_global_get("gdiff-command", 0);
94 }
95 if( zExternalCommand==0 ){
96 internalDiff=1;
97 }
98 blob_zero(&cmd);
99 blob_appendf(&cmd, "%s ", zExternalCommand);
100 }
101 for(i=2; i<g.argc-1; i++){
102 const char *z = g.argv[i];
103 if( (strcmp(z,"-v")==0 || strcmp(z,"--version")==0) && i<g.argc-2 ){
104 if( zV1==0 ){
@@ -123,11 +137,11 @@
137 Blob current;
138 Blob out;
139 blob_zero(&current);
140 blob_read_from_file(&current, zFile);
141 blob_zero(&out);
142 unified_diff(&record, &current, 5, &out);
143 printf("%s\n", blob_str(&out));
144 blob_reset(&current);
145 blob_reset(&out);
146 }else{
147 blob_write_to_file(&record, blob_str(&vname));
148
+2 -2
--- src/style.c
+++ src/style.c
@@ -107,12 +107,12 @@
107107
}
108108
if( !g.noPswd ){
109109
@ | <a href="%s(g.zBaseURL)/login">%s(zLogInOut)</a>
110110
}
111111
@ </div>
112
- @ <div id="sub-menu">
113112
if( nSubmenu>0 ){
113
+ @ <div id="sub-menu">
114114
int i;
115115
qsort(aSubmenu, nSubmenu, sizeof(aSubmenu[0]), submenuCompare);
116116
for(i=0; i<nSubmenu; i++){
117117
struct Submenu *p = &aSubmenu[i];
118118
char *zTail = i<nSubmenu-1 ? " | " : "";
@@ -122,12 +122,12 @@
122122
}else{
123123
@ <a class="label" href="%T(p->zLink)">%h(p->zLabel)</a>
124124
@ <span class="tail">%s(zTail)</span>
125125
}
126126
}
127
+ @ </div>
127128
}
128
- @ </div>
129129
@ <div id="page">
130130
g.cgiPanic = 1;
131131
}
132132
133133
/*
134134
--- src/style.c
+++ src/style.c
@@ -107,12 +107,12 @@
107 }
108 if( !g.noPswd ){
109 @ | <a href="%s(g.zBaseURL)/login">%s(zLogInOut)</a>
110 }
111 @ </div>
112 @ <div id="sub-menu">
113 if( nSubmenu>0 ){
 
114 int i;
115 qsort(aSubmenu, nSubmenu, sizeof(aSubmenu[0]), submenuCompare);
116 for(i=0; i<nSubmenu; i++){
117 struct Submenu *p = &aSubmenu[i];
118 char *zTail = i<nSubmenu-1 ? " | " : "";
@@ -122,12 +122,12 @@
122 }else{
123 @ <a class="label" href="%T(p->zLink)">%h(p->zLabel)</a>
124 @ <span class="tail">%s(zTail)</span>
125 }
126 }
 
127 }
128 @ </div>
129 @ <div id="page">
130 g.cgiPanic = 1;
131 }
132
133 /*
134
--- src/style.c
+++ src/style.c
@@ -107,12 +107,12 @@
107 }
108 if( !g.noPswd ){
109 @ | <a href="%s(g.zBaseURL)/login">%s(zLogInOut)</a>
110 }
111 @ </div>
 
112 if( nSubmenu>0 ){
113 @ <div id="sub-menu">
114 int i;
115 qsort(aSubmenu, nSubmenu, sizeof(aSubmenu[0]), submenuCompare);
116 for(i=0; i<nSubmenu; i++){
117 struct Submenu *p = &aSubmenu[i];
118 char *zTail = i<nSubmenu-1 ? " | " : "";
@@ -122,12 +122,12 @@
122 }else{
123 @ <a class="label" href="%T(p->zLink)">%h(p->zLabel)</a>
124 @ <span class="tail">%s(zTail)</span>
125 }
126 }
127 @ </div>
128 }
 
129 @ <div id="page">
130 g.cgiPanic = 1;
131 }
132
133 /*
134

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button