hg push sometimes crashes (raises python Exception)

Create issue
Issue #259 new
Former user created an issue

I'm using hgsubversion do work with an SVN repository. Sometimes, when I push changes to the SVN repository, hg fails by raising an Exception. The traceback is appended to this issue report.

After this exception, the changeset is usually correctly commited to the SVN repository, but not correctly mapped back to my HG repository. The old changeset is still there, sometimes also the SVN clone, but without parents. I can put the repository back to a consistent state by striping the SVN clone if it is there, running 'hg svn rebuild', pulling the changeset from SVN and then rebasing my old changeset to it's new clone from SVN, which makes it actually disappear, probably since they are exactly equal.

I'm using the same HG repository both from Ubuntu 10.10 and Windows 7. It is on a NTFS volume.

The appended Traceback is from Ubuntu, after I have installed Subvertpy 0.7.5 from sources. However it looks very similar to the exception I remember from before I installed Subvertpy.

The output of 'hg version --svn' is: {{{ hgsubversion: 1.2+42-13e24740a500 Subversion: 1.6.12 bindings: Subvertpy 0.7.5 }}} This is the traceback:

{{{ pushing to svn+http://intranet/svn searching for changes [r731] ... pulled 1 revisions Already up to date! unknown exception encountered, please report by visiting http://mercurial.selenic.com/wiki/BugTracker Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56) [GCC 4.4.5] Mercurial Distributed SCM (version 1.7.3) Extensions loaded: color, graphlog, mq, hgk, rebase, hgsubversion Traceback (most recent call last): File "/usr/local/bin/hg", line 38, in <module> mercurial.dispatch.run() File "/usr/local/lib/python2.6/dist-packages/mercurial/dispatch.py", line 16, in run sys.exit(dispatch(sys.argv[1:])) File "/usr/local/lib/python2.6/dist-packages/mercurial/dispatch.py", line 36, in dispatch return _runcatch(u, args) File "/usr/local/lib/python2.6/dist-packages/mercurial/dispatch.py", line 58, in _runcatch return _dispatch(ui, args) File "/usr/local/lib/python2.6/dist-packages/mercurial/dispatch.py", line 590, in _dispatch cmdpats, cmdoptions) File "/usr/local/lib/python2.6/dist-packages/mercurial/dispatch.py", line 401, in runcommand ret = _runcommand(ui, options, cmd, d) File "/usr/local/lib/python2.6/dist-packages/mercurial/extensions.py", line 175, in wrap return wrapper(origfn, *args, kwargs) File "/usr/local/lib/python2.6/dist-packages/hgext/color.py", line 223, in colorcmd return orig(ui_, opts, cmd, cmdfunc) File "/usr/local/lib/python2.6/dist-packages/mercurial/dispatch.py", line 641, in _runcommand return checkargs() File "/usr/local/lib/python2.6/dist-packages/mercurial/dispatch.py", line 595, in checkargs return cmdfunc() File "/usr/local/lib/python2.6/dist-packages/mercurial/dispatch.py", line 588, in <lambda> d = lambda: util.checksignature(func)(ui, args, cmdoptions) File "/usr/local/lib/python2.6/dist-packages/mercurial/util.py", line 426, in check return func(*args, kwargs) File "/usr/local/lib/python2.6/dist-packages/mercurial/extensions.py", line 130, in wrap util.checksignature(origfn), args, kwargs) File "/usr/local/lib/python2.6/dist-packages/mercurial/util.py", line 426, in check return func(*args, kwargs) File "/usr/local/share/pyshared/hgext/hgsubversion/hgsubversion/wrappers.py", line 489, in generic return orig(ui, repo, args, opts) File "/usr/local/lib/python2.6/dist-packages/mercurial/util.py", line 426, in check return func(*args, kwargs) File "/usr/local/lib/python2.6/dist-packages/mercurial/extensions.py", line 130, in wrap util.checksignature(origfn), args, kwargs) File "/usr/local/lib/python2.6/dist-packages/mercurial/util.py", line 426, in check return func(*args, kwargs) File "/usr/local/lib/python2.6/dist-packages/hgext/mq.py", line 2988, in mqcommand return orig(ui, repo, args, kwargs) File "/usr/local/lib/python2.6/dist-packages/mercurial/util.py", line 426, in check return func(*args, kwargs) File "/usr/local/lib/python2.6/dist-packages/mercurial/commands.py", line 2859, in push newbranch=opts.get('new_branch')) File "/usr/local/share/pyshared/hgext/hgsubversion/hgsubversion/svnrepo.py", line 48, in wrapper return fn(self, args, **opts) File "/usr/local/share/pyshared/hgext/hgsubversion/hgsubversion/svnrepo.py", line 59, in push return wrappers.push(self, remote, force, revs) File "/usr/local/share/pyshared/hgext/hgsubversion/hgsubversion/wrappers.py", line 203, in push newtip = newtipctx.node() UnboundLocalError: local variable 'newtipctx' referenced before assignment

}}}

