monotone-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Monotone-devel] PATCH: cvs_pull fix and test for n.v.m.cvssync branch


From: Emile Snyder
Subject: [Monotone-devel] PATCH: cvs_pull fix and test for n.v.m.cvssync branch
Date: 14 Apr 2005 04:42:16 -0700

While trying the latest head of net.venge.monotone.cvssync for a
cvs_pull of a module I hit a problem where it claims (to the CVS server)
to support the "Template" response, but does not implement a handler for
it.  A little poking into the CVS protocol, and I came up with the
attached patch.  Note that this doesn't do anything with the template
file recieved from the server.  Perhaps we could store it in a file in
MT/, and change the default get_comment() hook to use it...

-emile

# 
# add_file "tests/t_cvspull_committemplate.at"
# 
# patch "cvs_client.cc"
#  from [4bec53be82a9270e46502a8d07a57238d8a3a14d]
#    to [7e7ddbf4ac9f341d9381a458fcf26557cf383855]
# 
# patch "cvs_client.hh"
#  from [86c60057e7f4e7701941f3325443830055c6d26f]
#    to [a126f6ae155fccaf112c204428d9afc4e1329acc]
# 
# patch "tests/t_cvspull_committemplate.at"
#  from []
#    to [7c73e405066e7832eb9f7b546badf8b0c6840bcd]
# 
# patch "testsuite.at"
#  from [14b8600c48fdafc19eba6942e2270738b4bd8c71]
#    to [39bb6aec8093accd6899e52f691e71fc2fef932b]
# 
--- cvs_client.cc
+++ cvs_client.cc
@@ -508,6 +508,15 @@
     result.push_back(std::make_pair("rcs",readline()));
     return true;
   }
+  if (begins_with(x,"Template ",len))
+  { result.push_back(std::make_pair("CMD",x.substr(0,len-1)));
+    result.push_back(std::make_pair("dir",x.substr(len)));
+    result.push_back(std::make_pair("path",readline()));
+    std::string length=readline();
+    result.push_back(std::make_pair("length",length));
+   
result.push_back(std::make_pair("data",read_n(atol(length.c_str()))));
+    return true;
+  }
   if (begins_with(x,"Mod-time ",len))
   { result.push_back(std::make_pair("CMD",x.substr(0,len-1)));
     result.push_back(std::make_pair("date",x.substr(len)));
@@ -1022,6 +1031,16 @@
             L(F("file %s revision %s: %d bytes\n") % file 
                 % revision % lresult[6].second.size());
           }
+          else if (lresult[0].second=="Template")
+          { I(lresult.size()==5);
+            I(lresult[3].first=="length");
+            long len = atol(lresult[3].second.c_str());
+            I(len >= 0);
+            I(lresult[4].second.size() == (size_t) len);
+            L(F("found commit template %s:\n%s") % lresult[2].second %
lresult[4].second);
+            // FIX actually do something with the template?
+            result.committemplate = lresult[4].second;
+          }
           else if (lresult[0].second=="error")
           { throw oops("failed to check out "+file);
           }
