diff hgext/convert/convcmd.py @ 8692:827d4e807d57

convert: default revisions order depends on source When converting Mercurial repositories you expect the revision numbers to be preserved, while other sources conversions focus on efficiency.
author Patrick Mezard <pmezard@gmail.com>
date Mon, 01 Jun 2009 17:12:41 +0200
parents a0a541d6fed6
children 68e0a55eee6e
line wrap: on
line diff
--- a/hgext/convert/convcmd.py	Mon Jun 01 17:12:39 2009 +0200
+++ b/hgext/convert/convcmd.py	Mon Jun 01 17:12:41 2009 +0200
@@ -30,15 +30,15 @@
         return s.decode('utf-8').encode(orig_encoding, 'replace')
 
 source_converters = [
-    ('cvs', convert_cvs),
-    ('git', convert_git),
-    ('svn', svn_source),
-    ('hg', mercurial_source),
-    ('darcs', darcs_source),
-    ('mtn', monotone_source),
-    ('gnuarch', gnuarch_source),
-    ('bzr', bzr_source),
-    ('p4', p4_source),
+    ('cvs', convert_cvs, 'branchsort'),
+    ('git', convert_git, 'branchsort'),
+    ('svn', svn_source, 'branchsort'),
+    ('hg', mercurial_source, 'sourcesort'),
+    ('darcs', darcs_source, 'branchsort'),
+    ('mtn', monotone_source, 'branchsort'),
+    ('gnuarch', gnuarch_source, 'branchsort'),
+    ('bzr', bzr_source, 'branchsort'),
+    ('p4', p4_source, 'branchsort'),
     ]
 
 sink_converters = [
@@ -48,10 +48,10 @@
 
 def convertsource(ui, path, type, rev):
     exceptions = []
-    for name, source in source_converters:
+    for name, source, sortmode in source_converters:
         try:
             if not type or name == type:
-                return source(ui, path, rev)
+                return source(ui, path, rev), sortmode
         except (NoRepo, MissingTool), inst:
             exceptions.append(inst)
     if not ui.quiet:
@@ -364,18 +364,18 @@
     destc = convertsink(ui, dest, opts.get('dest_type'))
 
     try:
-        srcc = convertsource(ui, src, opts.get('source_type'),
-                             opts.get('rev'))
+        srcc, defaultsort = convertsource(ui, src, opts.get('source_type'),
+                                          opts.get('rev'))
     except Exception:
         for path in destc.created:
             shutil.rmtree(path, True)
         raise
 
-    sortmodes = ('datesort', 'sourcesort')
+    sortmodes = ('branchsort', 'datesort', 'sourcesort')
     sortmode = [m for m in sortmodes if opts.get(m)]
     if len(sortmode) > 1:
         raise util.Abort(_('more than one sort mode specified'))
-    sortmode = sortmode and sortmode[0] or 'branchsort'
+    sortmode = sortmode and sortmode[0] or defaultsort
     if sortmode == 'sourcesort' and not srcc.hasnativeorder():
         raise util.Abort(_('--sourcesort is not supported by this data source'))