Mercurial > hg
comparison hgext/convert/__init__.py @ 13691:ad02eba55459
convert: add svnrev, svnpath and svnuuid template keywords
$ hg -R A-hg log --template '{rev} {svnuuid}{svnpath}@{svnrev}\n'
10 644ede6c-2b81-4367-9dc8-d786514f2cde/trunk@10
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Thu, 17 Mar 2011 22:17:27 +0100 |
parents | 3178aca36b0f |
children | f30ce5983896 |
comparison
equal
deleted
inserted
replaced
13690:af331f557942 | 13691:ad02eba55459 |
---|---|
8 '''import revisions from foreign VCS repositories into Mercurial''' | 8 '''import revisions from foreign VCS repositories into Mercurial''' |
9 | 9 |
10 import convcmd | 10 import convcmd |
11 import cvsps | 11 import cvsps |
12 import subversion | 12 import subversion |
13 from mercurial import commands | 13 from mercurial import commands, templatekw |
14 from mercurial.i18n import _ | 14 from mercurial.i18n import _ |
15 | 15 |
16 # Commands definition was moved elsewhere to ease demandload job. | 16 # Commands definition was moved elsewhere to ease demandload job. |
17 | 17 |
18 def convert(ui, src, dest=None, revmapfile=None, **opts): | 18 def convert(ui, src, dest=None, revmapfile=None, **opts): |
332 # Options that are ignored for compatibility with cvsps-2.1 | 332 # Options that are ignored for compatibility with cvsps-2.1 |
333 ('A', 'cvs-direct', None, _('ignored for compatibility')), | 333 ('A', 'cvs-direct', None, _('ignored for compatibility')), |
334 ], | 334 ], |
335 _('hg debugcvsps [OPTION]... [PATH]...')), | 335 _('hg debugcvsps [OPTION]... [PATH]...')), |
336 } | 336 } |
337 | |
338 def kwconverted(ctx, name): | |
339 rev = ctx.extra().get('convert_revision', '') | |
340 if rev.startswith('svn:'): | |
341 if name == 'svnrev': | |
342 return str(subversion.revsplit(rev)[2]) | |
343 elif name == 'svnpath': | |
344 return subversion.revsplit(rev)[1] | |
345 elif name == 'svnuuid': | |
346 return subversion.revsplit(rev)[0] | |
347 return rev | |
348 | |
349 def kwsvnrev(repo, ctx, **args): | |
350 """:svnrev: String. Converted subversion revision number.""" | |
351 return kwconverted(ctx, 'svnrev') | |
352 | |
353 def kwsvnpath(repo, ctx, **args): | |
354 """:svnpath: String. Converted subversion revision project path.""" | |
355 return kwconverted(ctx, 'svnpath') | |
356 | |
357 def kwsvnuuid(repo, ctx, **args): | |
358 """:svnuuid: String. Converted subversion revision repository identifier.""" | |
359 return kwconverted(ctx, 'svnuuid') | |
360 | |
361 def extsetup(ui): | |
362 templatekw.keywords['svnrev'] = kwsvnrev | |
363 templatekw.keywords['svnpath'] = kwsvnpath | |
364 templatekw.keywords['svnuuid'] = kwsvnuuid |