Hudson - Can't Poll Mercurial - mercurial

I have Hudson 2.1.2 (not Jenkins) and I've set my projects up to poll my Mercurial repository hourly to check for changes. I generated a public key for my hudson user and added it to the authorized keys on my Mercurial server. When doing the hourly poll, sometimes some projects can't poll Mercurial. Here's an example of what I see in the Mercurial Polling Log:
Started on Apr 30, 2012 2:00:30 PM
[workspace] $ /usr/bin/hg incoming --style /opt/home/hudson/jobs/MyProject/workspace/tmp7506244240405638202style --no-merges --rev default --newest-first
remote: ssh_exchange_identification: Connection closed by remote host
abort: no suitable response from remote hg!
Done. Took 5.3 sec
No changes
However, if I click on "Build Now", it sucessfully polls, picks up changes and builds.
Started by user sdoca
Cleaning the workspace because project is configured to clean the workspace before each build.
$ /usr/bin/hg clone --rev default ssh://hudson#my.mercurial.server:22//opt/hg/current/MyProject /opt/home/hudson/jobs/MyProject/workspace
requesting all changes
adding changesets
adding manifests
adding file changes
added 31 changesets with 40 changes to 11 files
updating working directory
5 files updated, 0 files merged, 0 files removed, 0 files unresolved
[workspace] $ /usr/bin/hg log --rev . --template {node}
[INFO] Using bundled Maven 3 installation
[INFO] Checking Maven 3 installation environment
...
<snip>
Any ideas why I get an error on the auto poll?

Related

"abort: no suitable response from remote hg!"

I've just created a new Mercurial repo on my private server, but I can't push to it, and I can't figure out why.
Here's what I see:
% hg push
pushing to ssh://hg#mydomain.com//var/repos/myrepo
abort: no suitable response from remote hg!
On the server, the repo exists, and I can clone it locally:
root#mydomain:/tmp# hg clone /var/repos/myrepo repoclone
updating to branch default
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
I created the repo with hg init myrepo. It's owned by hg:hg, mod 755.
My workstation and server are both running
Mercurial Distributed SCM (version 4.4.1)
What else might be wrong?
Discovered you can add --debug to hg push.
% hg --debug push
pushing to ssh://hg#mydomain.com//var/repos/myrepo
running ssh 'hg#mydomain.com' 'hg -R /var/repos/myrepo serve --stdio'
sending hello command
sending between command
remote: This account is currently not available.
abort: no suitable response from remote hg!
I guess the server user must have a shell.
nano /etc/passwd
Changed
hg:x:999:1002:Mercurial repo owner:/home/hg:/usr/sbin/nologin
to
hg:x:999:1002:Mercurial repo owner:/home/hg:/bin/bash
And now it pushes!

Automatically trigger Hg repository verification before pushing/pulling, without programming

We discovered that our Hg repository got corrupted several weeks ago. This corruption seems to have propagated: all clones (the central repo and the user repos) are corrupted, pretty badly, in the same way. I think we could have prevented it if we did verification at that time.
Is there some Hg setting that would cause verification on each push, and prevent push in case of verification failure? I know I could implement it as a hook in Python, but is there maybe a simpler solution?
Is it also possible to do the opposite: make sure the remote repository is verified before pulling?
FWIW, I am on Windows 10 and we are using TortoiseHg.
Update: I've tried creating hooks as suggested by Jordi. Hg now hangs waiting for locks. Here is what I see:
c:\Users\username\test-hook>hg init
c:\Users\username\test-hook>cd ..
c:\Users\username>hg clone test-hook test-hook-clone
updating to branch default
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
# At this point I edited clone repository settings to include
# [hooks]
# preoutgoing = hg verify
#
# Then I created a test.txt file and "added" it via TortoiseHg context menu.
c:\Users\username\test-hook-clone>hg commit
c:\Users\username\test-hook-clone>hg status
c:\Users\username\test-hook-clone>hg outgoing
comparing with c:\Users\username\test-hook
searching for changes
changeset: 0:a61d33af6cdb
tag: tip
user: username
date: Mon May 06 20:32:54 2019 +0200
summary: test file added
c:\Users\username\test-hook-clone>hg push -verbose
pushing to c:\Users\username\test-hook
searching for changes
running hook preoutgoing: hg verify
waiting for lock on repository c:\Users\username\test-hook-clone held by process '16840' on host 'LT407233'
To answer your question, the hook does not have to be written in Python. In the appropriate server's hgrc (either at the repository level or the system level), simply set
[hooks]
preoutgoing = hg verify
preincoming = hg verify
This may significantly slow down all pull and push operations, but perhaps you are willing to sacrifice speed for correctness.
This will result in output like this when a client tries to pull from a corrupt repo:
$ hg clone http://localhost:9000 sample-repo
requesting all changes
remote: abort: preoutgoing hook exited with status 1
and in your server logs, you should see output similar to
127.0.0.1 - - [18/Apr/2019 12:41:09] "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=lheads+%3Bknown+nodes%3D x-hgproto-1:0.1 0.2 comp=zstd,zlib,none,bzip2 partial-pull
checking changesets
checking manifests
crosschecking files in changesets and manifests
checking files
a#0: broken revlog! (index data/a.i is corrupted)
warning: orphan data file 'data/a.i'
checked 2 changesets with 1 changes to 2 files
1 warnings encountered!
1 integrity errors encountered!
(first damaged changeset appears to be 0)
You can enable a server side option to perform more validation all incoming content, just set the server.validate=yes option on your server.
The simplest way is to enable it in your server global hgrc or in the repository .hg/hgrc file by adding the following two lines:
[server]
validate = yes
This is a server option but you can also use it on the client. It should validate pull too.
(By the way, what kind of corruption are you seeing?)

Can't clone bitbucket repository with sourcetree and without

MacOs Yosemite
I try clone repository with sourcetree. It began cloning but through some minutes it show me alert "Confirm Delete Repository" with text "You opted to delete repositories on disk but the repository "(null)" contains uncommitted files which will be lost forever if you delete this repository. Are you sure you want to delete the repository on disk?" So i can't clone
I try clone with terminal. After cloning terminal write message: "remote: Connection to bitbucket.org closed by remote host." But it's not clong all my repository and subrepository.
How I can get repository from bitbucket? I have 2 repositories, that I cloning 2-3 monthes ago on my macbook, and it was all good. Repository is cloned on my work under my account too without problems. But now I try get 2 new repositories on my mac, and I have same issues, that I described
In sourcetree I got such error:
hg clone ssh://hg#bitbucket.org/{my_repository}
requesting all changes
adding changesets
adding manifests
adding file changes
added 19 changesets with 115 changes to 58 files
updating to branch default
cloning subrepo framework from ssh://hg#bitbucket.org/{my_repository}
requesting all changes
adding changesets
adding manifests
adding file changes
added 1004 changesets with 4877 changes to 2384 files (+3 heads)
remote: Connection to bitbucket.org closed by remote host.
Completed with errors, see above

Mercurial hook exited with status 1

We use Mercurial (hg) for source control with a central repository (each developer has their own local as well). I am trying to set up a hook in the central repo such that it kicks off a Jenkins CI build.
The hook appears in the hgrc file as:
[hooks]
incoming.jenkins = java -jar C:/buildServerJar/jenkins-cli.jar -s http://ctc-jenkins:8080/ -i C:/buildServerJar/id_rsa build "All Working Projects"
[ui]
verbose = True
debug = True
Now, I have tested the command invoked from the hook on the command-line of the machine that hosts the central repository and it works as expected.
However, when I trigger the hook with a push to the central repository, I see the following output:
% hg --repository D:\dev\hg\******\source push W:\Repository\*********
pushing to W:\Repository\**********
searching for changes
adding changesets
add changeset 62784303122b
adding manifests
adding file changes
adding ****/CMakeLists.txt revisions
added 1 changesets with 1 changes to 1 files
updating the branch cache
running hook incoming.jenkins: java -jar C:/buildServerJar/jenkins-cli.jar -s http://ctc-jenkins:8080/ -i C:/buildServerJar/id_rsa build "All Working Projects"
warning: incoming.jenkins hook exited with status 1
[command completed successfully Fri Jul 26 15:24:58 2013]
The server in question is a Windows machine. Any ideas what could be going wrong or how to get more details on the error?
UPDATE:
So I modified the hook to get more info:
incoming.jenkins = java -jar C:/buildServerJar/jenkins-cli.jar -s http://ctc-jenkins:8080/ -i C:/buildServerJar/id_rsa build "All Working Projects" > hg_output.log 2> hg_errors.log
And it says it is unable to locate the jarfile, which is clearly in the location indicated. Makes me wonder if it is a permissions issue. Does anyone know what user account Mercurial runs its hooks under?
Error: Unable to access jarfile C:/buildServerJar/jenkins-cli.jar

Automating Hg notify config updates

Hosting Mercurial on a windows box thru IIS.
I have a root directory where I put all of my repos
d:\repos
- ProjectA
- .hg
- hgrc
- ProjectB
- .hg
- hgrc
- ProjectC
- .hg
- hgrc
All of the repos' hgrc files setup the notify extension with:
config =d:\hg\Repositories\NotificationList.txt
That way I have a single file to manage all of the notification recipients, like the wiki describes:
https://www.mercurial-scm.org/wiki/NotifyExtension
But the wiki makes mention of controlling that NotificationList.txt file thru it's own repository? How can I do that? If I create a separate repo at d:\repos\HgNotify and have the NotificationList.txt file in there, users can change, commit and push back, but when the push occurs, NotificationList.txt does not get updated on the hg server.
Is there a way to update that file somehow? Am I missing a key setup on my Hg server? Or do I need to use a post-push hook to deploy that file?
Update 1
I added the details from Tim's answer and I kept getting HTTP 500: Server Error on the push. I finally figure out how to trace the python calls (python -m win32traceutil), and here is what seems to be the problem:
File "C:\Python27\lib\site-packages\mercurial\util.py", line 402, in hgexecutable
exe = findexe('hg') or os.path.basename(sys.argv[0]) AttributeError: 'module' object has no attribute 'argv'
It doesn't seem to be able to find hg.exe.
Update 2
I installed TortoiseHg and rebooted the system. Now I get:
emote: added 1 changesets with 1 changes to 1 files
remote: notify: sending 1 subscribers 1 changes
remote: warning: changegroup.update hook exited with status 1
So that makes be think that it has found the hg.exe, but it is not doing its job, because the file does not get updated
Update 3
Found my solution here: https://stackoverflow.com/a/8023594/698
The command line I ended up using was:
changegroup = cmd /c hg update
I also added:
[ui]
debug=true
To my hgrc. Those two combined gave me a lot more meaningful messages. In the end I saw "Access denied". I gave Users full permission, but I am not sure why giving IUSR full permission didn't work. Something I'll have to dig into at a later time.
On the server repo containing your notification list you need to add a changegroup hook:
[hooks]
changegroup.update = hg update -C
or if you want to ensure the repository is always clean:
[extensions]
purge =
[hooks]
changegroup.update = hg update -C && hg purge --all