Fossil

Check-in [bc8d368b]
Login

Check-in [bc8d368b]

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

Overview
Comment:Avoid parsing manifests if a parent exists. Now the only case left using deleteall is when no parent exists.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: bc8d368b66053450c7f323b4e479fb5b4a878684
User & Date: joerg 2011-07-21 15:50:46
Context
2011-07-21
17:35
Skip missing merge parents. Git doesn't like missing marks and there isn't anything to be done about them. ... (check-in: b71b32d1 user: joerg tags: trunk)
15:50
Avoid parsing manifests if a parent exists. Now the only case left using deleteall is when no parent exists. ... (check-in: bc8d368b user: joerg tags: trunk)
13:53
Write incremental file lists for fast-export. ... (check-in: 433a3c9a user: joerg tags: trunk)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/export.c.

137
138
139
140
141
142
143

144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167





168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188

189
190




191










192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
    "       (SELECT value FROM tagxref WHERE rid=objid AND tagid=%d)"
    "  FROM event"
    " WHERE type='ci'"
    " ORDER BY mtime ASC",
    TAG_BRANCH
  );
  while( db_step(&q)==SQLITE_ROW ){

    const char *zSecondsSince1970 = db_column_text(&q, 0);
    int ckinId = db_column_int(&q, 1);
    const char *zComment = db_column_text(&q, 2);
    const char *zUser = db_column_text(&q, 3);
    const char *zBranch = db_column_text(&q, 4);
    char *zBr;
    Manifest *p;
    ManifestFile *pFile;
    const char *zFromType;
    int parent;

    bag_insert(&vers, ckinId);
    if( zBranch==0 ) zBranch = "trunk";
    zBr = mprintf("%s", zBranch);
    for(i=0; zBr[i]; i++){
      if( !fossil_isalnum(zBr[i]) ) zBr[i] = '_';
    }
    printf("commit refs/heads/%s\nmark :%d\n", zBr, ckinId+firstCkin);
    free(zBr);
    printf("committer");
    print_person(zUser);
    printf(" %s +0000\n", zSecondsSince1970);
    if( zComment==0 ) zComment = "null comment";
    printf("data %d\n%s\n", (int)strlen(zComment), zComment);





    p = manifest_get(ckinId, CFTYPE_ANY);
    zFromType = "from";
    parent = 0;
    for(i=0; i<p->nParent; i++){
      int pid = fast_uuid_to_rid(p->azParent[i]);
      if( pid==0 || !bag_find(&vers, pid) ) continue;
      if( i==0) parent = pid;
      printf("%s :%d\n", zFromType, fast_uuid_to_rid(p->azParent[i])+firstCkin);
      zFromType = "merge";
    }
    if( parent==0 ) {
      printf("deleteall\n");
      manifest_file_rewind(p);
      while( (pFile=manifest_file_next(p, 0))!=0 ){
        int fid = fast_uuid_to_rid(pFile->zUuid);
        const char *zPerm = "100644";
        if( fid==0 ) continue;
        if( pFile->zPerm && strstr(pFile->zPerm,"x") ) zPerm = "100755";
        if( !bag_find(&blobs, fid) ) continue;
        printf("M %s :%d %s\n", zPerm, fid, pFile->zName);
      }

    }else{
      Stmt q2;




      db_prepare(&q2,










        "SELECT filename.name, mlink.fid, mlink.mperm FROM mlink"
        " JOIN filename ON filename.fnid=mlink.fnid"
        " WHERE mlink.mid=%d",
        parent
      );
      while( db_step(&q2)==SQLITE_ROW ){
        const char *zName = db_column_text(&q2,0);
        int zNew = db_column_int(&q2,1);
        int mPerm = db_column_int(&q2,2);
        if( zNew==0)
           printf("D %s\n", zName);
        else
           printf("M %s :%d %s\n", mPerm ? "100755" : "100644", zNew, zName);
      }
      db_finalize(&q2);
    }
    manifest_cache_insert(p);
    printf("\n");
  }
  db_finalize(&q);
  bag_clear(&blobs);
  manifest_cache_clear();









