hgext/convert/convcmd.py
changeset 8690 c5b4f662109f
parent 8689 9bc95f8eb018
child 8691 a0a541d6fed6
--- a/hgext/convert/convcmd.py	Mon Jun 01 17:12:38 2009 +0200
+++ b/hgext/convert/convcmd.py	Mon Jun 01 17:12:39 2009 +0200
@@ -169,6 +169,13 @@
                 return next
             return picknext
 
+        def makesourcesorter():
+            """Source specific sort."""
+            keyfn = lambda n: self.commitcache[n].sortkey
+            def picknext(nodes):
+                return sorted(nodes, key=keyfn)[0]
+            return picknext
+
         def makedatesorter():
             """Sort revisions by date."""
             dates = {}
@@ -186,6 +193,8 @@
             picknext = makebranchsorter()
         elif sortmode == 'datesort':
             picknext = makedatesorter()
+        elif sortmode == 'sourcesort':
+            picknext = makesourcesorter()
         else:
             raise util.Abort(_('unknown sort mode: %s') % sortmode)
 
@@ -362,9 +371,11 @@
             shutil.rmtree(path, True)
         raise
 
-    sortmode = 'branchsort'
-    if opts.get('datesort'):
-        sortmode = 'datesort'
+    sortmodes = ('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'
 
     fmap = opts.get('filemap')
     if fmap: