Showing posts with label mercurial. Show all posts
Showing posts with label mercurial. Show all posts

Wednesday, June 7, 2017

Is there a way to tell mercurial 'delete all files that are deleted in local' during a merge?

Leave a Comment

I've been assigned the task to do a huge merge, ~1500 commits, on a mercurial project.

In the local fork we have deleted about ~200 files, right now I need to press d and enter for each file:

remote changed file/that/is/deleted/in/local which local deleted use (c)hanged version or leave (d)eleted? 

Is there a way to tell mercurial to choose to delete all those files?

4 Answers

Answers 1

Are you on a Unix-like system? If so, this command will automate answering "d" to all questions. That's what it's for. (Will only work if there are no other issues requesting manual intervention, of course.)

yes d | hg merge ... 

If you're not, you could implement it yourself :-) E.g.,

perl -e "for (;1;) { print \"d\n\"; }" | hg merge ... 

Or write a Windows batch file with an infinite loop (etc.)

YES.BAT | hg merge ... 

Answers 2

since you are on windows, try using tortoise https://tortoisehg.bitbucket.io/

add your project. then your working directory, you will be able to see the files affected, you can then

Answers 3

You deleted them on local? You can't just do an hg addremove? If they changed after removal, but before pushing I think you are out of luck :(

Answers 4

Wouldn't

hg merge ... --tool internal:local 

work?

Read More

Saturday, April 16, 2016

TotoiseHG: An existing connection was forcibly closed by the remote host

Leave a Comment

I wanted to push a project from from TortoiseHg to GitHub. I know that, TortoiseHg is a front-end to the Mercurial distributed version control system; where GitHub works with Git. But I love to use TortoiseHg (instead of TortoiseGit or GitGui), and want to keep my project in GitHub.

So, I configured TortoiseHg (File>Settings>Extensions>hggit) and was able to push a test project to GitHub (following this wonderful blog). But later when I tried to push a C# MVC project with it, situation changed. It nicely starts pushing, then asks for authentication, & then shows this error-

An existing connection was forcibly closed by the remote host

Here is what shown in the log-

% hg push git+https://github.com/MinhasKamal/MVCPracticeWork pushing to git+https://github.com/MinhasKamal/MVCPracticeWork http authorization required for https://github.com/MinhasKamal/MVCPracticeWork/info/refs realm: GitHub searching for changes adding objects URLError: [Errno 10054] An existing connection was forcibly closed by the remote host [command returned code 255 Thu Feb 04 16:17:02 2016] 

I don't understand- why this error is happening. Is this a problem of GitHub or TortoiseHG, or I did something wrong? How it can be solved?


Edit 1: I am able to push to the repository but only by 'not adding' some specific directories to my repository. Is it any file type or name that is making this error?


Edit 2: The problem again happened with me, this time with a Java project. Everything was fine, till I added a *.jar file in the repository. I made a commit, but when I tried to push it to the GitHub, TortoiseHg showed me the same message. I removed the *.jar, committed, and tried to push again, but couldn't.

Now, I did again that I did before (Edit 1)- I pulled the whole repository from GitHub to another folder, replaced changed files from the current repository at my PC (did not add the *.jar), committed, and pushed; I was successful this time. So, this time the *jar file was not added to the version control database, that is why it worked.

2 Answers

Answers 1

  • I can't see any pushes to MinhasKamal/MVCPracticeWork: This repository is empty.
  • You can automate pushing process (no handwork, no timeouts, no input errors) using [auth] section in .hgrc of this repo (define username and password in it)
  • At least some initial test-pushes will be better to perform in pure CLI (more informative and readable output)

Answers 2

There is a problem with Github if you trying to add a super large file into any repo. Even though i don't know if that's your problem.

I had a change to commit with both HG and Git on my Mac and try to push it to github. Git shown me the file is too large message when I ran git push but HG only shown me push failed.

If your .jar or any of the file you added cause the problem, you can check if the file size excess the limit (from github) and this one

Read More

Monday, March 14, 2016

Network is unreachable for hg clone

Leave a Comment

Autoproxy was installed on my firefox,and every web can be browsed via socket5 proxy service after buying vps service.

apt-get install mercurial  #on my local pc hg clone https://vim.googlecode.com/hg/   /tmp/vim  #on my local pc abort: error: Network is unreachable 

https://vim.googlecode.com/hg/ can be visited via autoproxy in Firefox.
How to build some kind of proxy service on my remote VPS to make the hg clone command to reach https://vim.googlecode.com/hg/?

Not all webs can be visited here, I have build a ladder to reach them via Firefox.

