changeset 8126:13b36eb14324

convert/bzr: handle files replaced by directories (issue1623)
author Patrick Mezard <pmezard@gmail.com>
date Thu, 23 Apr 2009 15:07:05 +0200
parents da9f3866c637
children 17ab4dab50a6 1467705473d5 adce97d28389
files hgext/convert/bzr.py tests/hghave tests/test-convert-bzr-114 tests/test-convert-bzr-114.out
diffstat 4 files changed, 55 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/convert/bzr.py	Thu Apr 23 08:45:44 2009 +0200
+++ b/hgext/convert/bzr.py	Thu Apr 23 15:07:05 2009 +0200
@@ -148,6 +148,11 @@
             # bazaar tracks directories, mercurial does not, so
             # we have to rename the directory contents
             if kind[1] == 'directory':
+                if kind[0] not in (None, 'directory'):
+                    # Replacing 'something' with a directory, record it
+                    # so it can be removed.
+                    changes.append((self.recode(paths[0]), revid))
+
                 if None not in paths and paths[0] != paths[1]:
                     # neither an add nor an delete - a move
                     # rename all directory contents manually
--- a/tests/hghave	Thu Apr 23 08:45:44 2009 +0200
+++ b/tests/hghave	Thu Apr 23 15:07:05 2009 +0200
@@ -31,6 +31,14 @@
     except ImportError:
         return False
 
+def has_bzr114():
+    try:
+        import bzrlib
+        return (bzrlib.__doc__ != None
+                and bzrlib.version_info[:2] == (1, 14))
+    except ImportError:
+        return False
+
 def has_cvs():
     re = r'Concurrent Versions System.*?server'
     return matchoutput('cvs --version 2>&1', re)
@@ -163,6 +171,7 @@
 checks = {
     "baz": (has_baz, "GNU Arch baz client"),
     "bzr": (has_bzr, "Canonical's Bazaar client"),
+    "bzr114": (has_bzr114, "Canonical's Bazaar client >= 1.14"),
     "cvs": (has_cvs, "cvs client/server"),
     "cvsps": (has_cvsps, "cvsps utility"),
     "darcs": (has_darcs, "darcs client"),
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-convert-bzr-114	Thu Apr 23 15:07:05 2009 +0200
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+"$TESTDIR/hghave" bzr114 || exit 80
+
+. "$TESTDIR/bzr-definitions"
+
+# The file/directory replacement can only be reproduced on
+# bzr >= 1.4. Merge it back in test-convert-bzr-directories once
+# this version becomes mainstream.
+echo % replace file with dir
+mkdir test-replace-file-with-dir
+cd test-replace-file-with-dir
+bzr init -q source
+cd source
+echo d > d
+bzr add -q d
+bzr commit -q -m 'add d file'
+rm d
+mkdir d
+bzr add -q d
+bzr commit -q -m 'replace with d dir'
+echo a > d/a
+bzr add -q d/a
+bzr commit -q -m 'add d/a'
+cd ..
+hg convert source source-hg
+manifest source-hg tip
+cd source-hg
+hg update
+cd ../..
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-convert-bzr-114.out	Thu Apr 23 15:07:05 2009 +0200
@@ -0,0 +1,11 @@
+% replace file with dir
+initializing destination source-hg repository
+scanning source...
+sorting...
+converting...
+2 add d file
+1 replace with d dir
+0 add d/a
+% manifest of tip
+644   d/a
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved