KeyError during 'hg clone'

Issue #423 resolved
robi_wan
created an issue

I want to try to use mercurial for our subversion repository. I tried to clone it with 'hg clone <IP of subversion repository>'

It starts the process but fails after some time:

[r18350] <author>: Renamed 'dead' folder to 'closed'.
Marked branch dead/async-db as closed.
Marked branch dead/september-feldtest as closed.
Marked branch dead/parameter-dependencies as closed.
Marked branch dead/configuration as closed.
Marked branch dead/november-release as closed.
[r18351] <author>: 'tags/releases' created.
[r18352] <author>: Moved 'prototype-iffa-2013' to 'tags/releases'.
.hgtags
[r18353] <author>: Moved 'september-feldtest' to 'tags/releases'.
.hgtags
[r18354] <author>: Moved 'branches/closed' to 'tags/closed'.
** Unknown exception encountered with possibly-broken third-party extension hgsubversion
** which supports versions unknown of Mercurial.
** Please disable hgsubversion and try your action again.
** If that fixes the bug please report it to the extension author.
** Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)]
** Mercurial Distributed SCM (version 3.0.1)
** Extensions loaded: hgsubversion
Traceback (most recent call last):
  File "hg", line 42, in <module>
  File "mercurial\dispatch.pyo", line 28, in run
  File "mercurial\dispatch.pyo", line 69, in dispatch
  File "mercurial\dispatch.pyo", line 138, in _runcatch
  File "mercurial\dispatch.pyo", line 819, in _dispatch
  File "mercurial\dispatch.pyo", line 599, in runcommand
  File "mercurial\dispatch.pyo", line 910, in _runcommand
  File "mercurial\dispatch.pyo", line 881, in checkargs
  File "mercurial\dispatch.pyo", line 816, in <lambda>
  File "mercurial\util.pyo", line 518, in check
  File "mercurial\extensions.pyo", line 151, in wrap
  File "mercurial\util.pyo", line 518, in check
  File "C:/Documents and Settings/Administrator/hgsubversion\hgsubversion\wrappers.py", line 603, in clone
    orig(ui, source, dest, **opts)
  File "mercurial\util.pyo", line 518, in check
  File "mercurial\commands.pyo", line 1299, in clone
  File "mercurial\extensions.pyo", line 196, in wrap
  File "C:/Documents and Settings/Administrator/hgsubversion\hgsubversion\wrappers.py", line 592, in hgclonewrapper
    data['srcrepo'], data['dstrepo'] = orig(ui, *args, **opts)
  File "mercurial\hg.pyo", line 400, in clone
  File "mercurial\localrepo.pyo", line 1860, in clone
  File "C:/Documents and Settings/Administrator/hgsubversion\hgsubversion\svnrepo.py", line 77, in wrapper
    return fn(self, *args, **opts)
  File "C:/Documents and Settings/Administrator/hgsubversion\hgsubversion\svnrepo.py", line 105, in pull
    return wrappers.pull(self, remote, heads, force)
  File "C:/Documents and Settings/Administrator/hgsubversion\hgsubversion\wrappers.py", line 454, in pull
    meta.committags(r, close)
  File "C:/Documents and Settings/Administrator/hgsubversion\hgsubversion\svnmeta.py", line 728, in committags
    self.get_parent_svn_branch_and_rev(r, b)])
KeyError: (None, None)

The exception occurs during the processing of revision 18354 but I think the cause is revision 18350:

r18354 | <author> | 2013-09-30 10:04:21 +0200 (Mo, 30 Sep 2013) | 1 line
Changed paths:
   D /avatar/branches/closed
   A /avatar/tags/closed (from /avatar/branches/closed:18353)

Moved 'branches/closed' to 'tags/closed'.
r18350 | <author> | 2013-09-30 10:01:27 +0200 (Mo, 30 Sep 2013) | 1 line
Changed paths:
   A /avatar/branches/closed (from /avatar/branches/dead:18349)
   D /avatar/branches/dead

Renamed 'dead' folder to 'closed'.

/avatar/branches/dead was the parent folder for several other branches - this parent folder was renamed (revision 18350) and moved to /avatar/tags (revision 18354).

I created a little sample repository for reproducing the exception. The attachment contains the zipped repository folder and a repository dump file.

The workflow we used: We created a branch 'async-db' under 'branches' folder. When we merged the changes from this branch back to trunk we did not need the branch any longer: We moved the branch 'async-db' to the folder /branches/dead. Later we changed the name of this folder from "branches/dead" to "branches/closed" and moved this folder to tags (this created a folder /tags/closed).

C:\tmp\hg2>hg clone <sample repository>
destination directory: avatar
using standard layout
[r1] VisualSVN Server: Create project 'avatar'
[r2] ntrs: add important file a.txt
A avatar/trunk/a.txt
a.txt
 committed to "default" as 1b1ee587378e
[r3] ntrs: Create branch async-db
 committed to "async-db" as 384a2122b41b
[r4] ntrs: Async functionality
A avatar/branches/async-db/b.txt
b.txt
 committed to "async-db" as 341dc18bde77
[r5] ntrs: Merged revision(s) 3-4 from avatar/branches/async-db:
A+ avatar/trunk/b.txt
b.txt
 committed to "default" as 7bf3b8bf4950
[r6] ntrs: Create branch folder for unnecessary branches
[r7] ntrs: We don't need the 'async-db' branch, anymore.
 committed to "dead/async-db" as c6bdf68b2755
Marked branch async-db as closed.
[r8] ntrs: Renamed 'dead' folder to 'closed'.
Marked branch dead/async-db as closed.
[r9] ntrs: Moved 'branches/closed' to 'tags/closed'.
** Unknown exception encountered with possibly-broken third-party extension hgsubversion
** which supports versions unknown of Mercurial.
** Please disable hgsubversion and try your action again.
** If that fixes the bug please report it to the extension author.
** Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)]
** Mercurial Distributed SCM (version 3.0.1)
** Extensions loaded: hgsubversion, color
Traceback (most recent call last):
  File "hg", line 42, in <module>
  File "mercurial\dispatch.pyo", line 28, in run
  File "mercurial\dispatch.pyo", line 69, in dispatch
  File "mercurial\dispatch.pyo", line 138, in _runcatch
  File "mercurial\dispatch.pyo", line 819, in _dispatch
  File "mercurial\dispatch.pyo", line 599, in runcommand
  File "mercurial\extensions.pyo", line 196, in wrap
  File "hgext\color.pyo", line 431, in colorcmd
  File "mercurial\dispatch.pyo", line 910, in _runcommand
  File "mercurial\dispatch.pyo", line 881, in checkargs
  File "mercurial\dispatch.pyo", line 816, in <lambda>
  File "mercurial\util.pyo", line 518, in check
  File "mercurial\extensions.pyo", line 151, in wrap
  File "mercurial\util.pyo", line 518, in check
  File "C:/Documents and Settings/Administrator/hgsubversion\hgsubversion\wrappers.py", line 603, in clone
    orig(ui, source, dest, **opts)
  File "mercurial\util.pyo", line 518, in check
  File "mercurial\commands.pyo", line 1299, in clone
  File "mercurial\extensions.pyo", line 196, in wrap
  File "C:/Documents and Settings/Administrator/hgsubversion\hgsubversion\wrappers.py", line 592, in hgclonewrapper
    data['srcrepo'], data['dstrepo'] = orig(ui, *args, **opts)
  File "mercurial\hg.pyo", line 400, in clone
  File "mercurial\localrepo.pyo", line 1860, in clone
  File "C:/Documents and Settings/Administrator/hgsubversion\hgsubversion\svnrepo.py", line 77, in wrapper
    return fn(self, *args, **opts)
  File "C:/Documents and Settings/Administrator/hgsubversion\hgsubversion\svnrepo.py", line 105, in pull
    return wrappers.pull(self, remote, heads, force)
  File "C:/Documents and Settings/Administrator/hgsubversion\hgsubversion\wrappers.py", line 454, in pull
    meta.committags(r, close)
  File "C:/Documents and Settings/Administrator/hgsubversion\hgsubversion\svnmeta.py", line 728, in committags
    self.get_parent_svn_branch_and_rev(r, b)])
KeyError: (None, None)

We are investigating a switch to mercurial - but we want to keep our project history. So this failing import is kind of a showstopper for us.

Or is there an alternative approach for trying out mercurial for an existing subversion repository?

I used the current tip of hgsubversion: 1196 (878372849175) maps: use meta.caseignoreauthors intead of accessing ui directly Sean Farley sean.michael.farley@gmail.com 2014-03-24 11:20:46 -0500 (2 months)

Comments (5)

  1. Augie Fackler repo owner

    Can you look at tests/fixtures/*.sh and try to build a similar script that would build a sample repository that's like yours? That would be helpful for us, as then we'd probably have a small sample repo that we can experiment on.

    Thanks!

  2. robi_wan reporter

    intermediate_ordering_branch.sh

    #!/bin/sh
    #
    # Generate intermediate_ordering_branch.svndump
    #
    
    mkdir temp
    cd temp
    
    mkdir project
    cd project
    mkdir trunk
    mkdir branches
    mkdir tags
    cd ..
    
    svnadmin create testrepo
    CURRENT_DIR=`pwd`
    svnurl=file://"$CURRENT_DIR"/testrepo
    #svn import project-orig $svnurl -m "init project"
    
    svn co $svnurl project
    cd project
    svn add *
    svn ci -m "init project"
    
    cd trunk
    echo a > a.txt
    svn add a.txt
    svn ci -m "add a.txt in trunk"
    
    # Create a branch
    svn up
    cd ../branches
    svn copy ../trunk async-db
    svn ci -m "add branch async-db"
    svn up
    
    # Implement feature
    cd async-db
    echo b > b.txt
    svn add b.txt
    svn ci -m "Async functionality"
    
    # Merge feature branch
    cd ../../trunk
    svn merge $svnurl/branches/async-db
    svn ci -m "Merged branch async-db"
    cd ..
    svn up
    
    # Create branch folder for unnecessary branches
    svn mkdir $svnurl/branches/dead -m "Create branch folder for unnecessary branches"
    svn up
    
    #  We don't need the 'async-db' branch, anymore.
    svn copy $svnurl/branches/async-db $svnurl/branches/dead -m "We don't need the 'async-db' branch, anymore."
    svn up
    
    # Rename 'dead' folder to 'closed'
    svn move $svnurl/branches/dead $svnurl/branches/closed -m "Renamed 'dead' folder to 'closed'"
    svn up
    
    # Move 'branches/closed' to 'tags/closed'
    svn move $svnurl/branches/closed $svnurl/tags/closed -m "Moved 'branches/closed' to 'tags/closed'."
    svn up
    
    # Dump repository
    cd ..
    svnadmin dump testrepo > ../intermediate_ordering_branch.svndump
    

    Is this sufficient or shall I create a pull request?

    This script is tested under cygwin under Windows Server 2003 R2 Standard Edition SP2 - and it generates an identical stacktrace when running 'hg clone':

    C:\development\work\hgsubversion\tests\fixtures\temp\hg_clone>hg clone <testrepo>
    destination directory: testrepo
    using standard layout
    [r1] Administrator: init project
    [r2] Administrator: add a.txt in trunk
    A trunk/a.txt
    a.txt
     committed to "default" as 02b4a5f1282c
    [r3] Administrator: add branch async-db
     committed to "async-db" as 406219937f19
    [r4] Administrator: Async functionality
    A branches/async-db/b.txt
    b.txt
     committed to "async-db" as 20d4329f630b
    [r5] Administrator: Merged branch async-db
    A+ trunk/b.txt
    b.txt
     committed to "default" as 6d5a00e267da
    [r6] Administrator: Create branch folder for unnecessary branches
    [r7] Administrator: We don't need the 'async-db' branch, anymore.
     committed to "dead/async-db" as 0b5abdf5e6e3
    [r8] Administrator: Renamed 'dead' folder to 'closed'
    Marked branch dead/async-db as closed.
    [r9] Administrator: Moved 'branches/closed' to 'tags/closed'.
    ** Unknown exception encountered with possibly-broken third-party extension hgsubversion
    ** which supports versions unknown of Mercurial.
    ** Please disable hgsubversion and try your action again.
    ** If that fixes the bug please report it to the extension author.
    ** Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)]
    ** Mercurial Distributed SCM (version 3.0.1)
    ** Extensions loaded: hgsubversion, color
    Traceback (most recent call last):
      File "hg", line 42, in <module>
      File "mercurial\dispatch.pyo", line 28, in run
      File "mercurial\dispatch.pyo", line 69, in dispatch
      File "mercurial\dispatch.pyo", line 138, in _runcatch
      File "mercurial\dispatch.pyo", line 819, in _dispatch
      File "mercurial\dispatch.pyo", line 599, in runcommand
      File "mercurial\extensions.pyo", line 196, in wrap
      File "hgext\color.pyo", line 431, in colorcmd
      File "mercurial\dispatch.pyo", line 910, in _runcommand
      File "mercurial\dispatch.pyo", line 881, in checkargs
      File "mercurial\dispatch.pyo", line 816, in <lambda>
      File "mercurial\util.pyo", line 518, in check
      File "mercurial\extensions.pyo", line 151, in wrap
      File "mercurial\util.pyo", line 518, in check
      File "C:/Documents and Settings/Administrator/hgsubversion\hgsubversion\wrappers.py", line 603, in clone
        orig(ui, source, dest, **opts)
      File "mercurial\util.pyo", line 518, in check
      File "mercurial\commands.pyo", line 1299, in clone
      File "mercurial\extensions.pyo", line 196, in wrap
      File "C:/Documents and Settings/Administrator/hgsubversion\hgsubversion\wrappers.py", line 592, in hgclonewrapper
        data['srcrepo'], data['dstrepo'] = orig(ui, *args, **opts)
      File "mercurial\hg.pyo", line 400, in clone
      File "mercurial\localrepo.pyo", line 1860, in clone
      File "C:/Documents and Settings/Administrator/hgsubversion\hgsubversion\svnrepo.py", line 77, in wrapper
        return fn(self, *args, **opts)
      File "C:/Documents and Settings/Administrator/hgsubversion\hgsubversion\svnrepo.py", line 105, in pull
        return wrappers.pull(self, remote, heads, force)
      File "C:/Documents and Settings/Administrator/hgsubversion\hgsubversion\wrappers.py", line 454, in pull
        meta.committags(r, close)
      File "C:/Documents and Settings/Administrator/hgsubversion\hgsubversion\svnmeta.py", line 728, in committags
        self.get_parent_svn_branch_and_rev(r, b)])
    KeyError: (None, None)
    
  3. Augie Fackler repo owner

    Great news! This appears to be fixed. I have no idea when in the last year and a half we did so, but I'm able to convert your test fixture successfully.

  4. Log in to comment