convert: fail fast if source does not support --sourcesort
authorPatrick Mezard <pmezard@gmail.com>
Mon, 01 Jun 2009 17:12:39 +0200
changeset 8691 a0a541d6fed6
parent 8690 c5b4f662109f
child 8692 827d4e807d57
convert: fail fast if source does not support --sourcesort
hgext/convert/common.py
hgext/convert/convcmd.py
hgext/convert/filemap.py
hgext/convert/hg.py
tests/test-convert-git
tests/test-convert-git.out
--- a/hgext/convert/common.py	Mon Jun 01 17:12:39 2009 +0200
+++ b/hgext/convert/common.py	Mon Jun 01 17:12:39 2009 +0200
@@ -137,6 +137,13 @@
         '''Notify the source that a revision has been converted.'''
         pass
 
+    def hasnativeorder(self):
+        """Return true if this source has a meaningful, native revision
+        order. For instance, Mercurial revisions are store sequentially
+        while there is no such global ordering with Darcs.
+        """
+        return False
+
 
 class converter_sink(object):
     """Conversion sink (target) interface"""
--- a/hgext/convert/convcmd.py	Mon Jun 01 17:12:39 2009 +0200
+++ b/hgext/convert/convcmd.py	Mon Jun 01 17:12:39 2009 +0200
@@ -376,6 +376,8 @@
     if len(sortmode) > 1:
         raise util.Abort(_('more than one sort mode specified'))
     sortmode = sortmode and sortmode[0] or 'branchsort'
+    if sortmode == 'sourcesort' and not srcc.hasnativeorder():
+        raise util.Abort(_('--sourcesort is not supported by this data source'))
 
     fmap = opts.get('filemap')
     if fmap:
--- a/hgext/convert/filemap.py	Mon Jun 01 17:12:39 2009 +0200
+++ b/hgext/convert/filemap.py	Mon Jun 01 17:12:39 2009 +0200
@@ -351,3 +351,6 @@
 
     def gettags(self):
         return self.base.gettags()
+
+    def hasnativeorder(self):
+        return self.base.hasnativeorder()
--- a/hgext/convert/hg.py	Mon Jun 01 17:12:39 2009 +0200
+++ b/hgext/convert/hg.py	Mon Jun 01 17:12:39 2009 +0200
@@ -338,3 +338,6 @@
 
     def after(self):
         self.ui.debug(_('run hg source post-conversion action\n'))
+
+    def hasnativeorder(self):
+        return True
--- a/tests/test-convert-git	Mon Jun 01 17:12:39 2009 +0200
+++ b/tests/test-convert-git	Mon Jun 01 17:12:39 2009 +0200
@@ -165,5 +165,9 @@
 
 echo '% convert author committer'
 hg convert git-repo4 git-repo4-hg
-cd git-repo4-hg
-hg log -v
+hg -R git-repo4-hg log -v
+
+echo '% --sourceorder should fail'
+hg convert --sourcesort git-repo4 git-repo4-sourcesort-hg
+
+true
--- a/tests/test-convert-git.out	Mon Jun 01 17:12:39 2009 +0200
+++ b/tests/test-convert-git.out	Mon Jun 01 17:12:39 2009 +0200
@@ -124,3 +124,6 @@
 addfoo
 
 
+% --sourceorder should fail
+initializing destination git-repo4-sourcesort-hg repository
+abort: --sourcesort is not supported by this data source