# HG changeset patch # User Alexis S. L. Carvalho # Date 1188625758 10800 # Node ID 70e9a527cc610a2eb2234335e11a672415ff0b8a # Parent a32a8e50d233556d76e12890079af0bf5e07fa23 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. diff --git a/hgext/convert/hg.py b/hgext/convert/hg.py --- a/hgext/convert/hg.py +++ b/hgext/convert/hg.py @@ -50,7 +50,7 @@ class mercurial_sink(converter_sink): 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 @@ class mercurial_sink(converter_sink): 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()) diff --git a/tests/test-convert-hg-sink b/tests/test-convert-hg-sink new file mode 100755 --- /dev/null +++ b/tests/test-convert-hg-sink @@ -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 diff --git a/tests/test-convert-hg-sink.out b/tests/test-convert-hg-sink.out new file mode 100644 --- /dev/null +++ b/tests/test-convert-hg-sink.out @@ -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