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
--- a/hgext/convert/__init__.py Thu Mar 17 22:17:27 2011 +0100
+++ b/hgext/convert/__init__.py Thu Mar 17 22:17:27 2011 +0100
@@ -10,7 +10,7 @@
import convcmd
import cvsps
import subversion
-from mercurial import commands
+from mercurial import commands, templatekw
from mercurial.i18n import _
# Commands definition was moved elsewhere to ease demandload job.
@@ -334,3 +334,31 @@
],
_('hg debugcvsps [OPTION]... [PATH]...')),
}
+
+def kwconverted(ctx, name):
+ rev = ctx.extra().get('convert_revision', '')
+ if rev.startswith('svn:'):
+ if name == 'svnrev':
+ return str(subversion.revsplit(rev)[2])
+ elif name == 'svnpath':
+ return subversion.revsplit(rev)[1]
+ elif name == 'svnuuid':
+ return subversion.revsplit(rev)[0]
+ return rev
+
+def kwsvnrev(repo, ctx, **args):
+ """:svnrev: String. Converted subversion revision number."""
+ return kwconverted(ctx, 'svnrev')
+
+def kwsvnpath(repo, ctx, **args):
+ """:svnpath: String. Converted subversion revision project path."""
+ return kwconverted(ctx, 'svnpath')
+
+def kwsvnuuid(repo, ctx, **args):
+ """:svnuuid: String. Converted subversion revision repository identifier."""
+ return kwconverted(ctx, 'svnuuid')
+
+def extsetup(ui):
+ templatekw.keywords['svnrev'] = kwsvnrev
+ templatekw.keywords['svnpath'] = kwsvnpath
+ templatekw.keywords['svnuuid'] = kwsvnuuid
--- a/tests/test-convert-svn-branches.t Thu Mar 17 22:17:27 2011 +0100
+++ b/tests/test-convert-svn-branches.t Thu Mar 17 22:17:27 2011 +0100
@@ -32,6 +32,21 @@
1 move back to old
0 last change to a
+Test template keywords
+
+ $ hg -R A-hg log --template '{rev} {svnuuid}{svnpath}@{svnrev}\n'
+ 10 644ede6c-2b81-4367-9dc8-d786514f2cde/trunk@10
+ 9 644ede6c-2b81-4367-9dc8-d786514f2cde/branches/old@9
+ 8 644ede6c-2b81-4367-9dc8-d786514f2cde/branches/old2@8
+ 7 644ede6c-2b81-4367-9dc8-d786514f2cde/branches/old@7
+ 6 644ede6c-2b81-4367-9dc8-d786514f2cde/trunk@6
+ 5 644ede6c-2b81-4367-9dc8-d786514f2cde/branches/old@6
+ 4 644ede6c-2b81-4367-9dc8-d786514f2cde/branches/old@5
+ 3 644ede6c-2b81-4367-9dc8-d786514f2cde/trunk@4
+ 2 644ede6c-2b81-4367-9dc8-d786514f2cde/branches/old@3
+ 1 644ede6c-2b81-4367-9dc8-d786514f2cde/trunk@2
+ 0 644ede6c-2b81-4367-9dc8-d786514f2cde/trunk@1
+
Convert again
$ hg convert --branchmap=branchmap --datesort svn-repo A-hg