[Python-Dev] I am now lost - committed, pulled, merged, what is "collapse"?

Ned Deily nad at acm.org
Sun Mar 20 02:59:43 CET 2011


In article 
<AANLkTiktVXSRMLW0Z8iFVZ3LkAEDV8vui_A4f-OciXcU at mail.gmail.com>,
 Nick Coghlan <ncoghlan at gmail.com> wrote:
> Mercurial isn't really all that different, but it's distributed nature
> means it want to keep track of even minor things like the local
> whitespace fixes and the merger of your changes with the other changes
> that were pushed since you started work. So the example above becomes
> something like:
> 
> hg pull -u
> #change stuff
> hg commit -m "Whatever"
> hg push
> # get rejected by server side hooks (e.g. changed files, bad whitespace)
> make patchcheck
> hg commit -m "Fix whitespace"
> hg pull -u
> hg merge
> # Resolve any conflicts, rerun relevant tests
> hg commit -m "Merge with remote"
> hg push

As a side note, if you are prone to accidentally adding extra whitespace 
(like I am), you can add the whitespace check hook into your local copy 
of Mercurial so that you will be warned about whitespace problems 
immediately when you commit things to your local repos rather than later 
when you try to push them up to the python.org repo.  You will need to 
add checkwhitsepace.py and reindent.py from the official hooks repo into 
the site-packages directory of the Python instance where your copy of hg 
is installed and then configure the hook in an hgrc configuration file. 

On a Unix-y system, here is one way to do it (no warranty on the 
installation instructions!):

# try to avoid permission problems
umask 022
hg clone http://hg.python.org/hooks
cd hooks
# make a dummy setup.py file for distutils
cat >setup.py <<EOF1
from distutils.core import setup
setup(name='pydevhooks',
      version='0.1',
      py_modules=['checkwhitespace', 'reindent'],
      )
EOF1
# kludge to find the Python instance which your hg uses
HGPYTHON=$(head -1 $(which hg) | sed s'/#!//')
echo $HGPYTHON
# install the hooks 
sudo  $HGPYTHON setup.py install
#  configure the hooks in your global .hgrc file -> affects all hg repos
HGRC=~/.hgrc
#  ... or configure in specific repos
#HGRC=/path/to/your_repo/.hg/hgrc
cat >>$HGRC <<EOF2

[hooks]
pretxncommit.whitespace = python:checkwhitespace.check_whitespace_single
EOF2

-- 
 Ned Deily,
 nad at acm.org



More information about the Python-Dev mailing list