1

I have a main mercurial repo and a remote clone repo. After the initial clone I added a pretxnchangegroup hook function to the main repo. The hook function uses os.environ["REMOTE_USER"] to retrieve the authenticated user. The hook function works as expected when I do a hg push from a remote repo which was cloned earlier. The problem arises when I try to a new clone. I get the following error

File "/usr/lib/pymodules/python2.6/mercurial/localrepo.py", line 2048, in addchangegroup
  url=url, pending=p)
File "/usr/lib/pymodules/python2.6/mercurial/localrepo.py", line 145, in hook
  return hook.hook(self.ui, self, name, throw, **args)
File "/usr/lib/pymodules/python2.6/mercurial/hook.py", line 139, in hook
  r = _pythonhook(ui, repo, name, hname, hookfn, args, throw) or r
File "/usr/lib/pymodules/python2.6/mercurial/hook.py", line 68, in _pythonhook
  r = obj(ui=ui, repo=repo, hooktype=name, **args)
File "/usr/lib/python2.6/pushvalidation.py", line 18, in chkaccess
  username = os.environ["REMOTE_USER"]
File "/usr/lib/python2.6/UserDict.py", line 22, in __getitem__
  raise KeyError(key)
KeyError: 'REMOTE_USER'

pushvalidation.py is the in-process pretxnchangegroup hook placed in global hgrc of the main repo.

I have a just started using Mercurial and this is the first big hook function that I have written.

Martin Geisler
  • 72,968
  • 25
  • 171
  • 229
Asha
  • 11
  • 1
  • You need better explain how many servers/repo you have and where hook is used. Because for now just seems you do not set REMOTE_USER in second cloned repo. – Zada Zorg Apr 28 '11 at 08:48
  • There is one server with my main repo and the hook is placed in the global hgrc of that main repo. Different mains connect to this server to get a clone of the main repo. – Asha Apr 28 '11 at 14:53

0 Answers0