{"thread":{"id":"4517","subject":"[PATCH for cvsps] Handle cvs repo with modules","startedAt":"2006-06-15T05:49:17Z","lastAt":"2006-06-17T21:33:27Z","messageCount":3,"participants":["Alexander Litvinov","Yann Dirson"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"21819","messageId":"200606151249.17518.lan@academsoft.ru","threadId":"4517","inReplyTo":null,"subject":"[PATCH for cvsps] Handle cvs repo with modules","fromName":"Alexander Litvinov","fromEmail":"lan@academsoft.ru","sentAt":"2006-06-15T05:49:17Z","receivedAt":"2006-06-15T05:49:17Z","isPatch":true,"sender":{"key":"lan@academsoft.ru","avatar":null},"body":"Parse 'Working file' lines from cvs log output. This alow to work with cvs repos \nwith modules. To enable this you need to add --no-rlog to cvsps command line args.\n\nThis patch was made to import such repo into git. But git-cvsimport can't load such data.\n\n---\n cvsps.c |   60 ++++++++++++++++++++++++++++++++++++++++++++++++++----------\n 1 files changed, 50 insertions(+), 10 deletions(-)\n\ndiff --git a/cvsps.c b/cvsps.c\nindex 2695a0f..62d6e08 100644\n--- a/cvsps.c\n+++ b/cvsps.c\n@@ -39,7 +39,8 @@ #define CVS_FILE_BOUNDARY \"=============\n \n enum\n {\n-    NEED_FILE,\n+    NEED_RCS_FILE,\n+    NEED_WORKING_FILE,\n     NEED_SYMS,\n     NEED_EOS,\n     NEED_START_LOG,\n@@ -117,7 +118,9 @@ static int parse_args(int, char *[]);\n static int parse_rc();\n static void load_from_cvs();\n static void init_paths();\n-static CvsFile * parse_file(const char *);\n+static CvsFile * build_file_by_name(const char *);\n+static CvsFile * parse_rcs_file(const char *);\n+static CvsFile * parse_working_file(const char *);\n static CvsFileRevision * parse_revision(CvsFile * file, char * rev_str);\n static void assign_pre_revision(PatchSetMember *, CvsFileRevision * rev);\n static void check_print_patch_set(PatchSet *);\n@@ -260,7 +263,7 @@ static void load_from_cvs()\n {\n     FILE * cvsfp;\n     char buff[BUFSIZ];\n-    int state = NEED_FILE;\n+    int state = NEED_RCS_FILE;\n     CvsFile * file = NULL;\n     PatchSetMember * psm = NULL;\n     char datebuff[20];\n@@ -339,10 +342,26 @@ static void load_from_cvs()\n \n \tswitch(state)\n \t{\n-\tcase NEED_FILE:\n-\t    if (strncmp(buff, \"RCS file\", 8) == 0 && (file = parse_file(buff)))\n+\tcase NEED_RCS_FILE:\n+\t    if (strncmp(buff, \"RCS file\", 8) == 0) {\n+              if ((file = parse_rcs_file(buff)) != NULL)\n \t\tstate = NEED_SYMS;\n+              else \n+                state = NEED_WORKING_FILE;\n+            }\n \t    break;\n+\tcase NEED_WORKING_FILE:\n+\t    if (strncmp(buff, \"Working file\", 12) == 0) {\n+              if ((file = parse_working_file(buff))) \n+\t\tstate = NEED_SYMS;\n+              else\n+                state = NEED_RCS_FILE;\n+\t\tbreak;\n+\t    } else {\n+              // Working file come just after RCS file. So reset state if it was not found\n+              state = NEED_RCS_FILE;\n+            }\n+            break;\n \tcase NEED_SYMS:\n \t    if (strncmp(buff, \"symbolic names:\", 15) == 0)\n \t\tstate = NEED_EOS;\n@@ -471,7 +490,7 @@ static void load_from_cvs()\n \t\thave_log = 0;\n \t\tpsm = NULL;\n \t\tfile = NULL;\n-\t\tstate = NEED_FILE;\n+\t\tstate = NEED_RCS_FILE;\n \t    }\n \t    else\n \t    {\n@@ -524,7 +543,7 @@ static void load_from_cvs()\n \texit(1);\n     }\n \n-    if (state != NEED_FILE)\n+    if (state != NEED_RCS_FILE)\n     {\n \tdebug(DEBUG_APPERROR, \"Error: Log file parsing error. (%d)  Use -v to debug\", state);\n \texit(1);\n@@ -1039,7 +1058,7 @@ static void init_paths()\n      * NOTE: because of some bizarre 'feature' in cvs, when 'rlog' is used\n      * (instead of log) it gives the 'real' RCS file path, which can be different\n      * from the 'nominal' repository path because of symlinks in the server and \n-     * the like.  See also the 'parse_file' routine\n+     * the like.  See also the 'parse_rcs_file' routine\n      */\n     strip_path_len = snprintf(strip_path, PATH_MAX, \"%s/%s/\", p, repository_path);\n \n@@ -1052,9 +1071,8 @@ static void init_paths()\n     debug(DEBUG_STATUS, \"strip_path: %s\", strip_path);\n }\n \n-static CvsFile * parse_file(const char * buff)\n+static CvsFile * parse_rcs_file(const char * buff)\n {\n-    CvsFile * retval;\n     char fn[PATH_MAX];\n     int len = strlen(buff + 10);\n     char * p;\n@@ -1129,6 +1147,28 @@ static CvsFile * parse_file(const char *\n \n     debug(DEBUG_STATUS, \"stripped filename %s\", fn);\n \n+    return build_file_by_name(fn);\n+}\n+\n+static CvsFile * parse_working_file(const char * buff)\n+{\n+    char fn[PATH_MAX];\n+    int len = strlen(buff + 14);\n+\n+    /* chop the \"LF\" */\n+    len -= 1;\n+    memcpy(fn, buff + 14, len);\n+    fn[len] = 0;\n+    \n+    debug(DEBUG_STATUS, \"working filename %s\", fn);\n+\n+    return build_file_by_name(fn);\n+}\n+\n+static CvsFile * build_file_by_name(const char * fn)\n+{\n+    CvsFile * retval;\n+\n     retval = (CvsFile*)get_hash_object(file_hash, fn);\n \n     if (!retval)\n-- \n1.4.0\n"},{"id":"21822","messageId":"20060615073445.GG7766@nowhere.earth","threadId":"4517","inReplyTo":"200606151249.17518.lan@academsoft.ru","subject":"Re: [PATCH for cvsps] Handle cvs repo with modules","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2006-06-15T07:34:45Z","receivedAt":"2006-06-15T07:34:45Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"On Thu, Jun 15, 2006 at 12:49:17PM +0700, Alexander Litvinov wrote:\n> Parse 'Working file' lines from cvs log output. This alow to work with cvs repos \n> with modules. To enable this you need to add --no-rlog to cvsps command line args.\n> \n> This patch was made to import such repo into git. But git-cvsimport can't load such data.\n\nThanks, applied (with --whitespace=strip).\n\nBest regards,\n-- \nYann Dirson    <ydirson@altern.org> |\nDebian-related: <dirson@debian.org> |   Support Debian GNU/Linux:\n                                    |  Freedom, Power, Stability, Gratis\n     http://ydirson.free.fr/        | Check <http://www.debian.org/>\n"},{"id":"21971","messageId":"20060617213327.GW1297@nowhere.earth","threadId":"4517","inReplyTo":"200606151249.17518.lan@academsoft.ru","subject":"Re: [PATCH for cvsps] Handle cvs repo with modules","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2006-06-17T21:33:27Z","receivedAt":"2006-06-17T21:33:27Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"On Thu, Jun 15, 2006 at 12:49:17PM +0700, Alexander Litvinov wrote:\n> Parse 'Working file' lines from cvs log output. This alow to work\n> with cvs repos with modules. To enable this you need to add\n> --no-rlog to cvsps command line args.  This patch was made to import\n> such repo into git. But git-cvsimport can't load such data.\n\nJust forgot to mention it, but this patch was applied to master.\n\nThanks,\n-- \nYann Dirson    <ydirson@altern.org> |\nDebian-related: <dirson@debian.org> |   Support Debian GNU/Linux:\n                                    |  Freedom, Power, Stability, Gratis\n     http://ydirson.free.fr/        | Check <http://www.debian.org/>\n"}]}