Fossil

Check-in [97f976785d]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Allow fossil_find_nearest_fork to be used on repository that is not open.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 97f976785dce535ea9b8efa1caa9e189ff3ea18d
User & Date: andybradford 2015-04-16 23:46:16.652
Context
2015-04-17
09:50
Cherry-pick [http://www.sqlite.org/src/info/e018f4bf1f27f7838342940ad89a12d7f1536e8e|e018f4bf1f]: Fix a potential one-byte buffer overread in the command-line shell. Add (undocumented) -backslash option to "fossil sqlite" check-in: af52f2912a user: jan.nijtmans tags: trunk
00:11
Merge in new feature from trunk. check-in: eab553c77e user: andybradford tags: sync-forkwarn
2015-04-16
23:46
Allow fossil_find_nearest_fork to be used on repository that is not open. check-in: 97f976785d user: andybradford tags: trunk
08:53
Remove unnecessary variable determination in src/descendants.c, and some unnecessary end-of-line spacing. check-in: 10f5fc6986 user: jan.nijtmans tags: trunk
2015-04-13
03:38
Use better fork detection mechanism and disable checking during push since it may not have a complete sync and issue warning prematurely. check-in: d0e2f1bd3e user: andybradford tags: sync-forkwarn
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/descendants.c.
405
406
407
408
409
410
411

412
413
414
415
416
417
418
419
                   blob_sql_text(&sql));
  }else{
    db_prepare(&q, "%s ORDER BY event.mtime DESC", blob_sql_text(&sql));
  }
  blob_reset(&sql);
  n = 0;
  while( db_step(&q)==SQLITE_ROW ){

    if( !showForks || fossil_find_nearest_fork(db_column_int(&q, 0)) ){
      const char *zId = db_column_text(&q, 1);
      const char *zDate = db_column_text(&q, 2);
      const char *zCom = db_column_text(&q, 3);
      const char *zBr = db_column_text(&q, 7);
      char *z;

      if( byBranch && fossil_strcmp(zBr, zLastBr)!=0 ){







>
|







405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
                   blob_sql_text(&sql));
  }else{
    db_prepare(&q, "%s ORDER BY event.mtime DESC", blob_sql_text(&sql));
  }
  blob_reset(&sql);
  n = 0;
  while( db_step(&q)==SQLITE_ROW ){
    if( !showForks || 
        fossil_find_nearest_fork(db_column_int(&q, 0), db_open_local(0)) ){
      const char *zId = db_column_text(&q, 1);
      const char *zDate = db_column_text(&q, 2);
      const char *zCom = db_column_text(&q, 3);
      const char *zBr = db_column_text(&q, 7);
      char *z;

      if( byBranch && fossil_strcmp(zBr, zLastBr)!=0 ){
Changes to src/info.c.
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
    if( is_a_leaf(rid) ){
      if( db_int(0, "SELECT 1 FROM tagxref AS tx"
                    " WHERE tx.rid=%d"
                    " AND tx.tagid=%d"
                    " AND tx.tagtype>0",
                    rid, TAG_CLOSED)){
        fossil_print("%s\n", "closed");
      }else if( fossil_find_nearest_fork(rid) ){
        fossil_print("%s\n", "fork");
        isFork = 1;
      }else{
        fossil_print("%s\n", "open");
      }
    }else{
      fossil_print("no\n");







|







119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
    if( is_a_leaf(rid) ){
      if( db_int(0, "SELECT 1 FROM tagxref AS tx"
                    " WHERE tx.rid=%d"
                    " AND tx.tagid=%d"
                    " AND tx.tagtype>0",
                    rid, TAG_CLOSED)){
        fossil_print("%s\n", "closed");
      }else if( fossil_find_nearest_fork(rid, db_open_local(0)) ){
        fossil_print("%s\n", "fork");
        isFork = 1;
      }else{
        fossil_print("%s\n", "open");
      }
    }else{
      fossil_print("no\n");
Changes to src/merge.c.
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
  db_finalize(&q);
}


/* Pick the most recent leaf that is (1) not equal to vid and (2)
** has not already been merged into vid and (3) the leaf is not
** closed and (4) the leaf is in the same branch as vid.


*/
int fossil_find_nearest_fork(int vid){



  return db_int(0,


    "SELECT leaf.rid"
    "  FROM leaf, event"
    " WHERE leaf.rid=event.objid"
    "   AND leaf.rid!=%d"                                /* Constraint (1) */




    "   AND leaf.rid NOT IN (SELECT merge FROM vmerge)"  /* Constraint (2) */



    "   AND NOT EXISTS(SELECT 1 FROM tagxref"            /* Constraint (3) */
                  "     WHERE rid=leaf.rid"
                  "       AND tagid=%d"
                  "       AND tagtype>0)"
    "   AND (SELECT value FROM tagxref"                  /* Constraint (4) */
          "   WHERE tagid=%d AND rid=%d AND tagtype>0) ="
          " (SELECT value FROM tagxref"
          "   WHERE tagid=%d AND rid=leaf.rid AND tagtype>0)"
    " ORDER BY event.mtime DESC LIMIT 1",
    vid, TAG_CLOSED, TAG_BRANCH, vid, TAG_BRANCH
  );







}

/*
** COMMAND: merge
**
** Usage: %fossil merge ?OPTIONS? ?VERSION?
**







>
>

|
>
>
>
|
>
>



|
>
>
>
>
|
>
>
>









|

>
>
>
>
>
>
>







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
  db_finalize(&q);
}


/* Pick the most recent leaf that is (1) not equal to vid and (2)
** has not already been merged into vid and (3) the leaf is not
** closed and (4) the leaf is in the same branch as vid.
**
** Set vmergeFlag to control whether the vmerge table is checked.
*/
int fossil_find_nearest_fork(int vid, int vmergeFlag){
  Blob sql;
  Stmt q;
  int rid = 0;

  blob_zero(&sql);
  blob_append_sql(&sql,
    "SELECT leaf.rid"
    "  FROM leaf, event"
    " WHERE leaf.rid=event.objid"
    "   AND leaf.rid!=%d",                                /* Constraint (1) */
    vid
  );
  if( vmergeFlag ){
    blob_append_sql(&sql,
      "   AND leaf.rid NOT IN (SELECT merge FROM vmerge)"  /* Constraint (2) */
    );
  }
  blob_append_sql(&sql,
    "   AND NOT EXISTS(SELECT 1 FROM tagxref"            /* Constraint (3) */
                  "     WHERE rid=leaf.rid"
                  "       AND tagid=%d"
                  "       AND tagtype>0)"
    "   AND (SELECT value FROM tagxref"                  /* Constraint (4) */
          "   WHERE tagid=%d AND rid=%d AND tagtype>0) ="
          " (SELECT value FROM tagxref"
          "   WHERE tagid=%d AND rid=leaf.rid AND tagtype>0)"
    " ORDER BY event.mtime DESC LIMIT 1",
    TAG_CLOSED, TAG_BRANCH, vid, TAG_BRANCH
  );
  db_prepare(&q, "%s", blob_sql_text(&sql));
  blob_reset(&sql);
  if( db_step(&q)==SQLITE_ROW ){
    rid = db_column_int(&q, 0);
  }
  db_finalize(&q);
  return rid;
}

/*
** COMMAND: merge
**
** Usage: %fossil merge ?OPTIONS? ?VERSION?
**
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
    ** the leaf is not closed and (4) the leaf is in the same branch
    ** as the current checkout.
    */
    Stmt q;
    if( pickFlag || backoutFlag || integrateFlag){
      fossil_fatal("cannot use --backout, --cherrypick or --integrate with a fork merge");
    }
    mid = fossil_find_nearest_fork(vid);
    if( mid==0 ){
      fossil_fatal("no unmerged forks of branch \"%s\"",
        db_text(0, "SELECT value FROM tagxref"
                   " WHERE tagid=%d AND rid=%d AND tagtype>0",
                   TAG_BRANCH, vid)
      );
    }







|







215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
    ** the leaf is not closed and (4) the leaf is in the same branch
    ** as the current checkout.
    */
    Stmt q;
    if( pickFlag || backoutFlag || integrateFlag){
      fossil_fatal("cannot use --backout, --cherrypick or --integrate with a fork merge");
    }
    mid = fossil_find_nearest_fork(vid, db_open_local(0));
    if( mid==0 ){
      fossil_fatal("no unmerged forks of branch \"%s\"",
        db_text(0, "SELECT value FROM tagxref"
                   " WHERE tagid=%d AND rid=%d AND tagtype>0",
                   TAG_BRANCH, vid)
      );
    }