On Tue, Feb 15, 2011 at 3:45 PM, Mark Janssen <mpc.jans...@gmail.com> wrote:
> On Tue, Feb 15, 2011 at 2:31 PM, Mark Janssen <mpc.jans...@gmail.com> wrote:
>> On Tue, Feb 15, 2011 at 1:41 PM, Richard Hipp <d...@sqlite.org> wrote:
>>>
>>>
>>> On Sun, Feb 13, 2011 at 4:15 PM, Richard Hipp <d...@sqlite.org> wrote:
>>>>
>>>>
>>>> On Sun, Feb 13, 2011 at 4:09 PM, Martin Gagnon <eme...@gmail.com> wrote:
>>>>>
>>>>> I've convert a git repository to fossil and I'm a bit confuse with my
>>>>> tags I had in git, the way they become in fossil.
>>>>>
>>>>> I had some tag in the original git repo, which was not branch, only a
>>>>> tag to a particular version. Once I convert to fossil, those tag
>>>>> propagate to future versions until next tag is reach. Those tags
>>>>> seems to be like real branches after conversion to fossil.
>>>>>
>>>>> Did someone else get the same problem? Or I miss something?
>>>>
>>>> I've seen the same thing.
>>>>
>>>> Either I'm misunderstanding the git-fast-export file format documentation
>>>> or else git-fast-export is getting branches and tags confused.
>>>
>>> git-fast-import works and generates the correct repository for the output of
>>> git-fast-export.  So there must be some way of interpreting the output of
>>> git-fast-export correctly.  Anybody with clues on how to do this, please
>>> help!
>>>
>>>
>>>>
>>>>   I'm not sure which it is, but I am leaning toward the problem being in
>>>> git-fast-export.  Others have reported issues with that tool, and the
>>>> documentation for git-fast-export itself explains that it cannot
>>>> successfully export the Linux kernel repository....
>>>>
>>>> I've got some ideas on how I might work around the (presumed) brokenness
>>>> in git-fast-export.  If you are able to send me the output of
>>>> git-fast-export from your repository, or let me clone you git repository,
>>>> that will give me another example repository to work with.
>>>>
>>>>
>>>>>
>>>>> Thanks
>>>>>
>>>>> --
>>>>> Martin
>>>>> _______________________________________________
>>>>> fossil-users mailing list
>>>>> fossil-users@lists.fossil-scm.org
>>>>> http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users
>>>>
>>>>
>>>>
>>>> --
>>>> D. Richard Hipp
>>>> d...@sqlite.org
>>>
>>>
>>>
>>> --
>>> D. Richard Hipp
>>> d...@sqlite.org
>>>
>>> _______________________________________________
>>> fossil-users mailing list
>>> fossil-users@lists.fossil-scm.org
>>> http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users
>>>
>>>
>>
>> Maybe I am missing something here, but aren't tags simply identifiable
>> by commits with revision prefix /refs/tags?
>>
>>
>> Mark
>>
>
> After some further investigation, it seems that git fast-export is
> making a mess of the tags. Commit commands refer to tags that have not
> been created yet. This does not play very well with the fossil
> approach of not rewriting history. I suspect the only way to solve
> this is to make a separate non propagating tagging phase after the
> whole repo has been converted.
>
> Mark
>

And continuing to reply to myself, the diff to import.c below seems to
correctly tag the revisions in at least the case of the first test
script. (It also contains some renaming of master->trunk but that can
be ignored).

Mark

--- src/import.c
+++ src/import.c
@@ -58,10 +58,11 @@
   char **azMerge;             /* Merge values */
   int nFile;                  /* Number of aFile values */
   int nFileAlloc;             /* Number of slots in aFile[] */
   ImportFile *aFile;          /* Information about files in a commit */
   int fromLoaded;             /* True zFrom content loaded into aFile[] */
+  int tagCommit;              /* True if the commit adds a tag */
 } gg;

 /*
 ** Duplicate a string.
 */
@@ -115,10 +116,11 @@
     fossil_free(gg.azMerge);
     fossil_free(gg.aFile);
     memset(&gg, 0, sizeof(gg));
   }
   gg.xFinish = finish_noop;
