1. TortoiseHg
  2. TortoiseHg
  3. thg
  4. Issues
Issue #484 closed

Can't update to any revision (SVN subrepo)

created an issue

Any attempt to update to any revision results in the following error:

% hg update --repository C:\MyRepo --verbose --config ui.merge=internal:fail --rev 1234 --check resolving manifests abort: The handle is invalid

Execution of that command in console works fine. I'm using version 2.0.2 of TortoiseHG and have one svn and one hg subrepositories.

Comments (20)

  1. Steve Borho

    My only guess is that the error is coming from subversion because the CWD is not within the repository folder.

    Does it work if you open 'thg log' from the command line inside the repository?

  2. John Schneiderman

    I got the same error as above, here is my trace:

    ** Mercurial version (1.8.3).  TortoiseHg version (2.0.4)
    ** Command: --nofork workbench
    ** CWD: C:\Projects\Reliant\AddProductCodes
    ** Extensions loaded: fixfrozenexts
    ** Python version: 2.6.6 (r266:84297, Aug 24 2010, 18:13:38) [MSC v.1500 64 bit (AMD64)]
    ** Windows version: (6, 1, 7601, 2, 'Service Pack 1')
    ** Processor architecture: x64
    ** Qt-4.7.1 PyQt-4.8.3
    Traceback (most recent call last):
      File "tortoisehg\hgqt\update.pyo", line 251, in update
      File "tortoisehg\hgqt\update.pyo", line 203, in isclean
      File "mercurial\subrepo.pyo", line 602, in dirty
      File "mercurial\subrepo.pyo", line 580, in _wcchanged
      File "mercurial\subrepo.pyo", line 546, in _svncommand
    Abort: svn: warning: 'C:\Projects\Reliant\AddProductCodes\'QtArgs' is not a working copy

    I have a repository with an svn sub-repository.

  3. Ed Brannin

    From the Mercurial bug comments:

    "That seems to be a TortoiseHg issue. Please file the issue there - unless you can reproduce with Mercurial. (But it seems like some configuration has some 'quotes' where it shouldn't.)"

    That matches my experience as well: I can't update or merge in my dotfiles repository from TortoiseHg, but I can do these things on the command-line.


  4. Ulf Larsson

    I ran into this problem when testing the subrepo feature with svn subrepositories. I got 'abort: handle is invalid' when trying to clone or update.

    With some primitive debug printing I was able to locate the 'handle is invalid' to the subprocess.Popen call in mercurial.subrepo.svnsubrepo._svncommand (corresponing code exists for git subrepo). And I think the problem is the same as reported in http://bugs.python.org/issue3905

    Using the workaround mentioned in the above bug report, to always call subprocess.Popen with stdin=subprocess.PIPE seems to help. I tested that by modifying code in mercurial.subrepo.

    The stdin=subprocess.PIPE is set if the condition: 'if not self._ui.interactive():' in _svncommand is true. Maybe it is possible to change the call from thg to ensure that. But I haven't figured out how to do it.

  5. Ulf Larsson

    The problem occurs when running commands from thread.QtUi which sets ui.interactive=on. Then subprocess.Popen will not be called with stdin=subprocess.PIPE and subprocess will use sys.stdin which is not a valid handle when using pythonw.

    A possible solution might be to set sys.stdin=None when running thg on windows with pythonw. A lot of console windows pops up and closes but the update command works from within tortoisehg.

  6. Max Calvin

    I recently started having this issue also, and have done a bit of playing around and found some things I wanted to report.

    The issue seems to only occur for me when launching thgw.exe directly, either from a pinned taskbar link or from the tortoisehg install folder (either through commandline or navigating in file explorer).

    If I run 'thg' from either the commandline or File Explorer, I can update just fine (even though I realise it just launches thgw.exe). If I open File Explorer, and right click on a folder and launch using the 'Hg Workbench' shell extension, I can update just fine.

    After I install a new version of tortoisehg, the pinned stuff works fine for a while. I believe after I reboot, it breaks again. Not tested this thoroughly.

    So my workaround (Caveate: Currently works for me, might not work for all, might not work for me for long...) When pinning it to the taskbar, go to your tortoisehg folder (likely: C:\program files\tortoisehg) and right click on thg.exe, and choose Pin to Taskbar. When using the link, it flashes up a console window before launching but at least it (seems to) update just fine. Never run or shortcut to thgw.exe directly.

    Not sure how helpful that is but hopefully it will help anyone else out who is having this problem, and may help debug the problem. My guess is something that is set in the OS environment for console apps that isn't for normal windows apps.

    Hope it helps!

  7. mckayerp

    I'm having similar problems as described in this and the duplicate issues.

    I'm using ADempiere on SourceForge with a main mercurial repository and two git sub-repositories. TortoiseHG give a terse Error 6: Handle is invalid on every refresh and won't update to a specific revision. The command line hg commands work well. On clicking browse at revision i received this more specific error:

    ** Mercurial version (2.7.2).  TortoiseHg version (2.9.2)
    ** Command: 
    ** CWD: C:\Windows\system32
    ** Encoding: cp1252
    ** Extensions loaded: hgflow, mq, transplant, purge
    ** 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=0, build=6001, platform=2, service_pack='Service Pack 1')
    ** Processor architecture: x86
    ** Qt-4.8.4 PyQt-4.10.2 QScintilla-2.7.2
    Traceback (most recent call last):
      File "tortoisehg\hgqt\repowidget.pyo", line 1849, in manifestRevision
      File "tortoisehg\hgqt\qtlib.pyo", line 1262, in open
      File "tortoisehg\hgqt\qtlib.pyo", line 1282, in _preparedlg
      File "tortoisehg\hgqt\qtlib.pyo", line 1285, in _populatedlg
      File "tortoisehg\hgqt\repowidget.pyo", line 120, in <lambda>
      File "tortoisehg\hgqt\repowidget.pyo", line 1853, in _createManifestDialog
      File "tortoisehg\hgqt\manifestdialog.pyo", line 35, in __init__
      File "tortoisehg\hgqt\manifestdialog.pyo", line 150, in __init__
      File "tortoisehg\hgqt\manifestmodel.pyo", line 183, in index
      File "tortoisehg\hgqt\manifestmodel.pyo", line 219, in _parententry
      File "tortoisehg\hgqt\manifestmodel.pyo", line 264, in _rootentry
      File "tortoisehg\hgqt\manifestmodel.pyo", line 390, in _newrootentry
      File "tortoisehg\hgqt\manifestmodel.pyo", line 368, in addrepocontentstotree
      File "tortoisehg\hgqt\thgrepo.pyo", line 793, in sub
      File "mercurial\context.pyo", line 357, in sub
      File "mercurial\subrepo.pyo", line 322, in subrepo
      File "mercurial\subrepo.pyo", line 1026, in __init__
      File "mercurial\subrepo.pyo", line 1031, in _ensuregit
      File "mercurial\subrepo.pyo", line 1071, in _gitnodir
      File "subprocess.pyo", line 672, in __init__
      File "subprocess.pyo", line 787, in _get_handles
      File "subprocess.pyo", line 826, in _make_inheritable
    WindowsError: [Error 6] The handle is invalid

    Is this something I can fix or is there still an issue with the application? It would be great to get this fixed as working around it is a pain.



  8. mckayerp

    Just upgraded to 2.11 and am still receiving the Error 6 Handle is invalid.

    ** Mercurial version (2.9).  TortoiseHg version (2.11)
    ** Command: 
    ** CWD: C:\Windows\system32
    ** Encoding: cp1252
    ** Extensions loaded: hgflow, strip, mq, transplant, purge
    ** Python version: 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)]
    ** Windows version: sys.getwindowsversion(major=6, minor=0, build=6001, platform=2, service_pack='Service Pack 1')
    ** Processor architecture: x86
    ** Qt-4.8.5 PyQt-4.10.3 QScintilla-2.7.2
    Traceback (most recent call last):
      File "tortoisehg\hgqt\manifestmodel.pyo", line 354, in fetchMore
      File "tortoisehg\hgqt\manifestmodel.pyo", line 407, in _populateNodes
      File "tortoisehg\hgqt\manifestmodel.pyo", line 577, in _populaterepo
      File "tortoisehg\hgqt\manifestmodel.pyo", line 606, in _populatesubrepos
      File "mercurial\subrepo.pyo", line 337, in itersubrepos
      File "tortoisehg\hgqt\thgrepo.pyo", line 837, in sub
      File "mercurial\context.pyo", line 169, in sub
      File "mercurial\subrepo.pyo", line 353, in subrepo
      File "mercurial\subrepo.pyo", line 1109, in __init__
      File "mercurial\subrepo.pyo", line 1114, in _ensuregit
      File "mercurial\subrepo.pyo", line 1154, in _gitnodir
      File "subprocess.pyo", line 701, in __init__
      File "subprocess.pyo", line 832, in _get_handles
      File "subprocess.pyo", line 883, in _make_inheritable
    WindowsError: [Error 6] The handle is invalid
  9. Yuya Nishihara

    cmdcore: enable command-server client by default in 3.1

    As I said in d02cfaed8676, CmdThread will be removed in 3.2.

    refs #1507 - "Stop button for pull hangs" should be fixed on Unix, but not on Windows due to the limitation of winsock.

    refs #3381 - "Locked folders/files on Windows" is partially solved since Mercurial commands are run in separate chdir-ed process.

    closes #484, #1661, #2071, #2614, #3343, #3370, #3637, #3670

    → <<cset 38985e4f9bd0>>

  10. Log in to comment