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
hgpullsvn
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.
vim archive.zip
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

$HOME/.sage/ipython/ipythonrc

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
HOMETEXMF = $HOME/texmf
by
HOMETEXMF = $HOME/.texmf
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.