# bug? Python traceback on git push

2 messages from 2012-05-30 to 2012-05-31. Participants: Pedro Werneck, Jeff King.
Thread: https://gitlist.dev/t/30665

## Pedro Werneck, 2012-05-30 22:11

Subject: bug? Python traceback on git push
Message-ID: <CA+u+8CLcUtTCkWN2bZvR8JNmgnCoX+TwRK3_e64zWaV__jOo7A@mail.gmail.com>
URL: https://gitlist.dev/e/CA%2Bu%2B8CLcUtTCkWN2bZvR8JNmgnCoX%2BTwRK3_e64zWaV__jOo7A%40mail.gmail.com

```
git 1.7.9.5

I was pushing to a repository

push actually seems to have worked, but popped this weird python traceback


(tcf-env)werneck@werneck:~/devel/tcf-api/src/tcf$ git push
Warning: Permanently added 'bitbucket.org,207.223.240.181' (RSA) to
the list of known hosts.
Counting objects: 15, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (8/8), done.
Writing objects: 100% (8/8), 860 bytes, done.
Total 8 (delta 7), reused 0 (delta 0)
remote: Traceback (most recent call last):
remote:   File "/opt/python/domains/bitbucket.org/current/bitbucket/scripts/git/hooks/pre-receive",
line 9, in <module>
remote:     from bitbucket.apps.repo2.hooks import prehooks
remote:   File "/data/vol1/www/venvs/deployed/bitbucket/apps/repo2/hooks.py",
line 4, in <module>
remote:     from orochi.hooks import failonerror, HookError, HookManager
remote:   File "/opt/python/domains/bitbucket.org/current/bitbucket/local/env/lib/python2.7/site-packages/orochi/hooks.py",
line 9, in <module>
remote:     from orochi.git import githook
remote:   File "/opt/python/domains/bitbucket.org/current/bitbucket/local/env/lib/python2.7/site-packages/orochi/git.py",
line 23, in <module>
remote:     from orochi.lock import lock
remote:   File "/opt/python/domains/bitbucket.org/current/bitbucket/local/env/lib/python2.7/site-packages/orochi/lock.py",
line 9, in <module>
remote:     from mercurial.lock import lock as mlock
remote: ImportError: No module named mercurial.lock
To git@bitbucket.org:titansgroup/tcf-api.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@bitbucket.org:titansgroup/tcf-api.git'

(tcf-env)werneck@werneck:~/devel/tcf-api/src/tcf$ git pull
Warning: Permanently added 'bitbucket.org,207.223.240.181' (RSA) to
the list of known hosts.
Already up-to-date.

(tcf-env)werneck@werneck:~/devel/tcf-api/src/tcf$ git push
Warning: Permanently added 'bitbucket.org,207.223.240.181' (RSA) to
the list of known hosts.
Counting objects: 15, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (8/8), done.
Writing objects: 100% (8/8), 860 bytes, done.
Total 8 (delta 7), reused 0 (delta 0)
remote: bb/acl: pjwerneck is allowed. accepted payload.
To git@bitbucket.org:titansgroup/tcf-api.git
   16b3b54..a50f671  master -> master


-- 
---
Pedro Werneck

```

## Jeff King, 2012-05-31 01:08

Subject: Re: bug? Python traceback on git push
Message-ID: <20120531010820.GB5488@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20120531010820.GB5488%40sigill.intra.peff.net
In-Reply-To: <CA+u+8CLcUtTCkWN2bZvR8JNmgnCoX+TwRK3_e64zWaV__jOo7A@mail.gmail.com>

```
On Wed, May 30, 2012 at 07:11:38PM -0300, Pedro Werneck wrote:

> git 1.7.9.5
> 
> I was pushing to a repository
> 
> push actually seems to have worked, but popped this weird python traceback

Not a bug in git. There is no python code at all in the push code path
(the only python in git these days is in the experimental svn
remote-helper). However, the remote side may have a hook that is written
in python...

> remote: Traceback (most recent call last):
> remote:   File "/opt/python/domains/bitbucket.org/current/bitbucket/scripts/git/hooks/pre-receive",
> line 9, in <module>
> remote:     from bitbucket.apps.repo2.hooks import prehooks
> [...]
> remote: ImportError: No module named mercurial.lock
> To git@bitbucket.org:titansgroup/tcf-api.git
>  ! [remote rejected] master -> master (pre-receive hook declined)
> error: failed to push some refs to 'git@bitbucket.org:titansgroup/tcf-api.git'

...and that is exactly what happened. Bitbucket's custom python hook
failed, and git did not allow the push to go through.

> (tcf-env)werneck@werneck:~/devel/tcf-api/src/tcf$ git pull
> Warning: Permanently added 'bitbucket.org,207.223.240.181' (RSA) to
> the list of known hosts.
> Already up-to-date.

I don't know that this shows anything conclusive; depending on your
configuration, you may or may not be pulling from the same ref you were
trying to push to a moment ago.

> (tcf-env)werneck@werneck:~/devel/tcf-api/src/tcf$ git push
> Warning: Permanently added 'bitbucket.org,207.223.240.181' (RSA) to
> the list of known hosts.
> Counting objects: 15, done.
> Delta compression using up to 4 threads.
> Compressing objects: 100% (8/8), done.
> Writing objects: 100% (8/8), 860 bytes, done.
> Total 8 (delta 7), reused 0 (delta 0)
> remote: bb/acl: pjwerneck is allowed. accepted payload.
> To git@bitbucket.org:titansgroup/tcf-api.git
>    16b3b54..a50f671  master -> master

And here you repeat the push, and you see that we had to send the data
again (because the push did not go through last time). No clue why their
hook failed the first time but not the second.

So as far as I can tell, git is operating as advertised. You might want
to file a report with bitbucket about their hook failing.

-Peff

```
