"bzr commit" fails when BZR_EDITOR is emacsclient

Bug #673637 reported by Eli Zaretskii
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Bazaar
Fix Released
Medium
Vincent Ladeuil
GNU Emacs
Invalid
Undecided
Unassigned

Bug Description

When committing from Windows, "bzr commit" fails if EDITOR or BZR_EDITOR point to emacsclient. This happens because msgeditor.py creates the temporary log file in the directory where "bzr ci" is invoked, which is normally inside the branch. When you save the log message inside Emacs, Emacs runs "bzr status", because the log message file is in a versioned directory, and Emacs tries to get its revision and status, to show that in the modeline. But because "bzr ci" is still running, the branch is locked, and "bzr status" fails, this failing the commit.

John Arbash Meinel <email address hidden> suggested a simple patch below, which causes the log message file to be created in a temporary directory, outside of the branch. I'm running with it since January, and it works perfectly.

Is it possible to make this part of a future Bazaar release, please?

--- bzrlib/msgeditor.py~ 2010-09-29 21:26:57.600250000 +0200
+++ bzrlib/msgeditor.py 2010-09-29 21:29:15.678375000 +0200
@@ -225,9 +225,9 @@
     """
     import tempfile
     tmp_fileno, msgfilename = tempfile.mkstemp(prefix='bzr_log.',
- dir='.',
+# dir='.',
                                                text=True)
- msgfilename = osutils.basename(msgfilename)
+# msgfilename = osutils.basename(msgfilename)
     msgfile = os.fdopen(tmp_fileno, 'w')
     try:
         if start_message is not None:

Related branches

Revision history for this message
Vincent Ladeuil (vila) wrote :

Thanks for the detailed analysis, yes, the proposed patch sounds like a good plan, I'll make a merge proposal for it.

I use dvc, so I've never encountered the problem. If I want to reproduce it, will disabling dvc be enough or do you have some additional setup (in addition to setting EDITOR to emacsclient) ?

Changed in bzr:
assignee: nobody → Vincent Ladeuil (vila)
importance: Undecided → Medium
status: New → Confirmed
Revision history for this message
Vincent Ladeuil (vila) wrote :

I don't think anything needs to be fixed in emacs so I'll mark this as Invalid, feel free to re-open if I'm wrong.

We use the affects-emacs tag for bzr bugs that affect emacs, you don't have to create a specific bug task for that (yes, the column name *is* 'affects' and you added a 'GNU Emacs' line... that's confusing :-/)

Changed in emacs:
status: New → Invalid
tags: added: affects-emacs
Revision history for this message
Eli Zaretskii (eliz) wrote :

No additional setup is required except setting EDITOR or BZR_EDITOR to point to emacsclient. Please note that the problem only happens on Windows (because the OS does not let bzr access the lock that is held by another instance of bzr). I never saw this on GNU/Linux.

You are right that Emacs does not need to be changed, I was just confused by the "Affects" link on the bug-reporting page.

Revision history for this message
Eli Zaretskii (eliz) wrote :

Just in case it wasn't clear: after pointing EDITOR to emacsclient, commit from the shell prompt, not from within Emacs. Therefore, I think you shouldn't even need to disable dvc, because Emacs will not know that it's being used in conjunction with a VCS.

Revision history for this message
Vincent Ladeuil (vila) wrote :

@Eli, thanks for the clarifications, digging a bit I think *I* disabled vc-bzr ages ago which explain why I can't see the behavior:
;; Disable vc-bzr
(eval-after-load 'vc-bzr
  (setq vc-handled-backends (delq 'Bzr vc-handled-backends)))

Annotations say that I did this 3 years ago because vc-bzr was too slow at the time (probably vc-bzr + bzr, I'm not throwing stones nor pointing fingers) and then I totally forgot about it, time to remove this (done :-/).

Changed in bzr:
status: Confirmed → In Progress
Vincent Ladeuil (vila)
Changed in bzr:
milestone: none → 2.3b4
Vincent Ladeuil (vila)
Changed in bzr:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.