[PATCH 1 of 3] Import darcs tags
Thomas Arendsen Hein
thomas at intevation.de
Sun Feb 25 11:31:17 UTC 2007
Hi!
Please send patches to the development list:
mercurial-devel at selenic.com
Some comments:
* Guy Brand <gb at isis.u-strasbg.fr> [20070224 20:21]:
> # HG changeset patch
> # User Guy Brand <gb at isis.u-strasbg.fr>
> # Date 1171321437 -3600
> # Node ID 9028722e609686fcf7a7675b4a1dd294b092dcfe
> # Parent 97251938485365716a52aebb013d271ba5f55e68
> Import darcs tags
>
> diff -r 972519384853 -r 9028722e6096 contrib/darcs2hg.py
> --- a/contrib/darcs2hg.py Fri Feb 23 14:16:50 2007 -0600
> +++ b/contrib/darcs2hg.py Tue Feb 13 00:03:57 2007 +0100
> if res.strip().lower().find("nothing changed") != -1:
> + print "Nothing to commit\n"
> pass
This is an unrelated change (and "pass" isn't needed anymore then)
> +def hg_tag( hg_repo, text, author, date ):
> + old_tip = hg_tip(hg_repo)
> + text = text.strip()
> + tag_file = hg_repo + "/.hgtags"
old_tip and tag_file are unused?
> + res = cmd("hg tags", hg_repo, silent=True)
> + (dead_text,hit) = re.subn(text,'',res)
It is good to have a space after ",".
> + if hit == 0:
> + cmd("hg tag -u \"%s\" -d \"%s 0\" \"%s\"" % (author, date, text), hg_repo)
You can use single quotes so you don't need to escape double quotes.
Besides that there is a high chance that this breaks if variables
contain quotes. But as darcs2hg uses this call everywhere, this can
be improved in a separate change, e.g. by using commands.dispatch()
> + (text,hit) = re.subn('^TAG ','',text)
Using text.startswith('TAG ') and text.split(' ', 1) might be
better. Remember a quote from Jamie Zawinski on comp.lang.emacs:
Some people, when confronted with a problem, think "I know, I'll use
regular expressions." Now they have two problems.
Thomas
--
thomas at intevation.de - http://intevation.de/~thomas/ - OpenPGP key: 0x5816791A
Intevation GmbH, Osnabrück - Registereintrag: Amtsgericht Osnabrück, HR B 18998
Geschäftsführer: Frank Koormann, Bernhard Reiter, Dr. Jan-Oliver Wagner
More information about the Mercurial
mailing list