Uploaded image for project: 'Bitbucket Cloud'
  1. Bitbucket Cloud
  2. BCLOUD-8263

http 400: bad request error when pulling from mercurial repo

      The repository in question is http://bitbucket.org/osrf/gazebo

      I can hg clone, diff, out, but I can't hg pull. Every time I get a HTTP 400 Error.

      If I switch to ssh instead of https, the problem goes away.

            [BCLOUD-8263] http 400: bad request error when pulling from mercurial repo

            We use Magnus Akselvoll's script from https://github.com/magnusakselvoll/hg-http-400 to fix this problem.

            Any feedback from Atlassian on their ability to add an option to change the close branch order of events?

            michaeldaly added a comment - We use Magnus Akselvoll's script from https://github.com/magnusakselvoll/hg-http-400 to fix this problem. Any feedback from Atlassian on their ability to add an option to change the close branch order of events?

            We fixed ours by creating a dangling_heads and executing the following bash script:

            for b in `hg log -r "heads(all()) - ( head() and not closed() )" --template "{branch}\n"`
            do
                hg merge $b --tool internal:local
                hg commit -m "Automated dummy merge"
            done
            

            We had about a thousand closed branches that were not merged after the close commit, bringing this number down to 600 fixed the issue for us.

            Run the {{hg log -r "heads(all()) - ( head() and not closed() )" --template "

            {branch}

            \n" | wc -l}} command to get the number of heads.

            Francois Lachance-Guillemette added a comment - We fixed ours by creating a dangling_heads and executing the following bash script: for b in `hg log -r "heads(all()) - ( head() and not closed() )" --template "{branch}\n" ` do hg merge $b --tool internal:local hg commit -m "Automated dummy merge" done We had about a thousand closed branches that were not merged after the close commit, bringing this number down to 600 fixed the issue for us. Run the {{hg log -r "heads(all()) - ( head() and not closed() )" --template " {branch} \n" | wc -l}} command to get the number of heads.

            magnusak added a comment -

            I have written an short article and given scripts to fix this using Powershell here: BCLOUD-8263

            magnusak added a comment - I have written an short article and given scripts to fix this using Powershell here: BCLOUD-8263

            This is recurring again on osrf/gazebo even though we have less than half as many heads as when this first started happening (about 355 now, compared to over 800 before).

            Steven Peters added a comment - This is recurring again on osrf/gazebo even though we have less than half as many heads as when this first started happening (about 355 now, compared to over 800 before).

            I just did another round of fixing this for osrf/gazebo. I used the following script to identify closed topological heads, and it's faster than the script I posted before:

            hg log -r "heads(0:tip) and closed()"
            

            Note that "closed topological heads" are closed branches that haven't been merged into anything. On osrf/gazebo, I made a branch called dangling_heads and merged all the closed topological heads into that branch, which helps with this mercurial issue.

            Steven Peters added a comment - I just did another round of fixing this for osrf/gazebo. I used the following script to identify closed topological heads, and it's faster than the script I posted before: hg log -r "heads(0:tip) and closed()" Note that "closed topological heads" are closed branches that haven't been merged into anything. On osrf/gazebo, I made a branch called dangling_heads and merged all the closed topological heads into that branch, which helps with this mercurial issue.

            I recently encountered this issue myself and ended up getting to the root of the problem. Blog post about it here for those interested: http://demianbrecht.github.io/mercurial/2014/12/11/debugging-mercurial-400/.

            To fix the problem, all that should need to be done is to have the max allowed header size increased on the web server. The header size is not unbounded as the requests issued for tree comparison are set to have 200.

            demianbrecht added a comment - I recently encountered this issue myself and ended up getting to the root of the problem. Blog post about it here for those interested: http://demianbrecht.github.io/mercurial/2014/12/11/debugging-mercurial-400/ . To fix the problem, all that should need to be done is to have the max allowed header size increased on the web server. The header size is not unbounded as the requests issued for tree comparison are set to have 200.

            @npetchimuthu You don't have to merge all the heads into default. Presumably some of these topological heads are closed branches that were already merged into other branches. If so, then you can create a new branch called dangling_heads and merge all the closed heads to that branch.

            I've done this for one of our repositories, so I can advise on the specifics. To get a list of closed topological heads, you can use the following:

            for b in `hg heads -tc | grep '^branch:' | sed -e 's@^branch: *@@'`
            do
                hg log -r "branch($b) and closed()"
            done
            

            We had a lot of these.

            UPDATE: this script is extremely slow.

            Steven Peters added a comment - @npetchimuthu You don't have to merge all the heads into default. Presumably some of these topological heads are closed branches that were already merged into other branches. If so, then you can create a new branch called dangling_heads and merge all the closed heads to that branch. I've done this for one of our repositories, so I can advise on the specifics. To get a list of closed topological heads, you can use the following: for b in `hg heads -tc | grep '^branch:' | sed -e 's@^branch: *@@'` do hg log -r "branch($b) and closed()" done We had a lot of these. UPDATE: this script is extremely slow.

            @jonmooring

            I have the same issue.

            Mercurial version : 2.7
            topological heads : 3237

            FYI: I can't able to merge these heads into default. Because each head is used for different set of peoples.

            But the same repository is working fine when using SSH mode.

            Thanks,
            Muthu.

            Legacy Bitbucket Cloud User (Inactive) added a comment - @jonmooring I have the same issue. Mercurial version : 2.7 topological heads : 3237 FYI: I can't able to merge these heads into default. Because each head is used for different set of peoples. But the same repository is working fine when using SSH mode. Thanks, Muthu.

            bfcosta added a comment -

            jonmorring, can this ticked be reopened ? I have a repo with just few heads (six) and still get this problem. No proxy configuration and mercurial client is tortoisehg version 2.4.2. If I import this copy to linux and run hg pull with version 1.8.4 I don't get the problem.

            bfcosta added a comment - jonmorring, can this ticked be reopened ? I have a repo with just few heads (six) and still get this problem. No proxy configuration and mercurial client is tortoisehg version 2.4.2. If I import this copy to linux and run hg pull with version 1.8.4 I don't get the problem.

            bfcosta added a comment -

            Well, using ssh is not an option in my case but I can try merging closed heads together.

            bfcosta added a comment - Well, using ssh is not an option in my case but I can try merging closed heads together.

              jmooring moo (Inactive)
              a78d5c3607fb Nathan Koenig
              Affected customers:
              3 This affects my team
              Watchers:
              7 Start watching this issue

                Created:
                Updated:
                Resolved: