Show More
@@ -247,7 +247,8 b' cmdtable = {' | |||||
247 | ('s', 'source-type', '', _('source repository type')), |
|
247 | ('s', 'source-type', '', _('source repository type')), | |
248 | ('', 'splicemap', '', _('splice synthesized history into place')), |
|
248 | ('', 'splicemap', '', _('splice synthesized history into place')), | |
249 | ('', 'branchmap', '', _('change branch names while converting')), |
|
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 | _('hg convert [OPTION]... SOURCE [DEST [REVMAP]]')), |
|
252 | _('hg convert [OPTION]... SOURCE [DEST [REVMAP]]')), | |
252 | "debugsvnlog": |
|
253 | "debugsvnlog": | |
253 | (debugsvnlog, |
|
254 | (debugsvnlog, |
@@ -38,7 +38,7 b" SKIPREV = 'SKIP'" | |||||
38 |
|
38 | |||
39 | class commit(object): |
|
39 | class commit(object): | |
40 | def __init__(self, author, date, desc, parents, branch=None, rev=None, |
|
40 | def __init__(self, author, date, desc, parents, branch=None, rev=None, | |
41 | extra={}): |
|
41 | extra={}, sortkey=None): | |
42 | self.author = author or 'unknown' |
|
42 | self.author = author or 'unknown' | |
43 | self.date = date or '0 0' |
|
43 | self.date = date or '0 0' | |
44 | self.desc = desc |
|
44 | self.desc = desc | |
@@ -46,6 +46,7 b' class commit(object):' | |||||
46 | self.branch = branch |
|
46 | self.branch = branch | |
47 | self.rev = rev |
|
47 | self.rev = rev | |
48 | self.extra = extra |
|
48 | self.extra = extra | |
|
49 | self.sortkey = sortkey | |||
49 |
|
50 | |||
50 | class converter_source(object): |
|
51 | class converter_source(object): | |
51 | """Conversion source interface""" |
|
52 | """Conversion source interface""" |
@@ -169,6 +169,13 b' class converter(object):' | |||||
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 = {} | |
@@ -186,6 +193,8 b' class converter(object):' | |||||
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 | |||
@@ -362,9 +371,11 b' def convert(ui, src, dest=None, revmapfi' | |||||
362 | shutil.rmtree(path, True) |
|
371 | shutil.rmtree(path, True) | |
363 | raise |
|
372 | raise | |
364 |
|
373 | |||
365 |
sortmode = ' |
|
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: |
@@ -302,7 +302,8 b' class mercurial_source(converter_source)' | |||||
302 | crev = None |
|
302 | crev = None | |
303 | return commit(author=ctx.user(), date=util.datestr(ctx.date()), |
|
303 | return commit(author=ctx.user(), date=util.datestr(ctx.date()), | |
304 | desc=ctx.description(), rev=crev, parents=parents, |
|
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 | def gettags(self): |
|
308 | def gettags(self): | |
308 | tags = [t for t in self.repo.tagslist() if t[0] != 'tip'] |
|
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 | hg up -C 0 |
|
20 | hg up -C 0 | |
21 | hg branch branchb |
|
21 | hg branch branchb | |
22 | echo b >> b |
|
22 | echo b >> b | |
23 |
hg ci -Am b0 -d ' |
|
23 | hg ci -Am b0 -d '6 0' | |
24 | hg up -C brancha |
|
24 | hg up -C brancha | |
25 | echo a >> a |
|
25 | echo a >> a | |
26 |
hg ci -m a4 -d ' |
|
26 | hg ci -m a4 -d '5 0' | |
27 | echo a >> a |
|
27 | echo a >> a | |
28 | hg ci -m a5 -d '7 0' |
|
28 | hg ci -m a5 -d '7 0' | |
29 | echo a >> a |
|
29 | echo a >> a | |
@@ -34,7 +34,12 b" hg ci -m b1 -d '9 0'" | |||||
34 | cd .. |
|
34 | cd .. | |
35 |
|
35 | |||
36 | echo % convert with datesort |
|
36 | echo % convert with datesort | |
37 |
hg convert --datesort t t |
|
37 | hg convert --datesort t t-datesort | |
38 | echo % graph converted repo |
|
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 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
7 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
8 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
8 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
9 | % convert with datesort |
|
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 | scanning source... |
|
44 | scanning source... | |
12 | sorting... |
|
45 | sorting... | |
13 | converting... |
|
46 | converting... |
@@ -210,6 +210,7 b' options:' | |||||
210 | --splicemap splice synthesized history into place |
|
210 | --splicemap splice synthesized history into place | |
211 | --branchmap change branch names while converting |
|
211 | --branchmap change branch names while converting | |
212 | --datesort try to sort changesets by date |
|
212 | --datesort try to sort changesets by date | |
|
213 | --sourcesort preserve source changesets order | |||
213 |
|
214 | |||
214 | use "hg -v help convert" to show global options |
|
215 | use "hg -v help convert" to show global options | |
215 | adding a |
|
216 | adding a |
General Comments 0
You need to be logged in to leave comments.
Login now