Comments (7)

  1. Luke Opperman

    FWIW, I also just got this traceback, commit was an uninteresting line add to one file. Probably coincidence, this occurred just after I upgraded to Mercurial-crew 1.9 / tip of hgsubversion. Also likely coincidence, this was to a branch that had erroneously been closed by an svn pull of the deletion of a different branch - should report that as a separate issue, I just stripped that erroneous close rev and after this error and "hg svn rebuild" this push went through...

    pushing to https://...
    searching for changes
    [r511] ...
    no changes found
    Already up to date!
    ** unknown exception encountered, please report by visiting
    **  http://mercurial.selenic.com/wiki/BugTracker
    ** Python 2.7.1+ (r271:86832, Apr 11 2011, 18:05:24) [GCC 4.5.2]
    ** Mercurial Distributed SCM (version 1.9+13-f96c354493d7)
    ** Extensions loaded: color, purge, record, transplant, mq, rebase, graphlog, hggit, svn, hggnome-keyring, histedit
    Traceback (most recent call last):
      File "/usr/local/bin/hg", line 38, in <module>
        mercurial.dispatch.run()
      File "/usr/local/lib/python2.7/dist-packages/mercurial/dispatch.py", line 27, in run
        sys.exit(dispatch(request(sys.argv[1:])))
      File "/usr/local/lib/python2.7/dist-packages/mercurial/dispatch.py", line 64, in dispatch
        return _runcatch(req)
      File "/usr/local/lib/python2.7/dist-packages/mercurial/dispatch.py", line 87, in _runcatch
        return _dispatch(req)
      File "/usr/local/lib/python2.7/dist-packages/mercurial/dispatch.py", line 675, in _dispatch
        cmdpats, cmdoptions)
      File "/usr/local/lib/python2.7/dist-packages/mercurial/dispatch.py", line 454, in runcommand
        ret = _runcommand(ui, options, cmd, d)
      File "/usr/local/lib/python2.7/dist-packages/mercurial/extensions.py", line 182, in wrap
        return wrapper(origfn, *args, **kwargs)
      File "/usr/local/lib/python2.7/dist-packages/hgext/color.py", line 367, in colorcmd
        return orig(ui_, opts, cmd, cmdfunc)
      File "/usr/local/lib/python2.7/dist-packages/mercurial/dispatch.py", line 729, in _runcommand
        return checkargs()
      File "/usr/local/lib/python2.7/dist-packages/mercurial/dispatch.py", line 683, in checkargs
        return cmdfunc()
      File "/usr/local/lib/python2.7/dist-packages/mercurial/dispatch.py", line 672, in <lambda>
        d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
      File "/usr/local/lib/python2.7/dist-packages/mercurial/util.py", line 385, in check
        return func(*args, **kwargs)
      File "/usr/local/lib/python2.7/dist-packages/mercurial/extensions.py", line 137, in wrap
        util.checksignature(origfn), *args, **kwargs)
      File "/usr/local/lib/python2.7/dist-packages/mercurial/util.py", line 385, in check
        return func(*args, **kwargs)
      File "/home/luke/lib/hgsubversion/hgsubversion/wrappers.py", line 524, in generic
        return orig(ui, repo, *args, **opts)
      File "/usr/local/lib/python2.7/dist-packages/mercurial/util.py", line 385, in check
        return func(*args, **kwargs)
      File "/usr/local/lib/python2.7/dist-packages/mercurial/extensions.py", line 137, in wrap
        util.checksignature(origfn), *args, **kwargs)
      File "/usr/local/lib/python2.7/dist-packages/mercurial/util.py", line 385, in check
        return func(*args, **kwargs)
      File "/usr/local/lib/python2.7/dist-packages/hgext/mq.py", line 3218, in mqcommand
        return orig(ui, repo, *args, **kwargs)
      File "/usr/local/lib/python2.7/dist-packages/mercurial/util.py", line 385, in check
        return func(*args, **kwargs)
      File "/usr/local/lib/python2.7/dist-packages/mercurial/commands.py", line 3884, in push
        newbranch=opts.get('new_branch'))
      File "/home/luke/lib/hgsubversion/hgsubversion/svnrepo.py", line 48, in wrapper
        return fn(self, *args, **opts)
      File "/home/luke/lib/hgsubversion/hgsubversion/svnrepo.py", line 59, in push
        return wrappers.push(self, remote, force, revs)
      File "/home/luke/lib/hgsubversion/hgsubversion/wrappers.py", line 225, in push
        newtip = newtipctx.node()
    UnboundLocalError: local variable 'newtipctx' referenced before assignment
    
    $ hg version --svn
    hgsubversion: f28e0f54a6ef
    Subversion: 1.6.12
    bindings: SWIG
    
  2. Augie Fackler repo owner

    Hm, frustrating. I'll have to look through the relevant codepaths and try to figure this out. Any idea on steps to reproduce?

  3. Luke Opperman

    I got it again, again with the first push to a branch that had been incorrectly closed. Let me describe that bug, although I've just spent some time trying to reproduce it locally to no success.

    SVN user deletes a branch.
    Pull correctly marks that branch as closed.
      but also creates additional revisions closing all other branches *that start with the branch name*
      eg, close "redesign", also creates hg-only revs that close "redesign-feeds" (branched from "redesign")
        and "redesign-2" (branched from trunk).
    Can't push a change in the incorrectly closed branch (the erroneous closing revision "had no changes in svn")
    Strip the incorrect closed revision.
    Push gets this error.
    Rebuild.
    Pull, get the pushed but errored-out revision.
    Ok.
    

    There's something more to the branch-closing bug because I haven't been able to reproduce just by name overlap.

  4. Former user Account Deleted

    Is `.hgsvnexternals` involved? I'm encountering this problem with that feature since hgsubversion doesn't appear to check it into SVN which causes problems.

  5. Former user Account Deleted

    I've got the same problem while trying to push just committed .hgsvnexternals and .hgignore files back to a SVN repository. The commit was done to SVN but included only .hgignore and not .hgsvnexternals. After the commit still appeared when calling "hg outgoing" and another "hg push" failed with this exception. "hg svn rebuild" didn't solve the issue for me. I had to use "hg strip" from the "mq" extension to remove the bad commit, commit the .hgsvnexternals file manually to the SVN repository and run "hg pull" again to retrive back the .hgsvnexternals file.

  6. Leonardo Postacchini

    We just had the same problem and found out at least one way to reproduce it.

    We have a subversion server and a mercurial server that works as central repository, we have people working in both hg and svn so we must keep them always in sync, in order to do that, there is a hook in svn which does a ssh login in the mercurial repository and commands a pull from hg, there is also a hook in hg that send changesets which are pushed into the repository over to subversion.

    What happens is: hg push a changeset(ctx:1) to svn, svn run the hook and cause the pull which makes the changeset(ctx:2, ouside hgsubversion) to be pulled into mercurial on a parallel process, this new changeset is not visible when:

    1. 3. Fetch revisions from svn
    2. TODO: this probably should pass in the source explicitly - rev too? r = repo.pull(dest, force=force) assert not r or r == 0
    1. 4. Find the new head of the target branch
    2. We expect to get our own new commit back, but we might also get other
    3. commits that happened since our last pull, or even right after our own
    4. commit (race). for c in oldtipctx.descendants(): if c.node() not in seen and c.branch() == svnbranch: newtipctx = c

    so no newtipctx is found.

  7. Log in to comment