changeset 5308:9400d677efc7

Merge with crew-stable
author Patrick Mezard <pmezard@gmail.com>
date Fri, 14 Sep 2007 23:10:41 +0200
parents 81575b7b505e (current diff) 5b0b0834419c (diff)
children e21644bbf01e
files hgext/convert/cvs.py tests/hghave tests/test-convert-cvs.out
diffstat 4 files changed, 112 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/convert/cvs.py	Tue Sep 11 23:38:29 2007 +0200
+++ b/hgext/convert/cvs.py	Fri Sep 14 23:10:41 2007 +0200
@@ -40,9 +40,10 @@
                 try:
                     # date
                     util.parsedate(self.rev, ['%Y/%m/%d %H:%M:%S'])
-                    cmd = "%s -d '1970/01/01 00:00:01' -d '%s'" % (cmd, self.rev)
+                    cmd = '%s -d "1970/01/01 00:00:01" -d "%s"' % (cmd, self.rev)
                 except util.Abort:
                     raise util.Abort('revision %s is not a patchset number or date' % self.rev)
+        cmd += " 2>&1"
 
         d = os.getcwd()
         try:
@@ -166,7 +167,8 @@
             if root.startswith(":ext:"):
                 root = root[5:]
             m = re.match(r'(?:([^@:/]+)@)?([^:/]+):?(.*)', root)
-            if not m:
+            # Do not take Windows path "c:\foo\bar" for a connection strings
+            if os.path.isdir(root) or not m:
                 conntype = "local"
             else:
                 conntype = "rsh"
@@ -180,7 +182,10 @@
                 else:
                     cmd = [rsh, host] + cmd
 
-            self.writep, self.readp = os.popen2(cmd)
+            # popen2 does not support argument lists under Windows
+            cmd = [util.shellquote(arg) for arg in cmd]
+            cmd = util.quotecommand(' '.join(cmd))
+            self.writep, self.readp = os.popen2(cmd, 'b')
 
         self.realroot = root
 
@@ -206,7 +211,7 @@
             raise IOError
 
         args = ("-N -P -kk -r %s --" % rev).split()
-        args.append(os.path.join(self.cvsrepo, name))
+        args.append(self.cvsrepo + '/' + name)
         for x in args:
             self.writep.write("Argument %s\n" % x)
         self.writep.write("Directory .\n%s\nco\n" % self.realroot)
--- a/tests/hghave	Tue Sep 11 23:38:29 2007 +0200
+++ b/tests/hghave	Fri Sep 14 23:10:41 2007 +0200
@@ -11,7 +11,7 @@
 
 tempprefix = 'hg-hghave-'
 
-def matchoutput(cmd, regexp):
+def matchoutput(cmd, regexp, ignorestatus=False):
     """Return True if cmd executes successfully and its output
     is matched by the supplied regular expression.
     """
@@ -19,7 +19,7 @@
     fh = os.popen(cmd)
     s = fh.read()
     ret = fh.close()
-    return ret is None and r.search(s)
+    return (ignorestatus or ret is None) and r.search(s)
 
 def has_symlink():
     return hasattr(os, "symlink")
@@ -27,6 +27,12 @@
 def has_fifo():
     return hasattr(os, "mkfifo")
 
+def has_cvs():
+    return matchoutput('cvs --version 2>&1', r'Concurrent Versions System')
+
+def has_cvsps():
+    return matchoutput('cvsps -h -q 2>&1', r'cvsps version', True)
+
 def has_executablebit():
     fd, path = tempfile.mkstemp(prefix=tempprefix)
     os.close(fd)
@@ -77,6 +83,8 @@
         return False
 
 checks = {
+    "cvs": (has_cvs, "cvs client"),
+    "cvsps": (has_cvsps, "cvsps utility"),
     "eol-in-paths": (has_eol_in_paths, "end-of-lines in paths"),
     "execbit": (has_executablebit, "executable bit"),
     "git": (has_git, "git command line client"),
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-convert-cvs	Fri Sep 14 23:10:41 2007 +0200
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+"$TESTDIR/hghave" cvs cvsps || exit 80
+
+echo "[extensions]" >> $HGRCPATH
+echo "convert = " >> $HGRCPATH
+
+echo % create cvs repository
+mkdir cvsrepo
+cd cvsrepo
+export CVSROOT=`pwd`
+cd ..
+
+cvs -q -d "$CVSROOT" init
+
+echo % create source directory
+mkdir src-temp
+cd src-temp
+echo a > a
+mkdir b
+cd b
+echo c > c
+cd ..
+
+echo % import source directory
+cvs -q import -m import src INITIAL start
+cd ..
+
+echo % checkout source directory
+cvs -q checkout src
+
+echo % convert fresh repo
+hg convert src src-hg | sed -e 's/connecting to.*cvsrepo/connecting to cvsrepo/g'
+cat src-hg/a
+cat src-hg/b/c
+
+echo % commit new file revisions
+cd src
+echo a >> a
+echo c >> b/c
+cvs -q commit -mci1 . | sed -e 's:.*src/\(.*\),v:src/\1,v:g'
+cd ..
+
+echo % convert again
+hg convert src src-hg | sed -e 's/connecting to.*cvsrepo/connecting to cvsrepo/g'
+cat src-hg/a
+cat src-hg/b/c
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-convert-cvs.out	Fri Sep 14 23:10:41 2007 +0200
@@ -0,0 +1,43 @@
+% create cvs repository
+% create source directory
+% import source directory
+N src/a
+N src/b/c
+
+No conflicts created by this import
+
+% checkout source directory
+U src/a
+U src/b/c
+% convert fresh repo
+initializing destination src-hg repository
+connecting to cvsrepo
+scanning source...
+sorting...
+converting...
+1 Initial revision
+0 import
+updating tags
+a
+c
+% commit new file revisions
+Checking in a;
+src/a,v  <--  a
+new revision: 1.2; previous revision: 1.1
+done
+Checking in b/c;
+src/b/c,v  <--  c
+new revision: 1.2; previous revision: 1.1
+done
+% convert again
+destination src-hg is a Mercurial repository
+connecting to cvsrepo
+scanning source...
+sorting...
+converting...
+0 ci1
+updating tags
+a
+a
+c
+c