[patch]bug 32054 if commit fails commit message draft is lost

Martin Pool mbp at canonical.com
Thu Oct 19 06:18:09 BST 2006


On 19 Oct 2006, Cheuksan Edward Wang <wang02139 at gmail.com> wrote:
> I have modified the code and tests according to your comments except the
> 'replace' part. The changeset is attached. I'll see what I can do with 5798.

Thankyou.

+1 with comments, taking 

> -        
> +
> +        # save the commit message and only unlink it if the commit was
> +        # successful
> +        try:
> +            tmp_fileno, msgfilename = tempfile.mkstemp(prefix='bzr-commit-',
> +                                                       dir=tree.basedir)
> +            os.close(tmp_fileno)
> +        except OSError:
> +            try:
> +                # No access to working dir, try $TMP
> +                tmp_fileno, msgfilename= tempfile.mkstemp(prefix='bzr-commit-')
> +                os.close(tmp_fileno)
> +            except:
> +                # We can't create a temp file, try to work without it
> +                msgfilename = None
> +        if msgfilename is not None:
> +            msgfile = open(msgfilename, "wt")
> +            try:
> +                msgfile.write(message.encode(bzrlib.user_encoding, 'replace'))
> +            finally:
> +                msgfile.close()
> +

This is large enough and self-contained enough that it should be in a
separate method.  If someone else approves it I'll fix that and merge.


-- 
Martin




More information about the bazaar mailing list