[PATCH resend] convert: teach cvsps to handle . repository [issue 1649]

Mathieu Clabaut mathieu.clabaut at gmail.com
Tue Mar 9 05:11:48 CST 2010


# HG changeset patch
# User Mathieu Clabaut <mathieu.clabaut at systerel.fr>
# Date 1268132997 -3600
# Node ID 707027328bd6f16ce762f5200ab8df4348911495
# Parent  261cc6b0f15c7e83dcff7dd7d5f3607c098c29bd
convert: teach cvsps to handle . repository [issue 1649]

For a CVS repository checked out with "cvs co .", the prefix used to strip of
what we get from CVS was previously erroneously set to "repopath/.".
We now prevent the dot to be added.

diff -r 261cc6b0f15c -r 707027328bd6 hgext/convert/cvsps.py
--- a/hgext/convert/cvsps.py	Thu Feb 18 23:23:17 2010 -0600
+++ b/hgext/convert/cvsps.py	Tue Mar 09 12:09:57 2010 +0100
@@ -124,9 +124,9 @@
         # Get the real directory in the repository
         try:
             prefix = open(os.path.join('CVS','Repository')).read().strip()
+            directory = prefix
             if prefix == ".":
                 prefix = ""
-            directory = prefix
         except IOError:
             raise logerror('Not a CVS sandbox')
 
@@ -184,7 +184,10 @@
         p = util.normpath(getrepopath(root))
         if not p.endswith('/'):
             p += '/'
-        prefix = p + util.normpath(prefix)
+        if prefix != "": # looks like normpath replaces "" by "."
+            prefix = p + util.normpath(prefix)
+        else:
+            prefix = p
     cmd.append(['log', 'rlog'][rlog])
     if date:
         # no space between option and date string
diff -r 261cc6b0f15c -r 707027328bd6 tests/test-convert-cvs-dot
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-convert-cvs-dot	Tue Mar 09 12:09:57 2010 +0100
@@ -0,0 +1,75 @@
+#!/bin/sh
+
+"$TESTDIR/hghave" cvs || exit 80
+
+cvscall()
+{
+    cvs -f "$@"
+}
+
+hgcat()
+{
+    hg --cwd all-hg cat -r tip "$1"
+}
+
+echo "[extensions]" >> $HGRCPATH
+echo "convert = " >> $HGRCPATH
+echo "graphlog = " >> $HGRCPATH
+
+cat > cvshooks.py <<EOF
+def cvslog(ui,repo,hooktype,log):
+    print "%s hook: %d entries"%(hooktype,len(log))
+
+def cvschangesets(ui,repo,hooktype,changesets):
+    print "%s hook: %d changesets"%(hooktype,len(changesets))
+EOF
+hookpath=`pwd`
+
+echo "[hooks]" >> $HGRCPATH
+echo "cvslog=python:$hookpath/cvshooks.py:cvslog" >> $HGRCPATH
+echo "cvschangesets=python:$hookpath/cvshooks.py:cvschangesets" >> $HGRCPATH
+
+echo % create cvs repository
+mkdir cvsrepo
+cd cvsrepo
+CVSROOT=`pwd`
+export CVSROOT
+CVS_OPTIONS=-f
+export CVS_OPTIONS
+cd ..
+
+cvscall -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
+cvscall -q import -m import src INITIAL start
+cd ..
+
+echo % checkout source directory
+cvscall -q checkout src
+
+echo % commit a new revision changing b/c
+cd src
+sleep 1
+echo c >> b/c
+cvscall -q commit -mci0 . | grep '<--' |\
+    sed -e 's:.*src/\(.*\),v.*:checking in src/\1,v:g'
+cd ..
+
+sleep 1
+echo % checkout full repo
+cvscall -q -d "$CVSROOT" checkout -d cvscheckout "."
+ls cvscheckout
+echo % convert fresh repo
+hg convert cvscheckout all-hg | sed -e 's/connecting to.*cvsrepo/connecting to cvsrepo/g'
+hgcat src/a
+hgcat src/b/c
+
diff -r 261cc6b0f15c -r 707027328bd6 tests/test-convert-cvs-dot.out
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-convert-cvs-dot.out	Tue Mar 09 12:09:57 2010 +0100
@@ -0,0 +1,50 @@
+% 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
+% commit a new revision changing b/c
+checking in src/b/c,v
+% checkout full repo
+U cvscheckout/CVSROOT/checkoutlist
+U cvscheckout/CVSROOT/commitinfo
+U cvscheckout/CVSROOT/config
+U cvscheckout/CVSROOT/cvswrappers
+U cvscheckout/CVSROOT/editinfo
+U cvscheckout/CVSROOT/loginfo
+U cvscheckout/CVSROOT/modules
+U cvscheckout/CVSROOT/notify
+U cvscheckout/CVSROOT/rcsinfo
+U cvscheckout/CVSROOT/taginfo
+U cvscheckout/CVSROOT/verifymsg
+U cvscheckout/src/a
+U cvscheckout/src/b/c
+CVS
+CVSROOT
+src
+% convert fresh repo
+initializing destination all-hg repository
+connecting to cvsrepo
+scanning source...
+collecting CVS rlog
+16 log entries
+cvslog hook: 16 entries
+creating changesets
+4 changeset entries
+cvschangesets hook: 4 changesets
+sorting...
+converting...
+3 Initial revision
+2 import
+1 initial checkin
+0 ci0
+updating tags
+a
+c
+c




More information about the Mercurial-devel mailing list