Wednesday, September 15, 2010

How to use hg by ssh at LaCIM

D'abord, je vérifie que hg est bien installé sur le serveur :
$ ssh
Last login: Wed Sep 15 12:56:35 2010 from
thales:~ USERNAME$ hg version
Mercurial Distributed SCM (version 1.3.1)

Copyright (C) 2005-2009 Matt Mackall and others
This is free software; see the source for copying conditions. There is NO
Ensuite, je teste si je peux utiliser Mercurial via ssh en mode non interactif :
sbeaudry:~ slabbe$ ssh hg version
bash: hg: command not found
Je me reconnecte au serveur ssh et j'édite le fichier .bashrc afin d'ajouter dans le PATH le chemin où se trouve Mercurial.
$ ssh
Last login: Wed Sep 15 13:00:18 2010 from
thales:~ USERNAME$ which hg
thales:~ USERNAME$ cat .bashrc
export PATH=/usr/local/bin:$PATH
Je me déconnecte à nouveau et je teste si je peux utiliser Mercurial en mode non interactif :
$ ssh hg version
Mercurial Distributed SCM (version 1.6.3+20100826)

Copyright (C) 2005-2010 Matt Mackall and others
This is free software; see the source for copying conditions. There is NO
Ça fonctionne!

Ensuite, je peux utiliser Mercurial pour synchroniser des répertoires (via push, pull et update). Pour le répertoire de mon site web, j'ai initialisé avec hg init mon répertoire Sites. Ensuite, j'ai fait un clone de la manière suivante:

hg clone ssh:// Sites

Puis, j'ai édité le fichier .hg/hgrc sur ma machine locale dans le répertoire de mon site web de la manière suivante :
# file .hg/hgrc
default = ssh://
Au LIRMM, j'ai édité le fichier .cshrc (plutôt que le .bashrc) de la manière suivante :
# fichier : .cshrc
# Ajout par Slabbe en mars 2010
# Set path shell variable
# (See description of path in the paragraph followin this example .cshrc)
set path = ( /usr/bin /usr/local /usr/local/bin /usr/bin/X11 \
/usr/ucb /usr/opt/bin ~ )

Wednesday, July 01, 2009

Convert an svn repository to an hg repository

[The following is a very condensed version of the instructions found here.]

Suppose svn-working-copy is a working copy of the svn repo.
hgimportsvn svn-working-copy hg-repo
Pull all SVN history with hgpullsvn
cd hg-repo
Do an update for good measure
hg update (optional)
Clean up the .svn and .hgignore directories.
cd hg-repo
find . -name .svn | xargs -0 rm -rf
find . -name .hgignore | xargs -0 rm -rf
Done. Yay.

Install hg in a custom location

The hg installation scripts allow you do a system-wide installation or an installation in $HOME (~/bin, ~/lib,...). To use a different location, do the following.

The install-home option for make installs hg into $HOME so we redefine the $HOME variable.
export HOME=/home/username/Applications/mercurial-1.2.1/
mkdir $HOME
Then run make.
make install-home
Create symlinks, if desired.
cd /home/username/Applications/bin
ln -s ../mercurial-1.2.1/bin/hg .

Add the following to .bashrc (change appropriately; for example, lib vs lib64, ...).
export PYTHONPATH=$HOME/Applications/mercurial-1.2.1/lib64/python/
export PATH=$HOME/Applications/bin:$HOME/bin:$PATH
Set $HOME back to the original location.
export HOME=/home/username/

Tuesday, May 12, 2009

Vim and Zip files

Today, by mistake, I tried to open a zipfile using vim.
I was presented with a list of the files contained in the zipfile, and was instructed to Select a file with cursor and press ENTER. I didn't know that Vim had a zipfile brower! Very nice.

(If this doesn't work for you, you need to install the zipfile browser plugin. Google for zip.vim to find it.)

Monday, May 04, 2009

Sage prompt in color

It is possible to activate colors for sage prompts in the terminal which is done by editing the file


As said by W. Stein on sage-devel :
"It has numerous color options, which are off by default since it is not possible to tell if the user's terminal has a white or black background, and any choice of colors looks like crap if you guess wrong about the background color."
Since the background of my terminal is light, my settings are :
# keep uncommented only the one you want:
#colors Linux
colors LightBG
#colors NoColor

Installing sagetex in sage

This post describes how I installed sagetex-2.0 recently. Of course, sage was already installed on my computer as well as texlive-full. First, I installed sagetex :

sage -i sagetex-2.0

Then, I created the folder ~/.texmf/tex (for *.sty files) and I edited the file /etc/texmf/texmf.cnf by replacing the line
Then, I copied the sagetex.sty :

cp sage-3.4/examples/latex_embed/sagetex.sty ~/.texmf/tex/

and I ran the command

sudo texhash

This allowed me to use sagetex from any repository without sagetex.sty inside. I found how to do it on the Ubuntu-fr forum.

Tuesday, January 20, 2009

Reinstall deleted or damaged files in Debian/Ubuntu

Suppose you delete or damage a system file named idoit.iam. To recover the file, do the following.

1. Locate the package which installed idoit.iam:

dpkg-query -S idiot.iam

Say the package name is idiotic. (It is possible that there is more than one package, especially if you deleted a directory. Replace the package name with all the package names in what follows.)

2. Try to reinstall the package:

apt-get --reinstall install idoitic

3. Check to see whether your file has been replaced. If so, then you are happy and owe me a beer . If not, then it must be a configuration file (the previous command will not restore configuration files). But all is not lost. Proceed.

4. Download the package without installing:

apt-get -d --reinstall install idiotic

(Technically you don't have to do this because the command in step 2 should have downloaded the packages already.)

5. Change to the directory containing the packages:

cd /var/cache/apt/archives/

6. Now install the packages using dpkg, but forcing it to reinstall the missing configuration files:

dpkg --install --force-confmiss idoitic

Now you should be happy , and still owe me a beer .

PS: Technically, I prefer a good glass of red wine over any beer, but there is no Google icon for wine.