+  gg.tagCommit = 0;
 }

 /*
 ** Insert an artifact into the BLOB table if it isn't there already.
 ** If zMark is not zero, create a cross-reference from that mark back
@@ -244,27 +246,45 @@
     zFromBranch = db_text(0, "SELECT brnm FROM xbranch WHERE tname=%Q",
                               gg.zFromMark);
   }else{
     zFromBranch = 0;
   }
-  if( fossil_strcmp(zFromBranch, gg.zBranch)!=0 ){
-    blob_appendf(&record, "T *branch * %F\n", gg.zBranch);
-    blob_appendf(&record, "T *sym-%F *\n", gg.zBranch);
-    if( zFromBranch ){
-      blob_appendf(&record, "T -sym-%F *\n", zFromBranch);
-    }
-  }
+  if (!gg.tagCommit) {
+         if( fossil_strcmp(zFromBranch, gg.zBranch)!=0 ){
+                 blob_appendf(&record, "T *branch * %F\n", gg.zBranch);
+                 blob_appendf(&record, "T *sym-%F *\n", gg.zBranch);
+                 if( zFromBranch ){
+                         blob_appendf(&record, "T -sym-%F *\n", zFromBranch);
+                 }
+         }
+ }
+
   free(zFromBranch);
   if( gg.zFrom==0 ){
-    blob_appendf(&record, "T +sym-trunk *\n");
+    blob_appendf(&record, "T *sym-trunk *\n");
   }
   db_multi_exec("INSERT INTO xbranch(tname, brnm) VALUES(%Q,%Q)",
                 gg.zMark, gg.zBranch);
   blob_appendf(&record, "U %F\n", gg.zUser);
   md5sum_blob(&record, &cksum);
   blob_appendf(&record, "Z %b\n", &cksum);
   fast_insert_content(&record, gg.zMark, 1);
+  if(gg.tagCommit) {
+     int rid;
+
+     rid = db_last_insert_rowid();
+  if( gg.zDate && gg.zUser && gg.zFrom ){
+    blob_reset(&record);
+    blob_reset(&cksum);
+    blob_appendf(&record, "D %s\n", gg.zDate);
+    blob_appendf(&record, "T +sym-%F %s\n", gg.zBranch, gg.zPrevCheckin);
+    blob_appendf(&record, "U %F\n", gg.zUser);
+    md5sum_blob(&record, &cksum);
+    blob_appendf(&record, "Z %b\n", &cksum);
+    db_multi_exec("INSERT OR REPLACE INTO xtag(tname, trid,  tuuid,
tinfo) VALUES(%Q,%d,%Q,%B)", gg.zBranch, rid,  gg.zPrevCheckin,
&record);
+  }
+  }
   blob_reset(&record);
   blob_reset(&cksum);
   fossil_free(gg.zPrevBranch);
   gg.zPrevBranch = gg.zBranch;
   gg.zBranch = 0;
@@ -425,20 +445,27 @@
       gg.xFinish();
       gg.xFinish = finish_commit;
       trim_newline(&zLine[7]);
       z = &zLine[7];
       for(i=strlen(z)-1; i>=0 && z[i]!='/'; i--){}
+      if (memcmp(&z[i-4],"tags",4) == 0) {
+           gg.tagCommit = 1;
+      }
       if( z[i+1]!=0 ) z += i+1;
-      gg.zBranch = fossil_strdup(z);
+      if (fossil_strcmp(z,"master")==0) {
+            gg.zBranch = fossil_strdup("trunk");
+      }else {
+            gg.zBranch = fossil_strdup(z);
+      }
       gg.fromLoaded = 0;
     }else
     if( memcmp(zLine, "tag ", 4)==0 ){
       gg.xFinish();
       gg.xFinish = finish_tag;
       trim_newline(&zLine[4]);
       gg.zTag = fossil_strdup(&zLine[4]);
-    }else
+    } else
     if( memcmp(zLine, "reset ", 4)==0 ){
       gg.xFinish();
     }else
     if( memcmp(zLine, "checkpoint", 10)==0 ){
       gg.xFinish();
@@ -631,10 +658,11 @@
 ** in the future.
 */
 void git_import_cmd(void){
   char *zPassword;
   FILE *pIn;
+  Stmt q;
   int forceFlag = find_option("force", "f", 0)!=0;
   find_option("git",0,0);  /* Skip the --git option for now */
   verify_all_options();
   if( g.argc!=3  && g.argc!=4 ){
     usage("REPOSITORY-NAME");
@@ -648,16 +676,30 @@
   if( forceFlag ) unlink(g.argv[2]);
   db_create_repository(g.argv[2]);
   db_open_repository(g.argv[2]);
   db_open_config(0);
   db_multi_exec(
-     "CREATE TEMP TABLE xtag(tname TEXT UNIQUE, trid INT, tuuid TEXT);"
+     "CREATE TEMP TABLE xtag(tname TEXT UNIQUE, trid INT, tuuid TEXT,
tinfo BLOB);"
      "CREATE TEMP TABLE xbranch(tname TEXT UNIQUE, brnm TEXT);"
   );
   db_begin_transaction();
   db_initial_setup(0, 0, 1);
   git_fast_import(pIn);
+  db_end_transaction(0);
+  db_begin_transaction();
+  printf("Storing non propagating tags...\n");
+  db_prepare(&q,"SELECT * FROM xtag WHERE tinfo not null");
+  while( db_step(&q)==SQLITE_ROW ){
+     Blob record;
+     blob_zero(&record);
+     db_column_blob(&q,3,&record);
+     fast_insert_content(&record,0,0);
+     printf("Applying:\n%s", blob_str(&record));
+     import_reset(0);
+     blob_reset(&record);
+  }
+  db_finalize(&q);
   db_end_transaction(0);
   db_begin_transaction();
   printf("Rebuilding repository meta-data...\n");
   rebuild_db(0, 1, 1);
   verify_cancel();
_______________________________________________
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users

Reply via email to