convert: avoid dirstate checks; add a test
authorAlexis S. L. Carvalho <alexis@cecm.usp.br>
Sat, 01 Sep 2007 02:49:18 -0300
changeset 5278 70e9a527cc61
parent 5277 a32a8e50d233
child 5279 2dbd750b3ddd
convert: avoid dirstate checks; add a test During a conversion, the dirstate contents are not consistent - there are files that may be missing from the dirstate and there may be files that shouldn't be in the dirstate. While this is not fixed, don't mark files as added - put them directly in state 'n'ormal.
hgext/convert/hg.py
tests/test-convert-hg-sink
tests/test-convert-hg-sink.out
--- a/hgext/convert/hg.py	Fri Aug 31 23:15:44 2007 +0200
+++ b/hgext/convert/hg.py	Sat Sep 01 02:49:18 2007 -0300
@@ -50,7 +50,7 @@
     def putfile(self, f, e, data):
         self.repo.wwrite(f, data, e)
         if f not in self.repo.dirstate:
-            self.repo.dirstate.add(f)
+            self.repo.dirstate.normallookup(f)
 
     def copyfile(self, source, dest):
         self.repo.copy(source, dest)
@@ -111,7 +111,7 @@
             p2 = parents.pop(0)
             a = self.repo.rawcommit(files, text, commit.author, commit.date,
                                     bin(p1), bin(p2), extra=extra)
-            self.repo.dirstate.invalidate()
+            self.repo.dirstate.clear()
             text = "(octopus merge fixup)\n"
             p2 = hg.hex(self.repo.changelog.tip())
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-convert-hg-sink	Sat Sep 01 02:49:18 2007 -0300
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+echo "[extensions]" >> $HGRCPATH
+echo "hgext.convert=" >> $HGRCPATH
+
+hg init orig
+cd orig
+echo foo > foo
+echo bar > bar
+hg ci -qAm 'add foo and bar' -d '0 0'
+
+hg rm foo
+hg ci -m 'remove foo' -d '0 0'
+
+mkdir foo
+echo file > foo/file
+hg ci -qAm 'add foo/file' -d '0 0'
+
+hg tag -d '0 0' some-tag
+
+hg log
+cd ..
+
+hg convert orig new 2>&1 | grep -v 'subversion python bindings could not be loaded'
+cd new
+hg out ../orig
+true
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-convert-hg-sink.out	Sat Sep 01 02:49:18 2007 -0300
@@ -0,0 +1,33 @@
+changeset:   3:593cbf6fb2b4
+tag:         tip
+user:        test
+date:        Thu Jan 01 00:00:00 1970 +0000
+summary:     Added tag some-tag for changeset ad681a868e44
+
+changeset:   2:ad681a868e44
+tag:         some-tag
+user:        test
+date:        Thu Jan 01 00:00:00 1970 +0000
+summary:     add foo/file
+
+changeset:   1:cbba8ecc03b7
+user:        test
+date:        Thu Jan 01 00:00:00 1970 +0000
+summary:     remove foo
+
+changeset:   0:327daa9251fa
+user:        test
+date:        Thu Jan 01 00:00:00 1970 +0000
+summary:     add foo and bar
+
+initializing destination new repository
+scanning source...
+sorting...
+converting...
+3 add foo and bar
+2 remove foo
+1 add foo/file
+0 Added tag some-tag for changeset ad681a868e44
+comparing with ../orig
+searching for changes
+no changes found