Cannot update embedded mercurial in Sourcetree
Asked by shaunmahoney:

Sourcetree 2.1.2.5

Windows 10 64 bit

Whenever I start Sourcetree, I get a warning dialogue about mercurial being out of date:

```
Your selected Mercurial is older than 3.7.3.The Mercurial team strongly encourages all users to upgrade to 3.7.3 or later due to a security vulnerability.You current configuration is Mercurial is 3.2.3.
```

In Tools-\>Options-\>Mercurial, I click on Update Embedded Mercurial.

It downloads something, then I get an error dialogue saying:

```
Failed to Extract7-Zip [32] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21Scanning the drive for archives:1 file, 8410583 bytes (8214 KiB)Extracting archive: C:\Users\xx\AppData\Local\Atlassian\SourceTree\PortableHg.7z--Path = C:\Users\xx\AppData\Local\Atlassian\SourceTree\PortableHg.7zType = 7zPhysical Size = 8410583Headers Size = 3362Method = LZMA2:24 BCJSolid = +Blocks = 2Sub items Errors: 2Archives with Errors: 1Sub items Errors: 2
```

Then under that, there is another dialogue that says:

```
Download not successfulDownload either failed or was cancelled, please try again later.
```

It did download though, so I don't know what that dialogue is all about.

How can I update the embedded mercurial in Sourcetree?


Answers:
author: minnsey
body: Hi  

Firstly SourceTree does not currently support Mercurial 4+, unfortunately it breaks some extensions we use. We have a fix in the works and hope to have it out to beta testers soon.  

Therefore the highest versions SourceTree will work with is 3.9.2. SourceTree should be able to work with a System install of 3.9.2  

<br />

Where there are problems updating the embedded Hg.  

EMbedded Hg is still using 3.7.3 and the following is the correct URL.

<https://downloads.atlassian.com/software/sourcetree/windows/PortableHg_3.7.3.7z>  

This should get downloaded to  
%localappdata%\\Atlassian\\SourceTree\\PortableHg.7z  
and then unzipped into  
%localappdata%\\Atlassian\\SourceTree\\hg_local  

If there are problmes downloading I can only assume there is a network connectivity issue getting to <https://downloads.atlassian.com> or perhaps a proxy on the network?  

It is possible the download has succeeded but unzipping has failed, possibly because a file is in use, in that case shutdwn SourceTree and delete the folder %localappdata%\\Atlassian\\SourceTree\\hg_local.  
When SourceTree restarts it shoudl re-install the embedded hg.

comments: author: shaunmahoney
body: Thanks for taking the time to reply Michael. Deleting the hg_local folder, re-open SourceTree, a pop-up comes up saying it can't find Mercurial, select the option Download an embedded version, and it now no longer continously displays the Mercurial version warning. The Mercurial version shows as 3.7.3 in Tools-\>Options. So that problem is solved.

Note that there were in fact no network problems or download issues as you suggest. I stated that in the original post, that it did download ok. So the error message that Sourcetree displays is incorrect. So you might want to open a bug report or something.

Also probably another bug report candidate for having to delete that folder to get the auto-update to work.

Alas, now when I select my repository, I get a popup saying something about not supporting hg-attic shelves anymore, then Sourcetree crashes.

Unfortunately, I cannot spend any more time on trying to get Sourcetree working. I'm using TortoiseHg and everything is fine.


author: Bernhard Kuepper
body: Hello Michael,

thanks for the solution of the download problem. I did the manual download and extract and I now have version 3.7.3.

Best regards,  
Bernhard


author: Franco Bucciarelli
body: Hello Michael,

I downloaded the files, but I don't have the hg_local folder.

Thanks,

Franco


author: Franco Bucciarelli
body: Hi Michael,

I have the Sourcetree v. 2.4.7.0 and in tools/options/mercurial tab I have Embedded Mercurial version 4.4.1, but I still get the error message.

Thanks and regards,

Franco![Screen Shot 01-26-18 at 02.41 PM.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/13397i8AFAEAA6F7F7FC29/image-size/large?v=v2&px=999 "Screen Shot 01-26-18 at 02.41 PM.PNG")

comments: author: minnsey
body: Hi  

Do you still get the error dialog after closing and restarting Sourcetree? If so it sounds like a bug, If Sourcetree reports version 4.4.1 in that tab then it is using that version.


author: Franco Bucciarelli
body: Hi Michael,

I don't get more the error dialog now.

Thanks for helping.

Regards,

Franco


author: Franco Bucciarelli
body: Hi Michael,

yes there is still a problem, thanks.

Do you know how I can upgrade Sourcetree from the existing program?

Regards,

Franco


author: minnsey
body: If this is still an issue please upgrade to Sourcetree 2.4.7.0 as this supports Mercurial 4.4.1.  

After upgrading you will still need to update the embedded version of Mercurial in the Tools/Options/Mercurial tab.


author: Ana Retamal
body: Hi! Can you try following the steps at [Upgrading Mercurial in SourceTree for Windows](https://confluence.atlassian.com/sourcetreekb/upgrading-git-mercurial-in-sourcetree-for-windows-695108075.html) (downloading the latest Mercurial version) and let us know if this worked for you?

Best regards,

Ana

comments: author: Bernhard Kuepper
body: Hi Ana, I have a similiar problem. I just updated from SourceTree 1.9 to 2.1.2.5 and tried to update the Embedded Mercurial. All I get is an error message

"Unable to extract C:\\...\\PortableHg.7z

Please check your SourceTree options.

System.Net.WebException: Unable to connect to the remote server  
System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 52.84.194.43:443"

SourceTree is trying to download from <https://downloads.atlassian.com/software/sourcetree/windows/PortableHg_3.7.3.7z>.

When I try to access this address in a web browser, I get:

"The requested URL /software/sourcetree/windows/PortableHg_3.7.3.7z. was not found on this server."

OS is Windows 7, 64-bit.

Thanks in advance,  
Bernhard


author: shaunmahoney
body: Thanks for the reply Ana. Unfortunately, attempting to Use System Mercurial does not work either. When I click that button, I simply get the Mercurial version warning dialogue again, and when I dismiss it, nothing happens. I seem to recall a folder location dialogue popping up for that in the past, but not now. I have Mercurial 4.1 installed from a TortoiseHg install, and that is included in my path.


Tags: mercurial