On Fri, Oct 11, 2024, 10:39 AM Dmitry Gutov <dmitry@gutov.dev> wrote:
On 11/10/2024 04:34, Dmitry Gutov wrote:
> BTW:
>
> On 13/09/2024 23:54, Spencer Baugh wrote:
>> +(defun vc-git-pushed-revision (_file &optional remote-location)
>> +  "Return the ref for REMOTE-LOCATION."
>> +  (if (and remote-location (not (string-empty-p remote-location)))
>> +      remote-location
>> +    "@{upstream}"))
>
> The function above and the function below
>
> +(defun vc-hg-pushed-revision (_file &optional remote-location)
>> +  "Return a revspec for the last commit not outgoing to REMOTE-
>> LOCATION."
>> +  (unless remote-location
>> +    (setq remote-location ""))
>> +  (format "last(. and not outgoing(%s))" remote-location))
>
> ...seem to be describing different kinds of refs: I think the Hg version
> refers to the last commit from the current branch that's present in the
> remote (the merge base), whereas the Git version points to the tip of
> the remote branch.
>
> Which will be different if the remote has some newer changes added
> (perhaps someone else has pushed to it). vc-git-log-outgoing won't
> notice the difference because it uses the ".." range, but vc-git-diff
> compares two versions directly, so e.g. anything new added to the remote
> will be shown as removed in such diff.
>
> We probably want "merge base with remote" for Git as well (git merge-
> base @{upstream} HEAD), but it doesn't have a similar short ref syntax.
>
> Could use "merge-base(@{upstream})" or "@{upstream}.." as a special
> value, maybe.

Or alternatively if we would prefer to err on the side of warning the
user that the upstream has diverged, I suppose it's the Hg
implementation that would need to change. That can result a simpler
mental model and documentation as well. What would be Hg's corresponding
selector for "tip of upstream branch"?

I'm not sure, I don't think there's no way to specify that with an hg revset.  Though like most hg users, I don't actually use branches, I use bookmarks; there's a way to do it with bookmarks, I think. I'll investigate.

I think it's useful to think of these two options relative to vc-outgoing and vc-incoming.  Comparing $1 against $2 is equivalent to getting the diff from $3:
- working-tree merge-base = vc-outgoing
- merge-base remote-tip = vc-incoming
- working-tree remote-tip = vc-outgoing+vc-incoming

The first two are more useful than the third, I think, since the third mixes together two sorts of diffs, making it ambiguous which is which.