Mercurial > hg
comparison hgext/convert/convcmd.py @ 8690:c5b4f662109f
convert: add --sourcesort option for source specific sort
Only supported by Mercurial source for now.
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Mon, 01 Jun 2009 17:12:39 +0200 |
parents | 9bc95f8eb018 |
children | a0a541d6fed6 |
comparison
equal
deleted
inserted
replaced
8689:9bc95f8eb018 | 8690:c5b4f662109f |
---|---|
167 break | 167 break |
168 prev[0] = next | 168 prev[0] = next |
169 return next | 169 return next |
170 return picknext | 170 return picknext |
171 | 171 |
172 def makesourcesorter(): | |
173 """Source specific sort.""" | |
174 keyfn = lambda n: self.commitcache[n].sortkey | |
175 def picknext(nodes): | |
176 return sorted(nodes, key=keyfn)[0] | |
177 return picknext | |
178 | |
172 def makedatesorter(): | 179 def makedatesorter(): |
173 """Sort revisions by date.""" | 180 """Sort revisions by date.""" |
174 dates = {} | 181 dates = {} |
175 def getdate(n): | 182 def getdate(n): |
176 if n not in dates: | 183 if n not in dates: |
184 | 191 |
185 if sortmode == 'branchsort': | 192 if sortmode == 'branchsort': |
186 picknext = makebranchsorter() | 193 picknext = makebranchsorter() |
187 elif sortmode == 'datesort': | 194 elif sortmode == 'datesort': |
188 picknext = makedatesorter() | 195 picknext = makedatesorter() |
196 elif sortmode == 'sourcesort': | |
197 picknext = makesourcesorter() | |
189 else: | 198 else: |
190 raise util.Abort(_('unknown sort mode: %s') % sortmode) | 199 raise util.Abort(_('unknown sort mode: %s') % sortmode) |
191 | 200 |
192 children, actives = mapchildren(parents) | 201 children, actives = mapchildren(parents) |
193 | 202 |
360 except Exception: | 369 except Exception: |
361 for path in destc.created: | 370 for path in destc.created: |
362 shutil.rmtree(path, True) | 371 shutil.rmtree(path, True) |
363 raise | 372 raise |
364 | 373 |
365 sortmode = 'branchsort' | 374 sortmodes = ('datesort', 'sourcesort') |
366 if opts.get('datesort'): | 375 sortmode = [m for m in sortmodes if opts.get(m)] |
367 sortmode = 'datesort' | 376 if len(sortmode) > 1: |
377 raise util.Abort(_('more than one sort mode specified')) | |
378 sortmode = sortmode and sortmode[0] or 'branchsort' | |
368 | 379 |
369 fmap = opts.get('filemap') | 380 fmap = opts.get('filemap') |
370 if fmap: | 381 if fmap: |
371 srcc = filemap.filemap_source(ui, srcc, fmap) | 382 srcc = filemap.filemap_source(ui, srcc, fmap) |
372 destc.setfilemapmode(True) | 383 destc.setfilemapmode(True) |