In my Mercurial repository, somehow, someone entered a blank branch name:
If i hg id -r 2004
, 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:
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'
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.
I've tried switching into the branch and then hg commit --close-branch
. When I try to push, I get an error:
Traceback (most recent call last):
File "hg", line 61, in <module>
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 <lambda>
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
I tried hg commit --close-branch
and then switching back to my working branch and pushing and it's the same result.
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.
You can change a branch name in any given repository using hg convert with the --branchmap option.
In this particular case I don't know if the strange naming would cause a problem with this feature - I think you would have to try it and see.
Now, the issue with renaming branches is that if the repository has been shared (pushed / pulled / cloned) then the modified clone will get out of sync with any others. So you would have to locate every clone and run the same operation on all of them. I think that would work OK after the fact (ie they will be able to sync correctly).