Fossil

Check-in [1982a8ce]
Login

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

Overview
Comment:Fix compiler warning. Coding style adjustments. Rename new link to 'branch diff' for now. Still needs tests.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | viric_pbranch
Files: files | file ages | folders
SHA1:1982a8ce0720b19ea921b780ff8c0d891048d333
User & Date: mistachkin 2015-02-10 03:05:36
Context
2015-02-10
17:31
Merge updates from trunk. Leaf check-in: 488dcfad user: mistachkin tags: viric_pbranch
03:05
Fix compiler warning. Coding style adjustments. Rename new link to 'branch diff' for now. Still needs tests. check-in: 1982a8ce user: mistachkin tags: viric_pbranch
02:40
Make the new link consistent with the existing coding style. check-in: 48027b23 user: mistachkin tags: viric_pbranch
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/info.c.

673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
      @ <tr><th>Other&nbsp;Links:</th>
      @   <td>
      @     %z(href("%R/tree?ci=%S",zUuid))files</a>
      @   | %z(href("%R/fileage?name=%S",zUuid))file ages</a>
      @   | %z(href("%R/tree?nofiles&type=tree&ci=%S",zUuid))folders</a>
      @   | %z(href("%R/artifact/%S",zUuid))manifest</a>
      @   | %z(href("%R/vdiff?from=pbranch:%S&to=%S",zUuid,zUuid))
      @           branch changes</a>
      if( g.perm.Write ){
        @   | %z(href("%R/ci_edit?r=%S",zUuid))edit</a>
      }
      @   </td>
      @ </tr>
      blob_reset(&projName);
    }







|







673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
      @ <tr><th>Other&nbsp;Links:</th>
      @   <td>
      @     %z(href("%R/tree?ci=%S",zUuid))files</a>
      @   | %z(href("%R/fileage?name=%S",zUuid))file ages</a>
      @   | %z(href("%R/tree?nofiles&type=tree&ci=%S",zUuid))folders</a>
      @   | %z(href("%R/artifact/%S",zUuid))manifest</a>
      @   | %z(href("%R/vdiff?from=pbranch:%S&to=%S",zUuid,zUuid))
      @           branch diff</a>
      if( g.perm.Write ){
        @   | %z(href("%R/ci_edit?r=%S",zUuid))edit</a>
      }
      @   </td>
      @ </tr>
      blob_reset(&projName);
    }

Changes to src/name.c.

180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
....
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077

1078
1079


1080
1081

1082
1083
1084
1085
1086
1087
1088
1089
1090
1091

1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105

1106
1107
1108
1109

1110
1111
1112

1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129


1130

1131
1132
1133
1134
1135
1136
1137
1138
1139
1140

1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151

1152
1153
1154
1155
1156


1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167


