[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] Issue 1440 - cvs2svn fails with AttributeError: 'NoneType' object has no attribute 'get'

From: Tobias Ringström <tobias_at_ringstrom.mine.nu>
Date: 2003-11-12 00:47:03 CET

A lot of people are hitting issue 1440. I've looked into it and I'd
like to share some thoughts and a simple patch.

The root of the problem is that a branch can be rooted in a dead CVS
revision. This happens if you add a file to a branch that is either
nonexistant or deleted in the revision where the branch is rooted. For
example, if you add a new file in a branch that does not exist in trunk,
it will be created as version 1.1.2.1, but a dead parent revision 1.1 is
also created.

When the current code discovers that the parent revision is dead, it
tries to find a parent in the next older trunk revision. This works for
some simple cases, but not for all, and most notably not for the 1.1.2.1
case above. The discussion in the issue tracker suggests that cvs2svn
should have a way to find the youngest older trunk revision where the
file exists and perform a copy from that revision, and if that fails
just perform an add.

There are two ways the new file can be created, namely add or merge, and
there is no way we can know which one, and even if we could somehow find
out that it was a merge, we couldn't know which revision it was merged
from. If we perform a copy with history, we will probably make a
mistake, and possibly confuse the user a tiny bit. The obvious solution
is then to alway do an add and not a copy.

The attached patch performs that, but I need a review from a cvs2svn
expert to be sure that it really works as intended since I'm more or
less fumbling in the dark when it comes to cvs2svn. I've tested it on a
bunch of repositories, including the cvs2svn tests suite, and it seems
to do the right thing. I modified the cvs2svn test 14 to match the new
behaviour. Test 16 was also fixed by this change.

It would be great to have issue 1440 fixed in 0.33.

/Tobias

* tools/cvs2svn/cvs2svn.py
   (RepositoryMirror::change_path) Handle branch files with dead parents.
* tools/cvs2svn/run-tests.py
   (phoenix_branch) Do not require copy with history for test to pass.
   Remove the XFail from the phoenix_branch test.

Index: tools/cvs2svn/cvs2svn.py
===================================================================
--- tools/cvs2svn/cvs2svn.py (revision 7702)
+++ tools/cvs2svn/cvs2svn.py (working copy)
@@ -672,12 +672,11 @@
       new_val = self.probe_path(copyfrom_path, copyfrom_rev)
       if new_val is None:
         # Sometimes a branch is rooted in a revision that RCS has
- # marked as 'dead'. Since that path will have been deleted in
- # the corresponding Subversion revision, we use the revision
- # right before it as the copyfrom rev, and return that to the
- # caller so it can emit the right dumpfile instructions.
- actual_copy_rev = copyfrom_rev - 1
- new_val = self.probe_path(copyfrom_path, actual_copy_rev)
+ # marked as 'dead'. Do nothing and return.
+ if expected_entries:
+ return Change(OP_NOOP, [], [], [])
+ else:
+ return Change(OP_NOOP, [], [])
     if expected_entries:
       approved_entries = new_val.get(self.approved_entries) or { }
       new_approved_entries = { }
Index: tools/cvs2svn/run-tests.py
===================================================================
--- tools/cvs2svn/run-tests.py (revision 7702)
+++ tools/cvs2svn/run-tests.py (working copy)
@@ -674,10 +674,9 @@
 def phoenix_branch():
   "convert a branch file rooted in a 'dead' revision"
   repos, wc, logs = ensure_conversion('phoenix')
- if not ((logs[4].changed_paths.get('/branches/volsung_20010721 '
- '(from /trunk:2)') == 'A')
+ if not ((logs[4].changed_paths.get('/branches/volsung_20010721') == 'A')
           and (logs[4].changed_paths.get('/branches/volsung_20010721/'
- 'phoenix') == 'M')
+ 'phoenix') == 'A')
           and (len(logs[4].changed_paths) == 2)):
     print "Revision 4 not as expected."
     raise svntest.Failure
@@ -769,7 +768,7 @@
               tolerate_corruption,
               phoenix_branch,
               ctrl_char_in_log,
- XFail(overdead),
+ overdead,
               double_delete,
               split_branch,
               resync_misgroups,

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Wed Nov 12 00:47:53 2003

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.