On 22 Dec 2022, at 19.28, 'Michael Forbes' via hg-git <
hg-...@googlegroups.com> wrote:
> That is what I expected, however, when I created the mercurial tags and then pushed to GitHub, the tags were not seen. (See
https://github.com/sphinx-contrib/zopeext/issues/6).
>
> Here is a MNWE:
>
> mkdir git-repo
> cd git-repo
> git init --bare
> cd ..
> hg clone git-repo hg-repo
> cd hg-repo
> touch A.txt
> hg add A.txt
> hg commit -m "A"
> hg bookmark main
> hg tag -r main 0.1
> hg tag -r main --git 0.2
> hg push -r .
> cd ../git-repo
> git tag
>
> Only the 0.2 tag shows.
>
> Maybe git tags are created but not pushed?
The culprit is the -r/--rev argument, it seems. You're pushing the commit that _created_ the tag rather than the tag itself. The coupling between names and commits is, generally speaking, much looser with Git than it is with Mercurial, so you can push a bunch of commits without pushing their names. Essentially, this is consistent with bookmarks where pushing a specific commit won't also push bookmarks on ancestor commits.
So, I think this is by design… the next question then becomes whether the design is correct 🙂
A slightly adjusted version:
+ rm -rf /tmp/xxx
+ mkdir -p /tmp/xxx
+ cd /tmp/xxx
+ mkdir git-repo
+ cd git-repo
+ git init --bare --quiet
+ cd ..
+ hg clone git-repo hg-repo
updating to branch default
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ cd hg-repo
+ touch A.txt
+ hg add A.txt
+ hg commit -m A
+ touch B.txt
+ hg add B.txt
+ hg commit -m B
+ hg bookmark -r 0 old-main
+ hg bookmark main
+ hg push -r .
pushing to /private/tmp/xxx/git-repo
searching for changes
adding objects
added 2 commits with 2 trees and 1 blobs
adding reference refs/heads/main
+ hg tag -r main 0.1
+ hg tag -r main --git 0.2
+ hg push -r .
pushing to /private/tmp/xxx/git-repo
searching for changes
adding objects
added 1 commits with 1 trees and 1 blobs
updating reference refs/heads/main
adding reference refs/tags/0.2
+ hg log -r . -r 0.1 --style=compact
2[0.2,default/main,tip][main] c5cef8296e5c 2022-12-22 20:04 +0100 danchr
Added tag 0.1 for changeset 5f7d63f46952
1[0.1] 5f7d63f46952 2022-12-22 20:04 +0100 danchr
B
+ cd ../git-repo
+ git tag
0.2
+ hg -R ../hg-repo push -r 0.1
pushing to /private/tmp/xxx/git-repo
searching for changes
adding reference refs/tags/0.1
+ git tag
0.1
0.2