>






<
<
<
<














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










>

|
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>





|
|
|
|





|

|







137
138
139
140
141
142
143
144
145
146
147
148
149
150




151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175

176
177
178

179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
    "       (SELECT value FROM tagxref WHERE rid=objid AND tagid=%d)"
    "  FROM event"
    " WHERE type='ci'"
    " ORDER BY mtime ASC",
    TAG_BRANCH
  );
  while( db_step(&q)==SQLITE_ROW ){
    Stmt q2;
    const char *zSecondsSince1970 = db_column_text(&q, 0);
    int ckinId = db_column_int(&q, 1);
    const char *zComment = db_column_text(&q, 2);
    const char *zUser = db_column_text(&q, 3);
    const char *zBranch = db_column_text(&q, 4);
    char *zBr;





    bag_insert(&vers, ckinId);
    if( zBranch==0 ) zBranch = "trunk";
    zBr = mprintf("%s", zBranch);
    for(i=0; zBr[i]; i++){
      if( !fossil_isalnum(zBr[i]) ) zBr[i] = '_';
    }
    printf("commit refs/heads/%s\nmark :%d\n", zBr, ckinId+firstCkin);
    free(zBr);
    printf("committer");
    print_person(zUser);
    printf(" %s +0000\n", zSecondsSince1970);
    if( zComment==0 ) zComment = "null comment";
    printf("data %d\n%s\n", (int)strlen(zComment), zComment);
    db_prepare(&q2, "SELECT pid FROM plink WHERE cid=%d AND isprim", ckinId);
    if( db_step(&q2) != SQLITE_ROW ){
      const char *zFromType;
      Manifest *p;
      ManifestFile *pFile;

      zFromType = "from";
      p = manifest_get(ckinId, CFTYPE_ANY);
      for(i=0; i<p->nParent; i++){
        int pid = fast_uuid_to_rid(p->azParent[i]);
        if( pid==0 || !bag_find(&vers, pid) ) continue;

        printf("%s :%d\n", zFromType, fast_uuid_to_rid(p->azParent[i])+firstCkin);
        zFromType = "merge";
      }

      printf("deleteall\n");
      manifest_file_rewind(p);
      while( (pFile=manifest_file_next(p, 0))!=0 ){
        int fid = fast_uuid_to_rid(pFile->zUuid);
        const char *zPerm = "100644";
        if( fid==0 ) continue;
        if( pFile->zPerm && strstr(pFile->zPerm,"x") ) zPerm = "100755";
        if( !bag_find(&blobs, fid) ) continue;
        printf("M %s :%d %s\n", zPerm, fid, pFile->zName);
      }
      manifest_cache_insert(p);
    }else{
      Stmt q3;
      int parent;

      parent = db_column_int(&q2, 0);
      printf("from :%d\n", parent+firstCkin);
      db_prepare(&q3,
        "SELECT pid FROM plink"
        " WHERE cid=%d AND NOT isprim"
        " ORDER BY pid",
        ckinId);
      while( db_step(&q3)==SQLITE_ROW ){
        printf("merge :%d\n", db_column_int(&q3,0)+firstCkin);
      }
      db_finalize(&q3);

      db_prepare(&q3,
        "SELECT filename.name, mlink.fid, mlink.mperm FROM mlink"
        " JOIN filename ON filename.fnid=mlink.fnid"
        " WHERE mlink.mid=%d",
        parent
      );
      while( db_step(&q3)==SQLITE_ROW ){
        const char *zName = db_column_text(&q3,0);
        int zNew = db_column_int(&q3,1);
        int mPerm = db_column_int(&q3,2);
        if( zNew==0)
           printf("D %s\n", zName);
        else
           printf("M %s :%d %s\n", mPerm ? "100755" : "100644", zNew, zName);
      }
      db_finalize(&q3);
    }
    db_finalize(&q2);
    printf("\n");
  }
  db_finalize(&q);
  bag_clear(&blobs);
  manifest_cache_clear();