Show More
@@ -247,7 +247,8 b' cmdtable = {' | |||
|
247 | 247 | ('s', 'source-type', '', _('source repository type')), |
|
248 | 248 | ('', 'splicemap', '', _('splice synthesized history into place')), |
|
249 | 249 | ('', 'branchmap', '', _('change branch names while converting')), |
|
250 |
('', 'datesort', None, _('try to sort changesets by date')) |
|
|
250 | ('', 'datesort', None, _('try to sort changesets by date')), | |
|
251 | ('', 'sourcesort', None, _('preserve source changesets order'))], | |
|
251 | 252 | _('hg convert [OPTION]... SOURCE [DEST [REVMAP]]')), |
|
252 | 253 | "debugsvnlog": |
|
253 | 254 | (debugsvnlog, |
@@ -38,7 +38,7 b" SKIPREV = 'SKIP'" | |||
|
38 | 38 | |
|
39 | 39 | class commit(object): |
|
40 | 40 | def __init__(self, author, date, desc, parents, branch=None, rev=None, |
|
41 | extra={}): | |
|
41 | extra={}, sortkey=None): | |
|
42 | 42 | self.author = author or 'unknown' |
|
43 | 43 | self.date = date or '0 0' |
|
44 | 44 | self.desc = desc |
@@ -46,6 +46,7 b' class commit(object):' | |||
|
46 | 46 | self.branch = branch |
|
47 | 47 | self.rev = rev |
|
48 | 48 | self.extra = extra |
|
49 | self.sortkey = sortkey | |
|
49 | 50 | |
|
50 | 51 | class converter_source(object): |
|
51 | 52 | """Conversion source interface""" |
@@ -169,6 +169,13 b' class converter(object):' | |||
|
169 | 169 | return next |
|
170 | 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 | 179 | def makedatesorter(): |
|
173 | 180 | """Sort revisions by date.""" |
|
174 | 181 | dates = {} |
@@ -186,6 +193,8 b' class converter(object):' | |||
|
186 | 193 | picknext = makebranchsorter() |
|
187 | 194 | elif sortmode == 'datesort': |
|
188 | 195 | picknext = makedatesorter() |
|
196 | elif sortmode == 'sourcesort': | |
|
197 | picknext = makesourcesorter() | |
|
189 | 198 | else: |
|
190 | 199 | raise util.Abort(_('unknown sort mode: %s') % sortmode) |
|
191 | 200 | |
@@ -362,9 +371,11 b' def convert(ui, src, dest=None, revmapfi' | |||
|
362 | 371 | shutil.rmtree(path, True) |
|
363 | 372 | raise |
|
364 | 373 | |
|
365 |
sortmode = ' |
|
|
366 | if opts.get('datesort'): | |
|
367 | sortmode = 'datesort' | |
|
374 | sortmodes = ('datesort', 'sourcesort') | |
|
375 | sortmode = [m for m in sortmodes if opts.get(m)] | |
|
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 | 380 | fmap = opts.get('filemap') |
|
370 | 381 | if fmap: |
@@ -302,7 +302,8 b' class mercurial_source(converter_source)' | |||
|
302 | 302 | crev = None |
|
303 | 303 | return commit(author=ctx.user(), date=util.datestr(ctx.date()), |
|
304 | 304 | desc=ctx.description(), rev=crev, parents=parents, |
|
305 |
branch=ctx.branch(), extra=ctx.extra() |
|
|
305 | branch=ctx.branch(), extra=ctx.extra(), | |
|
306 | sortkey=ctx.rev()) | |
|
306 | 307 | |
|
307 | 308 | def gettags(self): |
|
308 | 309 | tags = [t for t in self.repo.tagslist() if t[0] != 'tip'] |
@@ -20,10 +20,10 b" hg ci -m a3 -d '4 0'" | |||
|
20 | 20 | hg up -C 0 |
|
21 | 21 | hg branch branchb |
|
22 | 22 | echo b >> b |
|
23 |
hg ci -Am b0 -d ' |
|
|
23 | hg ci -Am b0 -d '6 0' | |
|
24 | 24 | hg up -C brancha |
|
25 | 25 | echo a >> a |
|
26 |
hg ci -m a4 -d ' |
|
|
26 | hg ci -m a4 -d '5 0' | |
|
27 | 27 | echo a >> a |
|
28 | 28 | hg ci -m a5 -d '7 0' |
|
29 | 29 | echo a >> a |
@@ -34,7 +34,12 b" hg ci -m b1 -d '9 0'" | |||
|
34 | 34 | cd .. |
|
35 | 35 | |
|
36 | 36 | echo % convert with datesort |
|
37 |
hg convert --datesort t t |
|
|
37 | hg convert --datesort t t-datesort | |
|
38 | 38 | echo % graph converted repo |
|
39 |
hg -R t |
|
|
39 | hg -R t-datesort glog --template '{rev} "{desc}"\n' | |
|
40 | 40 | |
|
41 | echo % convert with datesort | |
|
42 | hg convert --sourcesort t t-sourcesort | |
|
43 | echo % graph converted repo | |
|
44 | hg -R t-sourcesort glog --template '{rev} "{desc}"\n' | |
|
45 |
@@ -7,7 +7,40 b' created new head' | |||
|
7 | 7 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
8 | 8 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
9 | 9 | % convert with datesort |
|
10 |
initializing destination t |
|
|
10 | initializing destination t-datesort repository | |
|
11 | scanning source... | |
|
12 | sorting... | |
|
13 | converting... | |
|
14 | 8 a0 | |
|
15 | 7 a1 | |
|
16 | 6 a2 | |
|
17 | 5 a3 | |
|
18 | 4 a4 | |
|
19 | 3 b0 | |
|
20 | 2 a5 | |
|
21 | 1 a6 | |
|
22 | 0 b1 | |
|
23 | % graph converted repo | |
|
24 | o 8 "b1" | |
|
25 | | | |
|
26 | | o 7 "a6" | |
|
27 | | | | |
|
28 | | o 6 "a5" | |
|
29 | | | | |
|
30 | o | 5 "b0" | |
|
31 | | | | |
|
32 | | o 4 "a4" | |
|
33 | | | | |
|
34 | | o 3 "a3" | |
|
35 | | | | |
|
36 | | o 2 "a2" | |
|
37 | | | | |
|
38 | | o 1 "a1" | |
|
39 | |/ | |
|
40 | o 0 "a0" | |
|
41 | ||
|
42 | % convert with datesort | |
|
43 | initializing destination t-sourcesort repository | |
|
11 | 44 | scanning source... |
|
12 | 45 | sorting... |
|
13 | 46 | converting... |
@@ -210,6 +210,7 b' options:' | |||
|
210 | 210 | --splicemap splice synthesized history into place |
|
211 | 211 | --branchmap change branch names while converting |
|
212 | 212 | --datesort try to sort changesets by date |
|
213 | --sourcesort preserve source changesets order | |
|
213 | 214 | |
|
214 | 215 | use "hg -v help convert" to show global options |
|
215 | 216 | adding a |
General Comments 0
You need to be logged in to leave comments.
Login now