1168
1169
      "SELECT objid FROM event"
      " WHERE mtime<=julianday('%qz') AND type GLOB '%q'"
      " ORDER BY mtime DESC LIMIT 1",
      &zTag[4], zType);
    return rid;
  }

  /* "parent:", as for parent branch. It returns the checkin of
     the last checkin of the parent branch that has been merged in. */
  if( memcmp(zTag, "pbranch:", 8)==0 ){
    int branchRid = symbolic_name_to_rid(&zTag[8], zType);
    if (branchRid == 0) return 0;
    rid = get_parent_branch_rid(branchRid);
    return rid;
  }

  /* "tag:" + symbolic-name */
  if( memcmp(zTag, "tag:", 4)==0 ){
    rid = db_int(0,
       "SELECT event.objid, max(event.mtime)"
................................................................................
** Show all phantom artifacts
*/
void test_phatoms_cmd(void){
  db_find_and_open_repository(0,0);
  describe_artifacts_to_stdout("IN (SELECT rid FROM blob WHERE size<0)", 0);
}



/*
** It returns the checkin of the last checkin of the parent branch that has
** been merged in.

*/
int get_parent_branch_rid(int ridRequested){


  Stmt s;
  const char *branchName;    /* Name of the branch requested at rid */

  const char *parentBranchName; /* Name of the parent branch */
  int rid;

  /* Get the name of the current branch */
  branchName = db_text(0,
    "SELECT value FROM tagxref"
    " WHERE tagid=%d"
    "   AND tagxref.tagtype>0"
    "   AND rid=%d",
    TAG_BRANCH, ridRequested);


  if ( !branchName )
    return 0;

  /* Find the name of the branch this was forked from */
  db_prepare(&s,
    "SELECT pid, tagxref.value FROM plink JOIN tagxref"
    " WHERE cid=:rid"
    "   AND isprim=1"
    "   AND tagxref.tagid=%d"
    "   AND tagxref.tagtype>0"
    "   AND tagxref.rid=pid",
    TAG_BRANCH);


  rid = ridRequested;
  while( rid > 0 ) {
    db_bind_int(&s, ":rid", rid);
    if ( db_step(&s) == SQLITE_ROW ) {

      rid = db_column_int(&s, 0);
      parentBranchName = db_column_text(&s, 1);
      if ( !parentBranchName ) {

        rid = 0;
        break;
      }

      if ( fossil_strcmp(parentBranchName, branchName) ) {
        parentBranchName = fossil_strdup(parentBranchName);
        break;
      }
    }else{
      rid = 0;
      break;
    }
    db_reset(&s);
  }
  db_finalize(&s);

  if (rid == 0)


      return 0;


  /* Find the last checkin coming from the parent branch */
  db_prepare(&s,
    "SELECT pid, tagxref.value FROM plink JOIN tagxref"
    " WHERE cid=:rid"
    "   AND tagxref.tagid=%d"
    "   AND tagxref.tagtype>0"
    "   AND tagxref.rid=pid ORDER BY isprim ASC",
    TAG_BRANCH);


  rid = ridRequested;
  while( rid > 0 ) {
    db_bind_int(&s, ":rid", rid);
    int found = 0;
    while ( db_step(&s) == SQLITE_ROW ) {
      const char *branchNamePid; /* Branch name of the pid */

      ++found;
      rid = db_column_int(&s, 0);
      branchNamePid = db_column_text(&s, 1);
      if ( !branchNamePid ) {

        break;
      }
      if ( fossil_strcmp(parentBranchName, branchNamePid)==0 ) {
        /* Found the last merge from the parent branch */
        db_finalize(&s);


        return rid;
      }
    }
    
    if (found == 0) {
      break;
    }
    db_reset(&s);
  }
  db_finalize(&s);



  return 0;
}







|


|
|
|







 







<
<

<
<
>

|
>
>

<
>
|








|
>

|










|
<
>
|
|

|
>

|
<
>



|
|
<










|
>
>
|
>








|
<
>
|
|


|
|
<
|

|
<
>


|


>
>



|
<






>
>


180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
....
1066
1067
1068
1069
1070
1071
1072


1073


1074
1075
1076
1077
1078
1079

1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104

1105
1106
1107
1108
1109
1110
1111
1112

1113
1114
1115
1116
1117
1118

1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142

1143
1144
1145
1146
1147
1148
1149

1150
1151
1152

1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164

1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
      "SELECT objid FROM event"
      " WHERE mtime<=julianday('%qz') AND type GLOB '%q'"
      " ORDER BY mtime DESC LIMIT 1",
      &zTag[4], zType);
    return rid;
  }

  /* "pbranch:", as for parent branch.  It returns the checkin of
     the last checkin of the parent branch that has been merged in. */
  if( memcmp(zTag, "pbranch:", 8)==0 ){
    rid = symbolic_name_to_rid(&zTag[8], zType);
    if( rid==0 ) return 0; /* TODO: Negative rid allowed here? */
    rid = get_parent_branch_rid(rid);
    return rid;
  }

  /* "tag:" + symbolic-name */
  if( memcmp(zTag, "tag:", 4)==0 ){
    rid = db_int(0,
       "SELECT event.objid, max(event.mtime)"
................................................................................
** Show all phantom artifacts
*/
void test_phatoms_cmd(void){
  db_find_and_open_repository(0,0);
  describe_artifacts_to_stdout("IN (SELECT rid FROM blob WHERE size<0)", 0);
}



/*


** Returns the rid for the last checkin where the parent branch was merged.
*/
int get_parent_branch_rid(
  int branchRid /* The rid to find parent branch for. */
){
  Stmt s;

  char *branchName = 0;       /* Name of the branch at rid */
  char *parentBranchName = 0; /* Name of the parent branch */
  int rid;

  /* Get the name of the current branch */
  branchName = db_text(0,
    "SELECT value FROM tagxref"
    " WHERE tagid=%d"
    "   AND tagxref.tagtype>0"
    "   AND rid=%d",
    TAG_BRANCH, branchRid
  );

  if( !branchName )
    return 0;

  /* Find the name of the branch this was forked from */
  db_prepare(&s,
    "SELECT pid, tagxref.value FROM plink JOIN tagxref"
    " WHERE cid=:rid"
    "   AND isprim=1"
    "   AND tagxref.tagid=%d"
    "   AND tagxref.tagtype>0"
    "   AND tagxref.rid=pid",
    TAG_BRANCH

  );
  rid = branchRid;
  while( rid>0 ){
    db_bind_int(&s, ":rid", rid);
    if( db_step(&s)==SQLITE_ROW ){
      const char *zValue; /* Branch name of the pid */
      rid = db_column_int(&s, 0);
      zValue = db_column_text(&s, 1);

      if( !zValue ){
        rid = 0;
        break;
      }
      if( fossil_strcmp(zValue,branchName) ){
        parentBranchName = fossil_strdup(zValue);

        break;
      }
    }else{
      rid = 0;
      break;
    }
    db_reset(&s);
  }
  db_finalize(&s);

  if( rid==0 ){
    fossil_free(branchName);
    fossil_free(parentBranchName);
    return 0;
  }

  /* Find the last checkin coming from the parent branch */
  db_prepare(&s,
    "SELECT pid, tagxref.value FROM plink JOIN tagxref"
    " WHERE cid=:rid"
    "   AND tagxref.tagid=%d"
    "   AND tagxref.tagtype>0"
    "   AND tagxref.rid=pid ORDER BY isprim ASC",
    TAG_BRANCH

  );
  rid = branchRid;
  while( rid>0 ){
    db_bind_int(&s, ":rid", rid);
    int found = 0;
    while( db_step(&s)==SQLITE_ROW ){
      const char *zValue; /* Branch name of the pid */

      found++;
      rid = db_column_int(&s, 0);
      zValue = db_column_text(&s, 1);

      if( !zValue ){
        break;
      }
      if( fossil_strcmp(parentBranchName,zValue)==0 ){
        /* Found the last merge from the parent branch */
        db_finalize(&s);
        fossil_free(branchName);
        fossil_free(parentBranchName);
        return rid;
      }
    }
    if( found==0 ){

      break;
    }
    db_reset(&s);
  }
  db_finalize(&s);

  fossil_free(branchName);
  fossil_free(parentBranchName);
  return 0;
}