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.

http://mercurial.selenic.com/wiki/FTPExtension

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 : user@site.com, 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)
 else:
   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!

Advertisements

Working with Mercurial .hgignore

We’re currently using Mercurial as the base tequila repository and we frequently have to work with .hgignore files

After some fighting with this regex here are some rules that seems to work

syntax: glob

syntax: regexp
#^gateway.php$ Ignores a top level file called gateway

# ignores a directory
^includes/app$

# ignores another directory
^includes/packages/Zend$

#ignores cache.php
^temp/cache\.*\.php$
# ignores cache.inc.php
^temp/cache\.inc\.php/
cache\.inc\.php$

#ignores logs
log.*\.txt

Interestingly I cannot manage to ignore the file temp/cache.inc.php no matter what I do! When I have the answer I’ll modify this post!