Mercurial FTP extension

If you use mercurial for your version control and you need to deploy continuously to a FTP site you should have a look at the extension developed by André Klitzing.

It will the first time upload all your files to your host and then only the missing committed changes, it’s really great instead or uploading all or remembering the 35 files that you changed everywhere you can simply do:

cd yourdirectory
hg ftp yourseveralias --upload
(Check the instructions for how to add your server alias,user,pwd)

Now unfortunately in my hosting the username MUST use @ like :, so the URL is parsed wrongly by the python functions and the upload fails

I add this very naïve fix (New code in green and  DON’T forget to add proper padding in your editor)

Around line 31:
// Check if  there's more than one @ if so replace the first one with some arbitrary  characters that are hard to find in a username
path = self.ui.config('paths', url)
 if path:
   if path.find('@') != path.rfind('@'):
      path = path.replace('@','{!!',1)
   self.url = urlparse.urlsplit(path)
   self.url = urlparse.urlsplit(url)Around line 144 on the _ftp function BEFORE the login function
// Replace back the arbitrary characters '{!!' for the first @
 if user:
    user = user.replace('{!!','@',1)
 ftp.login(user, psw)

Hope it helps someone else!


2 thoughts on “Mercurial FTP extension

    • That sounds even better, thanks!

      I think last time I was installing this extension i didn’t need to ‘fix’ as python parsed properly, but can’t remember clearly.

Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s