Reputation: 4528
I have a Mercurial (Hg) repository with 2 remotes, let's call them default
and upstream
.
I have pulled from both remotes and would like to know which commits/branches came from the remote called default
and which commits/branches came from the remote called upstream
. How do I achieve this in Hg?
Ideally I would like to use the hg log
command much like I use the git log --describe --all
command which I'm more familiar with.
Is there a template for the hg log
command that is equivalent to git log --describe
?
Note: I'm already aware of using hg out <remote>
to show me what set of commits is not available on the remote I'm interested in, but I was hoping for something a little more visual.
Upvotes: 1
Views: 693
Reputation: 97280
Without giant changes in standard HG-workflow (assumed in another extension, remotenames), in default style, you can add Remote Branches Extension to your Mercurial
Upvotes: 3
Reputation: 487775
I have pulled from both remotes and would like to know which commits/branches came from the remote called
default
and which commits/branches came from the remote calledupstream
. How do I achieve this in Hg?
In general, you can't. (But see below, and Lazy Badger's suggested extension.)
Git doesn't actually do this either. Nonetheless, you can, as you said:
... use the git log --describe --all command ...
This does not tell you who delivered the commits to you. Instead, it tells you which of your references is "closest" to the to-be-described commit ("closest" being defined in a vague handwave-y manner). What Git does, that Mercurial doesn't, is to create, in your repository, specific references—remote-tracking names like remote1/branch
and remote2/branch
—that remember which commit was identified by the name branch
on remote1 and remote2 respectively.
Provided that precisely one of the two remotes has those commits in the first place, only one such reference can be "closest". Git will choose that one, and from that, you can infer who has the commits and who does not. It fails, or can fail, if both remotes have the commits: you get an arbitrary reference (which may suffice anyway depending on your underlying goal).
Now, you can do something. Specifically, the issue in this case is that Mercurial's branch names are global, and commits are permanently glued to the branch on which they were made. If you connect to remote1 and receive some commits, they have whatever hash ID and branch name they have, and your Mercurial stores them in your repository under that same hash ID and using that same name—and now Mercurial (like Git) forgets the source, because those are now your commits.
But you do know that whatever commits just came in (if any) came from remote1, not remote2. Moreover, if any commits did come in, they will have increased the local revision ID number (-r -n tip
). You can save that new number—or even the entire span—somewhere. All of those commits in that span, "old tip + 1" to "new tip" inclusive, came from remote1.
Repeat this for remote2: any new commits that arrive came from them.
(There is another option, but it's drastic: you can use the Convert extension to change the branch names of commits as they come in. If you do this, though, you are stuck with those commits being on the other branch: you would have to copy, i.e., graft or rebase, the commits to move them to their original branches later, if you want that. There are additional, and better, extensions, but unlike Convert, they are not distributed with Mercurial.)
Upvotes: 1