Error while changing global settings

Issue #2430 duplicate
Michael Strelnikov
created an issue
** Mercurial version (2.4.2+20130203).  TortoiseHg version (2.7)
** Command: --nofork userconf
** CWD: C:\projects\test
** Encoding: cp1251
** Extensions loaded: 
** Python version: 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)]
** Windows version: sys.getwindowsversion(major=6, minor=1, build=7601, platform=2, service_pack='Service Pack 1')
** Processor architecture: x86
** Qt-4.8.4 PyQt-4.9.6 QScintilla-2.7
Traceback (most recent call last):
  File "tortoisehg\hgqt\settings.pyo", line 1151, in accept
  File "tortoisehg\hgqt\settings.pyo", line 1129, in applyChanges
  File "tortoisehg\hgqt\settings.pyo", line 1544, in applyChanges
  File "tortoisehg\util\wconfig.pyo", line 253, in writefile
  File "mercurial\util.pyo", line 826, in close
  File "mercurial\windows.pyo", line 284, in rename
WindowsError: [Error 32] The process cannot access the file because it is being used by another process

Comments (10)

  1. Michael Strelnikov reporter

    It is trying to get an access to files like ".hg/.hgrc-jyboda". The content of those files (and I have them a lot) is "# Generated by TortoiseHg settings dialog". After I choose "retry" the dialog closes and configuration saved. Also, there is nobody accessing those files - they created when I push "OK" button in the settings dialog.

  2. Yuya Nishihara

    Thanks. I guess some application (or TortoiseHg itself?) watches new file and locks it temporarily.

    If you click "OK" button, TortoiseHg

    1. saves settings to temporary file, e.g. ".hg/.hgrc-jyboda"
    2. then, renames it to ".hg/hgrc"

    If another process watches .hg folder and detects 1, it may lock temporary file. Since TortoiseHg tries to rename it immediately, "[Error 32]" occurs.

  3. Yuya Nishihara

    Not sure. You've already tried to disable virus scanner. I have no other idea.

    Temporary workaround may be inserting slight delay before rename():

    # ...
    import time
    def _rename(orig, src, dst):
        time.sleep(0.5)  # [sec]
        return orig(src, dst)
    # ...
  4. Log in to comment