1 from mercurial
import hg
, ui
2 from mercurial
import revlog
3 from mercurial
.node
import hex
6 return 'data %i\n%s' % (len(x
), x
)
10 if not x
in all_marks
:
11 all_marks
[x
] = len(all_marks
) + 1
12 return ':%d' % all_marks
[x
]
14 def add_mark(x
, mark
):
19 if user
.find('<') < 0:
20 user
= user
+ ' <' + user
+ '>'
24 def fast_export(path
):
26 repo
= hg
.repository(ui
.ui(), path
)
30 if '.hgtags' in ctx
.files():
31 for line
in ctx
.filectx('.hgtags').data().splitlines():
33 if tag
[1] in all_tags
and all_tags
[tag
[1]] == tag
[0]:
35 all_tags
[tag
[1]] = tag
[0]
37 print 'from', get_mark(tag
[0])
39 print 'tagger', get_user(ctx
), int(ts
), '%+i' % tz
40 print data(ctx
.description())
42 for fn
in ctx
.files():
44 fctx
= ctx
.filectx(fn
)
45 except revlog
.LookupError:
48 print 'mark', get_mark(hex(fctx
.filenode()))
49 print data(fctx
.data())
52 if not branch
.startswith('refs/heads/'):
53 branch
= 'refs/heads/' + branch
54 print 'commit', branch
55 print 'mark', get_mark(ctx
.hex())
57 print 'committer', get_user(ctx
), int(ts
), '%+i' % tz
58 print data(ctx
.description())
61 for i
, type in ((0, 'from'), (1, 'merge')):
64 if pars
[i
] != revlog
.nullid
and pars
[i
].hex() != '0000000000000000000000000000000000000000':
65 if not pars
[i
].hex() in all_marks
:
66 raise Exception('parent not seen yet')
67 print type, get_mark(pars
[i
].hex())
70 for fn
in ctx
.files():
72 fctx
= ctx
.filectx(fn
)
73 except revlog
.LookupError:
75 deletes
[fn
] = 'delete'
77 renamed
= fctx
.renamed()
79 print 'R', renamed
[0], fn
80 deletes
[fn
] = 'rename'
89 print 'M', mode
, get_mark(hex(fctx
.filenode())), fn
92 if deletes
[fn
] == 'delete':
97 if __name__
== '__main__':
99 fast_export(sys
.argv
[1])