[PATCH 10 of 10] Use hg addremove -s 90 instead of hg add followed by hg remove

Alexis S. L. Carvalho alexis at cecm.usp.br
Tue Mar 6 17:11:37 CST 2007


Thus spake jgoerzen at complete.org:
> # HG changeset patch
> # User John Goerzen <jgoerzen at complete.org>
> # Date 1173039151 21600
> # Node ID ed7d523601cde60a80d97cfb9e8a091f463c0a16
> # Parent  c1c221249db9bd715541a9a0d2d17cecdea38ef9
> Use hg addremove -s 90 instead of hg add followed by hg remove
> This way we stand a chance of detecting renames
> 
> diff --git a/contrib/darcs2hg.py b/contrib/darcs2hg.py
> --- a/contrib/darcs2hg.py
> +++ b/contrib/darcs2hg.py
> @@ -121,8 +121,7 @@ def hg_commit( hg_repo, text, author, da
>  	fd, tmpfile = tempfile.mkstemp(prefix="darcs2hg_")
>  	writefile(tmpfile, text)
>  	old_tip = hg_tip(hg_repo)
> -	cmd("hg add -X _darcs", hg_repo)
> -	cmd("hg remove -X _darcs --after", hg_repo)
> +        cmd("hg addremove -s 90 -X _darcs", hg_repo)
>          res = cmd(['hg', 'commit', '-l', tmpfile, '-u', author, '-d',
>                     str(date) + ' 0'], hg_repo)

BTW - it's possible to miss some changes here (but it's not something
that was introduced by this patch):

Mercurial saves in .hg/dirstate the size, permissions and mtime of every
tracked file.  If they haven't changed, it assumes the file contents
also haven't changed.

But you can fool hg if you execute something like

change file
commit
change file but keep size and permissions

within one second.

This is not something that happens during interactive use, but it can
bite you during scripted conversions.

I'm not sure how to fix this from the command line...

Alexis


More information about the Mercurial-devel mailing list