How to make another ladder on my VPS (on the remote PC) to make the hg clone command run on my local PC?

Every time I make the ladder with my VPS and Firefox this way:

  1. To input ssh command in my local pc

    ssh -D 127.0.0.1:1080  -p 1234 root@44.44.44.44 
  2. Click the Autoproxy plugin into Global mode. It was set in good status in Socket 5 proxy.

  3. Now i can visit what I want to visit.

How to write the hg clone command?

2 Answers

Answers 1

To use proxy for Mercurial you can prefix your command with http_proxy:

http_proxy=http://proxy-server:8080 hg clone https://vim.googlecode.com/hg 

Or configure in your ~/.hgrc as:

[http_proxy] host=proxy-host:port user=username passwd=password 

Since you're using a SOCKS5 proxy, this is not yet supported by Mercurial (3.7.2 at time of writing), however there is an extension for it based on the patch below.

Extension

You can download a small extension for the Mercurial DVCS to enable the use of a SOCKS5 proxy: https://bitbucket.org/bugheisen/socks_proxy

So can configure your proxy in your ~/.hgrc as:

[extensions] socks_proxy = /path/to/socks_proxy.py  [socks_proxy] host = localhost:9150 

To experiment with a SOCKS5 proxy you can use the -D option of SSH, which creates such a proxy that runs over the SSH connection. Alternatively you can run Tor, which also starts a SOCKS5 proxy (probably either on port 9050 or port 9150).

Patch

The above extension is based on the original patch posted by Bug Heisen and you can apply by downloading the source code of Mercurial and applying this patch based on the code below:

diff -r 12f161f08d74 -r 3f58227755ed mercurial/url.py --- a/mercurial/url.py  Tue Apr 01 23:41:32 2014 -0700 +++ b/mercurial/url.py  Sun Apr 06 16:16:02 2014 +0200 @@ -63,6 +63,44 @@   class proxyhandler(urllib2.ProxyHandler):      def __init__(self, ui): + +        # First, check if a SOCKS5 proxy is set, using a line 'host = ...' in  +        # the [socks_proxy] section of the config file. + +        proxyurl = ui.config("socks_proxy", "host") + +        if proxyurl: +            idx = proxyurl.find(":") +            if idx < 0: +                raise util.Abort(_("host in socks_proxy should be " +                                   "hostname:port")) + +            host = proxyurl[:idx] +            portstr = proxyurl[idx+1:] +            try: +                port = int(portstr) +            except ValueError: +                raise util.Abort(_("Cannot interpret '%s' in the socks_proxy " +                                   "host line as an integer port number")  +                                   % portstr) + +            if port <= 0 or port > 65535: +                raise util.Abort(_("Port number in socks_proxy host line " +                                   "must lie between 1 and 65535, but is " +                                   "%d") % port) + +            ui.note("Setting SOCKS5 proxy to %s:%d\n" % (host, port)) +                     +            try: +                import socks +                socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, host, port) +                socket.socket = socks.socksocket +            except ImportError: +                raise util.Abort(_("The SocksiPy socks module is needed for " +                                   "SOCKS support")) + +        # Then check for a http/https proxy +                  proxyurl = ui.config("http_proxy", "host") or os.getenv('http_proxy')          # XXX proxyauthinfo = None 

then in your ~/.hgrc use socks_proxy instead of http_proxy (as shown above).

Original notes regarding this patch:

This patch adds support for a SOCKS5 proxy, using the 'socks' module from the SocksiPy projects (needs to be installed separately). Because it is the 'proxyhandler' function that is modified, it will only work for HTTP/HTTPS protocols. For the SSH protocol, using a SOCKS proxy can easily be done outside of Mercurial, by specifying the ProxyCommand option.

The patch has the SOCKS5 version hardcoded in it, but the socks module should support other versions as well. So other SOCKS versions are possible in the same way, but the code would require modification to support them.

For testing purposes, it's good to know that SSH can create a SOCKS5 proxy using the -D command line flag. Using Tor also generates such a proxy, typically either on port 9050 or 9150.

Answers 2

I suggest to start with configuring the proxy settings for your local mercurial instance. Check hg help config and look for proxy there.

"http_proxy" ------------  Used to access web-based Mercurial repositories through a HTTP proxy.  "host"     Host name and (optional) port of the proxy server, for example     "myproxy:8000".  "no"     Optional. Comma-separated list of host names that should bypass the     proxy.  "passwd"     Optional. Password zur Authentifikation mit einem Proxy-Server.  "user"     Optional. User name to authenticate with at the proxy server.  "always"     Optional. Always use the proxy, even for localhost and any entries in     "http_proxy.no". (default: False) 
Read More