SOLVED: Remote mercurial server fails in changegroup.notify with an exception - mercurial

Pushing changes to a remote mercurial repo is reporting an error in my changegroup.notify hook. It worked with an old 2.7 release of mercurial, but is broken now.
My server has
Python 3.9, hg --version is
Mercurial Distributed SCM (version 6.3.1)
The relevant repo's hgrc has
changegroup.notify = python:hgext.notify.hook
The hook reports an exception:
>: hg --traceback push
pushing to https://[redacted]
searching for changes
remote: adding changesets
remote: adding manifests
remote: adding file changes
remote: added 1 changesets with 1 changes to 1 files
remote: error: changegroup.notify hook raised an exception: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
remote: (run with --traceback for stack trace)
Why the exception, when I am using what is supposed to just work
out of the box?
Update: Re-ran the test pushing from an account on the same machine as the server (thanks #LazyBadger), got the following traceback:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/mercurial/hook.py", line 116, in pythonhook
r = obj(ui=ui, repo=repo, hooktype=htype, **pycompat.strkwargs(args))
File "/usr/local/lib/python3.9/dist-packages/hgext/notify.py", line 589, in hook
n = notifier(ui, repo, hooktype)
File "/usr/local/lib/python3.9/dist-packages/hgext/notify.py", line 326, in __init__
self.stripcount = int(self.ui.config(b'notify', b'strip'))
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
Solution:
Turns out this is the error you get if you haven't updated your hgrc in years. Used to be that adding the hook to your [.]hgrc was all that was required. Now you have to enable notify as well, so, e.g.
[extensions]
notify=
[hooks]
changegroup.notify = python:hgext.notify.hook
You also need some things to allow the email notication to work, for example if you have personal email support on the same server:
[reposubs]
* = [my email on the server]
[email]
from = Mercurial Notification <noreply#mydomain>
[smtp]
host = localhost

Related

Abort: unknown largefiles usercache location

I've got older Debian Jessie server with Mercurial 3.1.2 and Phabricator. Long time Phabricator protest that HG is old and there is secure problems and I decide to make brand new VM with latest HG.
Old:
lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 8.11 (jessie)
Release: 8.11
Codename: jessie
hg version
Mercurial Distributed SCM (version 3.1.2)
(see http://mercurial.selenic.com for more information)
New:
Distributor ID: Debian
Description: Debian GNU/Linux 10 (buster)
Release: 10
Codename: buster
hg version
Mercurial Distributed SCM (version 4.8.2)
(see https://mercurial-scm.org for more information)
Copyright (C) 2005-2018 Matt Mackall and others
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Enabled extensions:
largefiles internal
and configured:
hg debuginstall
checking encoding (UTF-8)...
checking Python executable (/usr/bin/python2)
checking Python version (2.7.16)
checking Python lib (/usr/lib/python2.7)...
checking Python security support (sni,tls1.0,tls1.1,tls1.2)
checking Mercurial version (4.8.2)
checking Mercurial custom build ()
checking module policy (c)
checking installed modules (/usr/lib/python2.7/dist-packages/mercurial)...
checking registered compression engines (bz2, bz2truncated, none, zlib, zstd)
checking available compression engines (bz2, bz2truncated, none, zlib, zstd)
checking available compression engines for wire protocol (zstd, zlib, bz2, none)
checking "re2" regexp engine (missing)
checking templates (/usr/share/mercurial/templates)...
checking default template (/usr/share/mercurial/templates/map-cmdline.default)
checking commit editor... (sensible-editor)
checking username (myuser <myuser#gmail.com>)
no problems detected
hg --debug showconfig
starting pager for command 'config'
read config from: /usr/etc/mercurial/hgrc
read config from: /etc/mercurial/hgrc
read config from: /etc/mercurial/hgrc.d/cacerts.rc
read config from: /etc/mercurial/hgrc.d/hgext.rc
read config from: /root/.hgrc
read config from: /root/.config/hg/hgrc
/etc/mercurial/hgrc:9: extensions.largefiles=
/etc/mercurial/hgrc:19: trusted.users=root, topperl, www-data
/etc/mercurial/hgrc:12: ui.username=myuser <myuser#gmail.com>
--verbose: ui.verbose=False
--debug: ui.debug=True
--quiet: ui.quiet=False
pager: ui.formatted=True
pager: ui.interactive=False
/etc/mercurial/hgrc.d/cacerts.rc:4: web.cacerts=/etc/ssl/certs/ca-certificates.crt
Rsynced all the repositories and setup hgweb.wsgi to act like a web server (Apache2 vhost as it's easy for me)
# An example WSGI for use with mod_wsgi, edit as necessary
# See https://mercurial-scm.org/wiki/modwsgi for more information
# Path to repo or hgweb config to serve (see 'hg help hgweb')
config = "/var/www/vhost/hg/cgi-bin/hgweb.config"
# Uncomment and adjust if Mercurial is not installed system-wide
# (consult "installed modules" path from 'hg debuginstall'):
#import sys; sys.path.insert(0, "/path/to/python/lib")
# Uncomment to send python tracebacks to the browser if an error occurs:
import cgitb; cgitb.enable()
# enable demandloading to reduce startup time
from mercurial import demandimport; demandimport.enable()
from mercurial.hgweb.hgwebdir_mod import hgwebdir
import os
os.environ["HGENCODING"] = "UTF-8"
from mercurial.hgweb import hgweb
application = hgweb(config)
Python version is:
Python 2.7.16 (default, Apr 6 2019, 01:42:57)
[GCC 8.3.0] on linux2
When push large files I receive error:
mod_wsgi (pid=3945): Exception occurred processing WSGI script '/var/www/vhost/hg/cgi-bin/hgwebdir.w
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/mercurial/hgweb/hgwebdir_mod.py", line 352, in run_wsgi
for r in self._runwsgi(req, res):
File "/usr/lib/python2.7/dist-packages/mercurial/hgweb/hgweb_mod.py", line 307, in run_wsgi
for r in self._runwsgi(req, res, repo):
File "/usr/lib/python2.7/dist-packages/mercurial/hgweb/hgweb_mod.py", line 333, in _runwsgi
rctx, req, res, self.check_perm)
File "/usr/lib/python2.7/dist-packages/mercurial/wireprotoserver.py", line 221, in handlewsgireque
_callhttp(repo, req, res, proto, cmd)
File "/usr/lib/python2.7/dist-packages/mercurial/wireprotoserver.py", line 436, in _callhttp
rsp = wireprotov1server.dispatch(repo, proto, cmd)
File "/usr/lib/python2.7/dist-packages/mercurial/wireprotov1server.py", line 74, in dispatch
return func(repo, proto, *args)
File "/usr/lib/python2.7/dist-packages/mercurial/wireprotov1server.py", line 196, in batch
result = func(repo, proto, *[data[k] for k in keys])
File "/usr/lib/python2.7/dist-packages/hgext/largefiles/proto.py", line 89, in statlfile
filename = lfutil.findfile(repo, sha)
File "/usr/lib/python2.7/dist-packages/hgext/largefiles/lfutil.py", line 111, in findfile
elif inusercache(repo.ui, hash):
File "/usr/lib/python2.7/dist-packages/hgext/largefiles/lfutil.py", line 100, in inusercache
path = usercachepath(ui, hash)
File "/usr/lib/python2.7/dist-packages/hgext/largefiles/lfutil.py", line 71, in usercachepath
return os.path.join(_usercachedir(ui), hash)
File "/usr/lib/python2.7/dist-packages/hgext/largefiles/lfutil.py", line 97, in _usercachedir
raise error.Abort(_('unknown %s usercache location') % name)
Abort: unknown largefiles usercache location
Tried really hard whole day that and another tweak and advice but no luck :/
Some one with smart advice ?
PS: Also tried to clone old >> push new some repos and not good again
Partial resolve the problem - users cloned repositories can now make hg push repo
Add to /etc/mercurial/hgrc except:
[extensions]
largefiles =
and
[largefiles]
usercache = /path/to/largefiles/storage
Still facing the problem how to migrate all the repost from old to new server.
If I found proper solution will edit the topic.

Mercurial Fails to Update to A Revision Due to a File Name

I have a repository which I am trying to work on. Unfortunately when I update to a revision of interest it fails with message
abort: Illegal byte sequence: /Users/<user>/Projects/P/infusion16/Standings ? Kattis, Infusion Programming Contest 2016.pdf
When I run update with --traceback and --debug options it shows following:
File "/Users/evgeniy.sharapov/.pyenv/versions/2.7.14/lib/python2.7/site-packages/mercurial/merge.py", line 1381, in batchget
atomictemp=atomictemp)
File "/Users/evgeniy.sharapov/.pyenv/versions/2.7.14/lib/python2.7/site-packages/mercurial/context.py", line 1969, in write
**kwargs)
File "/Users/evgeniy.sharapov/.pyenv/versions/2.7.14/lib/python2.7/site-packages/mercurial/localrepo.py", line 1115, in wwrite
**kwargs)
File "/Users/evgeniy.sharapov/.pyenv/versions/2.7.14/lib/python2.7/site-packages/mercurial/vfs.py", line 87, in write
with self(path, 'wb', backgroundclose=backgroundclose, **kwargs) as fp:
File "/Users/evgeniy.sharapov/.pyenv/versions/2.7.14/lib/python2.7/site-packages/mercurial/vfs.py", line 409, in __call__
fp = util.posixfile(f, mode)
IOError: [Errno 92] Illegal byte sequence: '/Users/<user>/Projects/Puzzles/infusion16/Standings \x96 Kattis, Infusion Programming Contest 2016.pdf'
abort: Illegal byte sequence: /Users/<user>/Projects/Puzzles/infusion16/Standings ? Kattis, Infusion Programming Contest 2016.pdf
Looks like it has some sort of a character that is not supported in a file name ? I check environment both LC_CTYPE and LANG are set to en_US.UTF-8.
What could be done in this situation ? I could probably live without this file or have it renamed? Another problem that the fail in update happens in the middle of the process so I don't have all the files in the work directory.
I'd first run hg man to obtain the relevant PATHNAME, and then extract that file's contents by: hg cat PATHNAME
Then you could try hg revert --all --exclude PATHNAME to extract everything else (assuming all the other filenames are accepted by the host OS).

qemu-native error when building core-image-minimal with yocto

I want to build the core-image-minimal with yocto and it fails. To set everything up I use the following steps:
sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat cpio python python3 python3-pip python3-pexpect cmake
git clone git://git.yoctoproject.org/poky.git poky.git
cd poky.git
git checkout -b morty remotes/origin/morty
. oe-init-build-env
cd ..
git clone https://github.com/altera-opensource/meta-altera.git meta-altera
cd meta-altera
git checkout -b angstrom-v2015.12-yocto2.0 remotes/origin/angstrom-v2015.12-yocto2.0
Afterwards I add the path to meta-altera to build/conf/bblayers.conf and MACHINE = "cyclone5" to build/conf/local.conf. I would expect, that now bitbake core-image-minimal would run through, but it stops with the following error:
WARNING: qemu-native-2.7.0-r1 do_populate_sysroot: File '/mydirectory/poky.git/build/tmp/sysroots/x86_64-linux/usr/share/qemu/openbios-ppc' from qemu-native was already stripped, this will prevent future debugging!
WARNING: qemu-native-2.7.0-r1 do_populate_sysroot: File '/mydirectory/poky.git/build/tmp/sysroots/x86_64-linux/usr/share/qemu/openbios-sparc32' from qemu-native was already stripped, this will prevent future debugging!
WARNING: qemu-native-2.7.0-r1 do_populate_sysroot: File '/mydirectory/poky.git/build/tmp/sysroots/x86_64-linux/usr/share/qemu/openbios-sparc64' from qemu-native was already stripped, this will prevent future debugging!
WARNING: qemu-native-2.7.0-r1 do_populate_sysroot: File '/mydirectory/poky.git/build/tmp/sysroots/x86_64-linux/usr/share/qemu/s390-ccw.img' from qemu-native was already stripped, this will prevent future debugging!
WARNING: qemu-native-2.7.0-r1 do_populate_sysroot: File '/mydirectory/poky.git/build/tmp/sysroots/x86_64-linux/usr/share/qemu/u-boot.e500' from qemu-native was already stripped, this will prevent future debugging!
ERROR: qemu-native-2.7.0-r1 do_populate_sysroot: runstrip: ''strip' --remove-section=.comment --remove-section=.note '/mydirectory/poky.git/build/tmp/work/x86_64-linux/qemu-native/2.7.0-r1/sysroot-destdir/media/sln/Data/yocto/poky.git/build/tmp/sysroots/x86_64-linux/usr/share/qemu/palcode-clipper'' strip command failed with 1 (b"strip: Unable to recognise the format of the input file `/mydirectory/poky.git/build/tmp/work/x86_64-linux/qemu-native/2.7.0-r1/sysroot-destdir/mydirectory/poky.git/build/tmp/sysroots/x86_64-linux/usr/share/qemu/palcode-clipper'\n")
I got rid of the warnings by adding INSANE_SKIP_qemu-native = "already-stripped" to poky.git/meta/recipes-devtools/qemu/qemu.inc but the error remains. I am using Ubunut 16.04 as my build machine. Any help or tipps are appreciated.
If I continue building, I get an error while building gcc-runtime-6.2.0-r0 do_compile and it stops. I assume that this error is based on the qemu error.
Here is the build config shown in bitbake:
Build Configuration:
BB_VERSION = "1.32.0"
BUILD_SYS = "x86_64-linux"
NATIVELSBSTRING = "universal"
TARGET_SYS = "arm-poky-linux-gnueabi"
MACHINE = "cyclone5"
DISTRO = "poky"
DISTRO_VERSION = "2.2.1"
TUNE_FEATURES = "arm armv7a vfp neon callconvention-hard"
TARGET_FPU = "hard"
meta
meta-poky
meta-yocto-bsp = "morty:924e576b8930fd2268d85f0b151e5f68a3c2afce"
meta-altera = "angstrom-v2015.12-yocto2.0:3cfd56bb15673795435cf7684ef9c723283a6bce"
It looks like you're checking out the Yocto 2.0 branch of the meta-altera layer. Yocto 2.0 was Jethro. You're checking out the Morty branch of Poky which is Yocto 2.2. Try checking out the jethro branch of Poky with by executing the following Git command while in your poky.git folder:
git checkout -b jethro remotes/origin/jethro

Mercurial https clone: "abort: error: (...) wrong version number"

I have problem with mercurial on OS X 10.9.1
I have a repository on bitbucket with couple files, when I'm trying to clone it I'm getting an error:
mac-mini-jakub:testrepo kubeczek$ hg clone https://kubecz3k#bitbucket.org/kubecz3k/test
abort: error: _ssl.c:507: error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number
I have installed Mercurial 2.8.2 for MacOS X 10.9 from https://www.mercurial-scm.org/downloads/
I'm pretty sure that on the side of the bitbucket everything is ok, because I have no problem on linux machine.
here is the full traceback:
mac-mini-jakub:testrepo kubeczek$ hg clone https://kubecz3k#bitbucket.org/kubecz3k/test --traceback
Traceback (most recent call last):
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/dispatch.py", line 133, in _runcatch
return _dispatch(req)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/dispatch.py", line 806, in _dispatch
cmdpats, cmdoptions)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/dispatch.py", line 585, in runcommand
ret = _runcommand(ui, options, cmd, d)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/dispatch.py", line 897, in _runcommand
return checkargs()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/dispatch.py", line 868, in checkargs
return cmdfunc()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/dispatch.py", line 803, in <lambda>
d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/util.py", line 512, in check
return func(*args, **kwargs)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/commands.py", line 1286, in clone
branch=opts.get('branch'))
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/hg.py", line 268, in clone
srcpeer = peer(ui, peeropts, source)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/hg.py", line 122, in peer
return _peerorrepo(rui, path, create).peer()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/hg.py", line 102, in _peerorrepo
obj = _peerlookup(path).instance(ui, path, create)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/httppeer.py", line 238, in instance
inst._fetchcaps()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/httppeer.py", line 57, in _fetchcaps
self.caps = set(self._call('capabilities').split())
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/httppeer.py", line 171, in _call
fp = self._callstream(cmd, **args)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/httppeer.py", line 118, in _callstream
resp = self.urlopener.open(req)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 404, in open
response = self._open(req, data)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 422, in _open
'_open', req)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 382, in _call_chain
result = func(*args)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/url.py", line 368, in https_open
return self.do_open(self._makeconnection, req)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/keepalive.py", line 257, in do_open
raise urllib2.URLError(err)
URLError: <urlopen error [Errno 1] _ssl.c:507: error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number>
abort: error: _ssl.c:507: error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number
My Python version is:
mac-mini-jakub:~ kubeczek$ python -V
Python 2.7.6
And SSL:
>>> print _ssl.OPENSSL_VERSION
OpenSSL 0.9.8y 5 Feb 2013
I will appreciate every help, thanks!
You probably have to disable TLS, read this
To do so, add this to ~/.hgrc
[ui]
tls = False
more information about SSL and TLS here
There is another cause. It might not have been your problem, but it should be listed here as well, for the case others encounter this problem:
If you are behind a proxy and your proxy settings are incorrect, this error message appears as well. God knows why...
Example: you have the following config
[http_proxy]
no = localhost,127.0.0.1
host = 1.2.3.4:8080
user = myusername
passwd = oldpassword
The oldpassword might be obsolet (you have forgotten to change it). Then the very same SSL wrong version error appears. It does absolutly make no sense at all (at least to me), but I reproduced this issue with mercurial 3.6.2. Correcting the proxy settings fixes everything.
Not exactly a direct solution but good workaround:
With strong suggestion that the problem lies is ssl I have switched to ssh(https://confluence.atlassian.com/pages/viewpage.action?pageId=270827678) and now everything works. So from a practical point of view for me this problem is solved.
I had this problem for some bitbucket repositories (but not all). I found that, as per the traceback, setting --config ui.clonebundles=false worked.
hg clone --config ui.clonebundles=false https://bitbucket.org/me/myrepo
made the clone much slower mind you.
[edit] -- Although, see my comment on #UniversE's answer above, the actual problem was to do with an atlassian subdomain not being on my squid proxy's whitelist. phew, that was hard to debug.
As one of the question's comments suggested, switching from https to ssh fixed it for me
You have to disable clonebundle from system wide mercurial config file or own config file.
To do, add following lines to /etc/mercurial/hgrc or ~/.hgrc
# system-wide mercurial configuration file
# See hgrc(5) for more information
[ui]
clonebundles = False

How to resolve mercurial conflict where no match is found?

I have managed to really get my repo into a state, and I don't have the mad skills required to fix it, your help would be appreciated.
I am trying to merge/update so that the work I developed in a seperate branch is correctly integrated into my local one.
When I run and run a merge on rev 284, I get the following error:
% hg --repository C:\Projects\foo merge --verbose
--tool=internal:merge 284 abort: data/Web/Utilities/Extensions/RegexExtensions.cs.i#364e78cf7bcb: no
match found! [command returned code 255 Sat Jan 19 16:12:54 2013]
I am using tortoisehg, and have tried to search for a resolution but I can't figure out how to resolve this error?
What has happend in this case, is that the file has been deleted in one branch, and I guess exists in the other?
How to resovle?
.
Edit 1:
Was fiddling around and found this as well:
#!python
** Mercurial version (2.4.2). TortoiseHg version (2.6.2)
** Command: --nofork workbench
** CWD: C:\Projects\foo
** Encoding: cp1252
** Extensions loaded:
** Python version: 2.7.3 (default, Apr 10 2012, 23:24:47) [MSC v.1500 64 bit (AMD64)]
** Windows version: sys.getwindowsversion(major=6, minor=1, build=7600, platform=2, service_pack='')
** Processor architecture: x64
** Qt-4.8.0 PyQt-4.9.1
Traceback (most recent call last):
File "tortoisehg\hgqt\repowidget.pyo", line 1678, in visualDiffToLocal
File "tortoisehg\hgqt\visdiff.pyo", line 213, in visualdiff
File "mercurial\copies.pyo", line 166, in pathcopies
File "mercurial\copies.pyo", line 151, in _backwardcopies
File "mercurial\copies.pyo", line 138, in _forwardcopies
File "mercurial\copies.pyo", line 106, in _tracefile
File "mercurial\context.pyo", line 722, in ancestors
File "mercurial\context.pyo", line 546, in parents
File "mercurial\util.pyo", line 246, in __get__
File "mercurial\context.pyo", line 399, in _filenode
File "mercurial\revlog.pyo", line 776, in lookup
LookupError: data/web/Utilities/Extensions/RegexExtensions.cs.i#364e78cf7bcb: no match found
Edit 2:
I've managed to merge most of the revisions I need, I am left now with just one on the branch that is corrupt.
How can I now discard that revision/branch?
CLI-version of merge (screenshots - maybe later)
hg up
hg merge 297
hg commit -m "Merge 1"
hg merge 284
hg commit -m "Merge 2"
If you want to merge at some other points: fix destination of update (to this point you'll merge) and merge sources