简体   繁体   中英

SVN to HG: Now output SVN revision number from HG changeset

I converted a Subversion repository to Mercurial, using the Convert extension. When I look at the new repository with Tortoise HG, I see in each changeset the corresponding source path and revision (see image). Tortoise HG屏幕截图,带有HG Changeset和SVN源路径/修订版

Is there a way to write those two out to the console? Ideally I'd like an output like this:

hg:1147 svn:trunk@7201
hg:1146 svn:trunk@7200
...

I know that I can use hg log with the template option to customize the output, but don't know how to get the Subversion source path/revision.

EDIT: It looks like the way I wanted to go is not possible. The svn source path/revision is in a field called extras within the changeset (thanks @Ry4en) and neither hg log nor hg export output this value. What I will try now is to use the file .hg/shamap in combination with

hg log --template 'hg:{rev} nodeid:{node}'

To map the Mercurial revision to the SVN source path/revision.

EDIT2: My Mercurial version is 1.4.3. With Mercurial 1.7.1 it's possible to use this command (thanks @ Wim Coenen): hg log --template {node}\\n{extras}\\n\\n

New versions of hgsubversion adds a {svnrev} template keyword. This is described in hg help subversion :

[...]

Finding and displaying Subversion revisions

For revealing the relationship between Mercurial changesets and Subversion revisions, hgsubversion provides three template keywords:

  svnrev Expanded to the original Subversion revision number. svnpath The path within the repository that the changeset represents. svnuuid The Universally Unique Identifier of the Subversion repository. 

An example:

  $ hg log --template='{rev}:{node|short} {author|user}\\nsvn: {svnrev}\\n' 

The template keywords are available when using Mercurial 1.5 or later.

For finding changesets from Subversion, hgsubversion extends revsets to provide two new selectors:

  fromsvn Select changesets that originate from Subversion. Takes no arguments. svnrev Select changesets that originate in a specific Subversion revision. Takes a revision argument. 

For example:

  $ hg log -r 'fromsvn()' $ hg log -r 'svnrev(500)' 

Revsets are available when using Mercurial 1.6 or later and are accepted by several Mercurial commands for specifying revisions. See "hg help revsets" for details.

It's tucked away in a field named extras on the changeset, and I don't believe there is a log template entry for it. It might show up in a hg export from which you could grep it, and it's certainly available programmatically, but I don't think there's a --template way to get it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM