Home > Development > Using mercurial as SVN client

Using mercurial as SVN client

Somewhere over the rainbow
Skies are blue,
And the dreams that you dare to dream
Really do come true.
(Harold Arlen and E.Y. Harburg)

There are two things I can’t stand with SVN. The whole unnecessary forest of .svn sub-directories scattered all around my working copy. Second is the propset way of ignoring files. Can I add third? 🙂 It’s the manual svn add/remove for every file I create/delete…  Ay my current company (srce.hr) we use SVN as central VCS. I use it for RPM packages and puppet modules/manifests.
Now, if you want to distribute same working copy on more than one location, and be able to pull and push changes, all those .svn directories are really clumsy. So I decided to try HGsubversion extension. I already use Mercurial a lot (for example with etckeeper) and love its simplicity. So, on my workstation running CentOS 6, I first fetched hgsubversion extension:

% hg clone http://bitbucket.org/durin42/hgsubversion/ ~/.hgsubversion
 % echo "[extensions]" > ~/.hgrc
 % echo "hgsubversion = ~/.hgsubversion/hgsubversion" >> ~/.hgrc

How many of you actually read README’s? 🙂 I surely don’t until things break out. And so they broke…

% hg clone svn+https://svnserver/svn/repo
 destination directory: repo
 Auth realm:  SVN login
 Password for jsosic:
 [r1] jsosic: import modula
 [r2] jsosic: Redesigned.
 [r3] jsosic: something
 [r4] jsosic: something else
 pulled 4 revisions
 updating to branch default
 151 files updated, 0 files merged, 0 files removed, 0 files unresolved
 ** unknown exception encountered, details follow
 ** report bug details to http://mercurial.selenic.com/bts/
 ** or mercurial@selenic.com
 ** Mercurial Distributed SCM (version 1.4)
 ** Extensions loaded: hgsubversion
 Traceback (most recent call last):
 File "/usr/bin/hg", line 27, in
 mercurial.dispatch.run()
 File "/usr/lib64/python2.6/site-packages/mercurial/dispatch.py", line 16, in run
 sys.exit(dispatch(sys.argv[1:]))
 File "/usr/lib64/python2.6/site-packages/mercurial/dispatch.py", line 30, in dispatch
 return _runcatch(u, args)
 File "/usr/lib64/python2.6/site-packages/mercurial/dispatch.py", line 46, in _runcatch
 return _dispatch(ui, args)
 File "/usr/lib64/python2.6/site-packages/mercurial/dispatch.py", line 449, in _dispatch
 return runcommand(lui, repo, cmd, fullargs, ui, options, d)
 File "/usr/lib64/python2.6/site-packages/mercurial/dispatch.py", line 319, in runcommand
 ret = _runcommand(ui, options, cmd, d)
 File "/usr/lib64/python2.6/site-packages/mercurial/dispatch.py", line 500, in _runcommand
 return checkargs()
 File "/usr/lib64/python2.6/site-packages/mercurial/dispatch.py", line 454, in checkargs
 return cmdfunc()
 File "/usr/lib64/python2.6/site-packages/mercurial/dispatch.py", line 448, in
 d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
 File "/usr/lib64/python2.6/site-packages/mercurial/util.py", line 386, in check
 return func(*args, **kwargs)
 File "/usr/lib64/python2.6/site-packages/mercurial/extensions.py", line 116, in wrap
 util.checksignature(origfn), *args, **kwargs)
 File "/usr/lib64/python2.6/site-packages/mercurial/util.py", line 386, in check
 return func(*args, **kwargs)
 File "/home/jsosic/.hgsubversion/hgsubversion/wrappers.py", line 540, in clone
 fd = dst.opener("hgrc", "a", text=True)
 AttributeError: 'bool' object has no attribute 'opener'
 [1]    15118 exit 1     hg clone svn+https://svnserver/svn/repo

It seems that I didn’t have subvertpy installed, which is availabe in EPEL for RHEL/CentOS so…

# yum install python-subvertpy

After that – another error…

% hg clone svn+https://svnserver/svn/repo
 destination directory: repo
 ** unknown exception encountered, details follow
 ** report bug details to http://mercurial.selenic.com/bts/
 ** or mercurial@selenic.com
 ** Mercurial Distributed SCM (version 1.4)
 ** Extensions loaded: hgsubversion
 Traceback (most recent call last):
 File "/usr/bin/hg", line 27, in
 mercurial.dispatch.run()
 File "/usr/lib64/python2.6/site-packages/mercurial/dispatch.py", line 16, in run
 sys.exit(dispatch(sys.argv[1:]))
 File "/usr/lib64/python2.6/site-packages/mercurial/dispatch.py", line 30, in dispatch
 return _runcatch(u, args)
 File "/usr/lib64/python2.6/site-packages/mercurial/dispatch.py", line 46, in _runcatch
 return _dispatch(ui, args)
 File "/usr/lib64/python2.6/site-packages/mercurial/dispatch.py", line 449, in _dispatch
 return runcommand(lui, repo, cmd, fullargs, ui, options, d)
 File "/usr/lib64/python2.6/site-packages/mercurial/dispatch.py", line 319, in runcommand
 ret = _runcommand(ui, options, cmd, d)
 File "/usr/lib64/python2.6/site-packages/mercurial/dispatch.py", line 500, in _runcommand
 return checkargs()
 File "/usr/lib64/python2.6/site-packages/mercurial/dispatch.py", line 454, in checkargs
 return cmdfunc()
 File "/usr/lib64/python2.6/site-packages/mercurial/dispatch.py", line 448, in
 d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
 File "/usr/lib64/python2.6/site-packages/mercurial/util.py", line 386, in check
 return func(*args, **kwargs)
 File "/usr/lib64/python2.6/site-packages/mercurial/extensions.py", line 116, in wrap
 util.checksignature(origfn), *args, **kwargs)
 File "/usr/lib64/python2.6/site-packages/mercurial/util.py", line 386, in check
 return func(*args, **kwargs)
 File "/home/jsosic/.hgsubversion/hgsubversion/wrappers.py", line 528, in clone
 orig(ui, source, dest, **opts)
 File "/usr/lib64/python2.6/site-packages/mercurial/util.py", line 386, in check
 return func(*args, **kwargs)
 File "/usr/lib64/python2.6/site-packages/mercurial/commands.py", line 649, in clone
 update=opts.get('updaterev') or not opts.get('noupdate'))
 File "/usr/lib64/python2.6/site-packages/mercurial/extensions.py", line 128, in wrap
 return wrapper(origfn, *args, **kwargs)
 File "/home/jsosic/.hgsubversion/hgsubversion/wrappers.py", line 517, in hgclonewrapper
 data['srcrepo'], data['dstrepo'] = orig(ui, *args, **opts)
 File "/usr/lib64/python2.6/site-packages/mercurial/hg.py", line 292, in clone
 dest_repo.clone(src_repo, heads=revs, stream=stream)
 File "/usr/lib64/python2.6/site-packages/mercurial/localrepo.py", line 2144, in clone
 return self.pull(remote, heads)
 File "/home/jsosic/.hgsubversion/hgsubversion/svnrepo.py", line 81, in wrapper
 return fn(self, *args, **opts)
 File "/home/jsosic/.hgsubversion/hgsubversion/svnrepo.py", line 104, in pull
 return wrappers.pull(self, remote, heads, force)
 File "/home/jsosic/.hgsubversion/hgsubversion/wrappers.py", line 271, in pull
 svn_url = source.svnurl
 File "/home/jsosic/.hgsubversion/hgsubversion/svnrepo.py", line 154, in svnurl
 return self.svn.svn_url
 File "/usr/lib64/python2.6/site-packages/mercurial/util.py", line 150, in __get__
 result = self.func(obj)
 File "/home/jsosic/.hgsubversion/hgsubversion/svnrepo.py", line 159, in svn
 return svnwrap.SubversionRepo(*self.svnauth, password_stores=self.password_stores)
 File "/home/jsosic/.hgsubversion/hgsubversion/svnwrap/subvertpy_wrapper.py", line 179, in __init__
 self.init_ra_and_client()
 File "/home/jsosic/.hgsubversion/hgsubversion/svnwrap/subvertpy_wrapper.py", line 231, in init_ra_and_client
 auth=auth)
 File "/usr/lib64/python2.6/site-packages/subvertpy/ra.py", line 47, in RemoteAccess
 return url_handlers[type](url, *args, **kwargs)
 subvertpy.SubversionException: ("OPTIONS of 'https://svnserver/svn/repo': authorization failed:
 Could not authenticate to server: rejected Basic challenge (https://svnserver)", 170001)
 [1]    15247 exit 1     hg clone svn+https://svnserver/svn/repo

Now this second error is due to subvertpy not asking for authentication credentials… So what you have to do to fix this one is to store SVN password in either gnome-keyring, kwallet or simply plaintext… After that, HG works finaly 🙂

Edit: I’ve built hgsubversion RPM package and put it into SRCE rpm repositories.

Advertisements
Categories: Development Tags: , , ,
  1. June 21, 2013 at 5:23 pm

    So, how exactly do you “store SVN password simply plaintext”? I have a wheezy-based server and get this error upon push. No gnome-keyring here, of course. I’d like to try your plaintext-password suggestion but have no idea what you mean. The API of subvertpy does not really help.

  2. June 21, 2013 at 5:45 pm

    In `subvertpy_wrapper.py` I saw that URL credentials become parsed, so I added my credentials in plaintext in `.hg/hgrc` like so:

    [paths]
    default = svn+https://user:pass@svn.server.org/location/
    

    This worked.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: