Problems using import_

Didly didlybom at gmail.com
Wed Nov 16 01:02:35 CST 2011


On Wed, Nov 16, 2011 at 6:35 AM, Peer Sommerlund
<peer.sommerlund at gmail.com> wrote:
> Hi list
> I'm working on pfinish for the pbranch extension. This command compiles a
> patch from a branch, places it in a file, and calls the mercurial import
> command. This works fine, except if the patch is empty.
> This is my code:
>         # Commit patch to dependency
>         try:
>             fd, patch_file_name = tempfile.mkstemp(prefix='hg-patch-')
>             patch_file = os.fdopen(fd, 'w')
>             patch_file.writelines(graph.diff(patch_name, [], opts))
>             patch_file.close()
>             upstream_branch = graph.deps(patch_name)[0]
>             commands.update(ui, repo, rev=upstream_branch)
>             # BUG: import cannot apply an empty patch
>             ui.status(_('importing patch branch %s\n') % patch_name)
>             commands.import_(ui, repo, patch_file_name, base='', strip=1)
>         finally:
>             os.unlink(patch_file_name)
> An empty patch file could look like this
> # HG changeset patch
> # User Peer Sommerlund <peso at users.sourceforge.net>
> # Date 1321168004 -3600
>
> In case a patch is empty the finally os.unlink command will fail with
> message "file in use by another process". I'm on Windows 7.
> If I scan mercurial/commands.py [cset f8a0c7925496] I find
> 3583:  raise util.Abort(_('no diffs found'))
> which seems to cause the problem. If I uncomment this line the problem
> disappears.
> I guess this has something to do with the url.open() call in import_ that
> somehow opens a file, but I cannot figure out where the file is closed.
> Is this a bug in import_ or am I doing something wong?
> Is there another way to import a patch file I should use instead?
> Regards,
> Peer

I don't know if this is the same issue, but I see very similar errors
when using MQ (via TortoiseHg) on Windows 7. I often get this "file in
use by another process" message, even though the MQ operations seem to
work fine.

Angel


More information about the Mercurial-devel mailing list