title: Mercurial branch with blank name
body: <p>In my Mercurial repository, somehow, someone entered a blank branch name:</p>
  
  <p><a href="https://i.stack.imgur.com/1ilQo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1ilQo.png" alt="enter image description here"></a></p>
  
  <p>If i <code>hg id -r 2004</code>, I indeed get blank text.  The problem now is that this is causing issues with our Redmine installation since it's not able to sync the repository with the error:</p>
  
  <pre><code>NoMethodError (undefined method `[]' for nil:NilClass):
    lib/redmine/scm/adapters/mercurial_adapter.rb:123:in `branchmap'
    app/models/repository/mercurial.rb:150:in `latest_changesets_cond'
    app/models/repository/mercurial.rb:119:in `latest_changesets'
    app/controllers/repositories_controller.rb:94:in `show'
    lib/redmine/sudo_mode.rb:63:in `sudo_mode'
  </code></pre>
  
  <p>I've been trying to figure out how to take care of this this -- whether there's some way I can rename the branch or otherwise get rid of it.  </p>
  
  <p>I've tried switching into the branch and then <code>hg commit --close-branch</code>.  When I try to push, I get an error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "hg", line 61, in &lt;module&gt;
    File "mercurial\dispatch.pyo", line 88, in run
    File "mercurial\dispatch.pyo", line 183, in dispatch
    File "mercurial\dispatch.pyo", line 324, in _runcatch
    File "mercurial\dispatch.pyo", line 332, in _callcatch
    File "mercurial\scmutil.pyo", line 154, in callcatch
    File "mercurial\dispatch.pyo", line 314, in _runcatchfunc
    File "mercurial\dispatch.pyo", line 918, in _dispatch
    File "mercurial\dispatch.pyo", line 673, in runcommand
    File "mercurial\dispatch.pyo", line 926, in _runcommand
    File "mercurial\dispatch.pyo", line 915, in &lt;lambda&gt;
    File "mercurial\util.pyo", line 1195, in check
    File "mercurial\commands.pyo", line 4194, in push
    File "mercurial\exchange.pyo", line 483, in push
    File "mercurial\exchange.pyo", line 1069, in _pushchangeset
    File "mercurial\exchange.pyo", line 697, in _pushcheckoutgoing
    File "mercurial\discovery.pyo", line 338, in checkheads
    File "mercurial\discovery.pyo", line 248, in _headssummary
  </code></pre>
  
  <p>I tried <code>hg commit --close-branch</code> and then switching back to my working branch and pushing and it's the same result.</p>
  
  <p>If I rollback the commit, update to my active branch, make a change, and commit+push, everything works fine.  So as of right now, I'm at a loss for how to handle this rogue branch.</p>