@@ -1414,7 +1433,9 @@
   { I(!lresult.empty());
     I(lresult[0].first=="CMD");
     if (lresult[0].second=="Set-sticky"
-        || lresult[0].second=="Clear-template") continue;
+        || lresult[0].second=="Clear-template"
+        || lresult[0].second=="Template") continue;
+    L(F("cvs_client::RequestServerDir lresult[0].second is '%s', not
'Clear-static-directory'") % lresult[0].second);
     I(lresult[0].second=="Clear-static-directory");
     I(lresult.size()==3);
     if (!last_rcs.empty() && begins_with(lresult[2].second,last_rcs)
--- cvs_client.hh
+++ cvs_client.hh
@@ -46,6 +46,7 @@
     std::string mode;
     bool dead;
     std::string keyword_substitution;
+    std::string committemplate;
     
     checkout() : mod_time(-1), dead() {}
   };
--- tests/t_cvspull_committemplate.at
+++ tests/t_cvspull_committemplate.at
@@ -0,0 +1,77 @@
+#  -*- Autoconf -*-
+
+AT_SETUP([pull of CVS module that has a commit template])
+
+MONOTONE_SETUP
+
+AT_DATA(importme.0, [version 0 of test file
+])
+
+AT_DATA(importme.1, [version 1 of test file
+])
+
+AT_DATA(importme.2, [version 2 of test file
+])
+
+AT_DATA(importme.3, [version 3 of test file
+])
+
+AT_DATA(committemplate, [This is my commit template
+])
+AT_DATA(newrcsinfo, [ALL `pwd`/committemplate
+])
+
+TSHA0=`SHA1(importme.0)`
+TSHA1=`SHA1(importme.1)`
+TSHA2=`SHA1(importme.2)`
+TSHA3=`SHA1(importme.3)`
+
+# build the cvs repository
+
+CVSROOT=`pwd`/cvs-repository
+AT_CHECK(cvs -q -d $CVSROOT init)
+AT_CHECK(test -e $CVSROOT)
+AT_CHECK(test -e $CVSROOT/CVSROOT)
+AT_CHECK(test -e $CVSROOT/CVSROOT/history)
+
+# check out the CVSROOT admin module and edit the rcsinfo file to give
ourself a commit template
+
+AT_CHECK(cvs -d $CVSROOT co CVSROOT, [], [ignore], [ignore])
+AT_CHECK(cp newrcsinfo CVSROOT/rcsinfo)
+AT_CHECK(cvs -d $CVSROOT commit -m 'adding commit template entry to
rcsinfo' CVSROOT/rcsinfo, [], [ignore], [ignore])
+
+
+# check out the working copy and make some commits
+
+AT_CHECK(cvs -d $CVSROOT co ., [], [ignore], [ignore])
+AT_CHECK(mkdir testdir)
+AT_CHECK(cp importme.0 testdir/importme)
+AT_CHECK(cvs -d $CVSROOT add testdir, [], [ignore], [ignore])
+AT_CHECK(cvs -d $CVSROOT add testdir/importme, [], [ignore], [ignore])
+AT_CHECK(cvs -d $CVSROOT commit -m 'commit 0' testdir/importme, [],
[ignore], [ignore])
+AT_CHECK(cp importme.1 testdir/importme)
+AT_CHECK(cvs -d $CVSROOT commit -m 'commit 1' testdir/importme, [],
[ignore], [ignore])
+AT_CHECK(cp importme.2 testdir/importme)
+AT_CHECK(cvs -d $CVSROOT commit -m 'commit 2' testdir/importme, [],
[ignore], [ignore])
+AT_CHECK(cp importme.3 testdir/importme)
+AT_CHECK(cvs -d $CVSROOT commit -m 'commit 3' testdir/importme, [],
[ignore], [ignore])
+
+# pull into monotone
+
+AT_CHECK(MONOTONE --branch=testbranch cvs_pull $CVSROOT testdir, [],
[ignore], [ignore])
+
+
+# check presence of files
+
+AT_CHECK(MONOTONE cat file $TSHA0, [], [ignore])
+AT_CHECK(MONOTONE cat file $TSHA1, [], [ignore])
+AT_CHECK(MONOTONE cat file $TSHA2, [], [ignore])
+AT_CHECK(MONOTONE cat file $TSHA3, [], [ignore])
+
+# also check that history is okay -- has a unique head, and it's the
+# right one.
+
+AT_CHECK(MONOTONE checkout --branch=testbranch mtcodir, [], [ignore],
[ignore])
+AT_CHECK(cmp importme.3 mtcodir/importme)
+
+AT_CLEANUP
--- testsuite.at
+++ testsuite.at
@@ -551,3 +551,4 @@
 m4_include(tests/t_netsync_largish_file.at)
 m4_include(tests/t_update_off_branch.at)
 m4_include(tests/t_setup_checkout_modify_new_dir.at)
+m4_include(tests/t_cvspull_committemplate.at)

+----------------------------------------------------------------------
this wine is particularly heavy, and is mostly recommended for
hand-to-hand combat. -- Eric Idle 
+----------------------------------------------------------------------

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]