Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Mercurial need to talk to the server, to list outgoing (non-pushed) commits?

Tags:

dvcs

mercurial

When I type hg outgoing, I get a response like this:

comparing with ssh://server:1234/path/to/repo

and a delay while it communicates over the network.

Why is this network traffic necessary? Is there something fundamental about Mercurial which means it can't remember which commits have been pushed, and which haven't?

Is there an alternative command which can give me similar information without having to communicate over the network?

like image 465
Graham Borland Avatar asked Mar 12 '12 17:03

Graham Borland


1 Answers

As Mercurial is a distributed system, there are multiple ways for your changes to get from your local repo to the remote repo.

For example:

  • it is possible for someone to pull changes from you and then push those changes to the remote repo
  • you could actually just copy your local repo using whatever operating system you have and Mercurial would be totally unaware of that. You could then push the changes in this copy to the remote repo.

However, if you have Mercurial 2.1 or later you can use hg phase to determine which changesets have been pushed. Assuming you don't use hg phase to change the status of any changesets then the changesets with a phase of draft or secret have not been pushed and those with a phase of public have. Use

$ hg log -r "not public()"

to see unpublished changesets.

It won't catch the two examples I gave above but it will probably be good enough if you just want to know which changesets you have not pushed.

Look here or check hg help phases for instructions on how to work with phases.

like image 171
Steve Kaye Avatar answered Sep 30 '22 18:09

Steve Kaye