Fossil

Check-in [485eb736]
Login

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

Overview
Comment:Attempt to simplify/unify the logic for looking up the start of a branch.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | unifiedStart
Files: files | file ages | folders
SHA1:485eb736034f3f73671d2c49e9780d0e832f016d
User & Date: mistachkin 2015-02-11 00:18:48
Context
2015-02-24
00:51
Merge updates from trunk. Leaf check-in: ae8f6f2b user: mistachkin tags: unifiedStart
2015-02-11
00:18
Attempt to simplify/unify the logic for looking up the start of a branch. check-in: 485eb736 user: mistachkin tags: unifiedStart
2015-02-10
17:31
Merge updates from trunk. Leaf check-in: 488dcfad user: mistachkin tags: viric_pbranch
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/name.c.

40
41
42
43
44
45
46










47
48
49
50
51
52
53
....
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
  if( !fossil_isdigit(z[5]) ) return 0;
  if( !fossil_isdigit(z[6]) ) return 0;
  if( z[7]!='-') return 0;
  if( !fossil_isdigit(z[8]) ) return 0;
  if( !fossil_isdigit(z[9]) ) return 0;
  return 1;
}











/*
** Return the RID that is the "root" of the branch that contains
** check-in "rid" if inBranch==0 or the first check-in in the branch
** if inBranch==1.
*/
int start_of_branch(int rid, int inBranch){
................................................................................
){
  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"







>
>
>
>
>
>
>
>
>
>







 







|
<
<
<
<
<
<




<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
>
|
<
|
<
<
<
<
<
<
<
<
<
<
<

<







40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
....
1088
1089
1090
1091
1092
1093
1094
1095






1096
1097
1098
1099




















1100
1101

1102











1103

1104
1105
1106
1107
1108
1109
1110
  if( !fossil_isdigit(z[5]) ) return 0;
  if( !fossil_isdigit(z[6]) ) return 0;
  if( z[7]!='-') return 0;
  if( !fossil_isdigit(z[8]) ) return 0;
  if( !fossil_isdigit(z[9]) ) return 0;
  return 1;
}

/*
** Return the name of the branch containing RID -OR- zero if not found.
*/
char *name_of_branch(int rid){
  return db_text(0,"SELECT value FROM tagxref"
                   " WHERE rid=%d AND tagid=%d"
                   " AND tagtype>0",
                   rid, TAG_BRANCH);
}

/*
** Return the RID that is the "root" of the branch that contains
** check-in "rid" if inBranch==0 or the first check-in in the branch
** if inBranch==1.
*/
int start_of_branch(int rid, int inBranch){
................................................................................
){
  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 = name_of_branch(branchRid);







  if( !branchName )
    return 0;





















  parentBranchName = name_of_branch(start_of_branch(branchRid, 0));


  if( !parentBranchName ){











    fossil_free(branchName);

    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"