Fossil SCM

Upgrade the test-find-pivot command to the merge-base command, per discussion at [forum:1f5db4364464e965|forum post 1f5db4364464e965].

stephan 2022-11-19 14:02 trunk
Commit 2b6649c74384ce871e2cab8cd56ced0560ef8e9c0a22a1db9bf643645a76eb31
2 files changed +12 -7 +1
+12 -7
--- src/pivot.c
+++ src/pivot.c
@@ -152,35 +152,40 @@
152152
db_finalize(&u1);
153153
return rid;
154154
}
155155
156156
/*
157
-** COMMAND: test-find-pivot
157
+** COMMAND: merge-base
158158
**
159
-** Usage: %fossil test-find-pivot ?options? PRIMARY SECONDARY ...
159
+** Usage: %fossil merge-base ?options? PRIMARY SECONDARY ...
160160
**
161
-** Test the pivot_find() procedure.
161
+** Find a common ancestor given two or more checkin versions to
162
+** hypothetically merge.
162163
**
163164
** Options:
164165
** --ignore-merges Ignore merges for discovering name pivots
165166
*/
166167
void test_find_pivot(void){
167168
int i, rid;
168169
int ignoreMerges = find_option("ignore-merges",0,0)!=0;
169
- int showDetails = find_option("details",0,0)!=0;
170
+ int showDetails = find_option("details",0,0)!=0
171
+ /* intentionally undocumented */;
170172
if( g.argc<4 ){
171173
usage("?options? PRIMARY SECONDARY ...");
172174
}
173175
db_must_be_within_tree();
174176
pivot_set_primary(name_to_rid(g.argv[2]));
175177
for(i=3; i<g.argc; i++){
176178
pivot_set_secondary(name_to_rid(g.argv[i]));
177179
}
178180
rid = pivot_find(ignoreMerges);
179
- printf("pivot=%s\n",
180
- db_text("?","SELECT uuid FROM blob WHERE rid=%d",rid)
181
- );
181
+ if( rid==0 ){
182
+ puts("No common ancestor found.");
183
+ }else{
184
+ printf("pivot=%s\n",
185
+ db_text("?","SELECT uuid FROM blob WHERE rid=%d",rid));
186
+ }
182187
if( showDetails ){
183188
Stmt q;
184189
db_prepare(&q,
185190
"SELECT substr(uuid,1,12), aqueue.rid, datetime(aqueue.mtime),"
186191
" aqueue.pending, aqueue.src\n"
187192
--- src/pivot.c
+++ src/pivot.c
@@ -152,35 +152,40 @@
152 db_finalize(&u1);
153 return rid;
154 }
155
156 /*
157 ** COMMAND: test-find-pivot
158 **
159 ** Usage: %fossil test-find-pivot ?options? PRIMARY SECONDARY ...
160 **
161 ** Test the pivot_find() procedure.
 
162 **
163 ** Options:
164 ** --ignore-merges Ignore merges for discovering name pivots
165 */
166 void test_find_pivot(void){
167 int i, rid;
168 int ignoreMerges = find_option("ignore-merges",0,0)!=0;
169 int showDetails = find_option("details",0,0)!=0;
 
170 if( g.argc<4 ){
171 usage("?options? PRIMARY SECONDARY ...");
172 }
173 db_must_be_within_tree();
174 pivot_set_primary(name_to_rid(g.argv[2]));
175 for(i=3; i<g.argc; i++){
176 pivot_set_secondary(name_to_rid(g.argv[i]));
177 }
178 rid = pivot_find(ignoreMerges);
179 printf("pivot=%s\n",
180 db_text("?","SELECT uuid FROM blob WHERE rid=%d",rid)
181 );
 
 
 
182 if( showDetails ){
183 Stmt q;
184 db_prepare(&q,
185 "SELECT substr(uuid,1,12), aqueue.rid, datetime(aqueue.mtime),"
186 " aqueue.pending, aqueue.src\n"
187
--- src/pivot.c
+++ src/pivot.c
@@ -152,35 +152,40 @@
152 db_finalize(&u1);
153 return rid;
154 }
155
156 /*
157 ** COMMAND: merge-base
158 **
159 ** Usage: %fossil merge-base ?options? PRIMARY SECONDARY ...
160 **
161 ** Find a common ancestor given two or more checkin versions to
162 ** hypothetically merge.
163 **
164 ** Options:
165 ** --ignore-merges Ignore merges for discovering name pivots
166 */
167 void test_find_pivot(void){
168 int i, rid;
169 int ignoreMerges = find_option("ignore-merges",0,0)!=0;
170 int showDetails = find_option("details",0,0)!=0
171 /* intentionally undocumented */;
172 if( g.argc<4 ){
173 usage("?options? PRIMARY SECONDARY ...");
174 }
175 db_must_be_within_tree();
176 pivot_set_primary(name_to_rid(g.argv[2]));
177 for(i=3; i<g.argc; i++){
178 pivot_set_secondary(name_to_rid(g.argv[i]));
179 }
180 rid = pivot_find(ignoreMerges);
181 if( rid==0 ){
182 puts("No common ancestor found.");
183 }else{
184 printf("pivot=%s\n",
185 db_text("?","SELECT uuid FROM blob WHERE rid=%d",rid));
186 }
187 if( showDetails ){
188 Stmt q;
189 db_prepare(&q,
190 "SELECT substr(uuid,1,12), aqueue.rid, datetime(aqueue.mtime),"
191 " aqueue.pending, aqueue.src\n"
192
--- www/changes.wiki
+++ www/changes.wiki
@@ -1,9 +1,10 @@
11
<title>Change Log</title>
22
33
<h2 id='v2_21'>Changes for version 2.21 (pending)</h2>
44
* Add the ability to put text descriptions on ticket report formats.
5
+ * Upgrade the test-find-pivot command to the [/help/merge-base|merge-base command].
56
67
<h2 id='v2_20'>Changes for version 2.20 (2022-11-16)</h2>
78
* Added the [/help?cmd=chat-timeline-user|chat-timeline-user setting]. If
89
it is not an empty string, then any changes that would appear on the timeline
910
are announced in [./chat.md|the chat room].
1011
--- www/changes.wiki
+++ www/changes.wiki
@@ -1,9 +1,10 @@
1 <title>Change Log</title>
2
3 <h2 id='v2_21'>Changes for version 2.21 (pending)</h2>
4 * Add the ability to put text descriptions on ticket report formats.
 
5
6 <h2 id='v2_20'>Changes for version 2.20 (2022-11-16)</h2>
7 * Added the [/help?cmd=chat-timeline-user|chat-timeline-user setting]. If
8 it is not an empty string, then any changes that would appear on the timeline
9 are announced in [./chat.md|the chat room].
10
--- www/changes.wiki
+++ www/changes.wiki
@@ -1,9 +1,10 @@
1 <title>Change Log</title>
2
3 <h2 id='v2_21'>Changes for version 2.21 (pending)</h2>
4 * Add the ability to put text descriptions on ticket report formats.
5 * Upgrade the test-find-pivot command to the [/help/merge-base|merge-base command].
6
7 <h2 id='v2_20'>Changes for version 2.20 (2022-11-16)</h2>
8 * Added the [/help?cmd=chat-timeline-user|chat-timeline-user setting]. If
9 it is not an empty string, then any changes that would appear on the timeline
10 are announced in [./chat.md|the chat room].
11

Keyboard Shortcuts

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