topics vs bookmarks and hg-git

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

topics vs bookmarks and hg-git

Ernie Rael-2
Can (should) I use topics, instead of bookmarks, with hg-git and github?

-ernie

_______________________________________________
Mercurial mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial
Reply | Threaded
Open this post in threaded view
|

Re: topics vs bookmarks and hg-git

Manuel Jacob
Bookmarks work best with hg-git, as they can be easily mapped to Git
refs and back.

Mapping topics to Git refs ("Git branches") is possible by restricting
each topic to have a single head and assigning a Git ref to each topic
head. Mapping Git refs back to topics is not possible in general, as Git
refs refer a single commit while the topic name is on all changesets in
the topic.

If you use hg-git only for syncing from Mercurial to Git, but not the
other way, you’ll find a not yet merged feature useful.

You can find it in the `export-additional-refs` topic of the hg-git
repository. There’s no documentaion so far, but see the test case:

https://foss.heptapod.net/mercurial/hg-git/-/merge_requests/8/diffs?commit_id=7e2344def8a4f18aca8b4d49d45ad85c584136d5#diff-content-6af25606bfd4c7217ddbb5a602fab0c84988a0fa

The following configuration will export all topic heads to Git branches
with the name of the topic:

[git]
export-additional-refs.named-branch-heads:revset = head() and topic()
export-additional-refs.named-branch-heads:template = refs/heads/{topic}

With this configuration, if you push from Mercurial to Git and then pull
from Git to Mercurial, all the topic heads will have a bookmark with the
name of the topic, which is a mess of course. You could work around that
by modifying the template to give them a different Git ref to avoid the
naming clash, or add a hook removing the bookmarks, but then you won’t
see if the Git side was updated.

On 2020-07-29 01:14, Ernie Rael wrote:
> Can (should) I use topics, instead of bookmarks, with hg-git and
> github?
>
> -ernie
>
> _______________________________________________
> Mercurial mailing list
> [hidden email]
> https://www.mercurial-scm.org/mailman/listinfo/mercurial
_______________________________________________
Mercurial mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial
Reply | Threaded
Open this post in threaded view
|

Re: topics vs bookmarks and hg-git

Uwe Brauer
>>> "MJ" == Manuel Jacob <[hidden email]> writes:

   > Bookmarks work best with hg-git, as they can be easily mapped to Git
   > refs and back.


   > The following configuration will export all topic heads to Git
   > branches with the name of the topic:

   > [git]
   > export-additional-refs.named-branch-heads:revset = head() and topic()
   > export-additional-refs.named-branch-heads:template = refs/heads/{topic}




   > With this configuration, if you push from Mercurial to Git and then
   > pull from Git to Mercurial, all the topic heads will have a bookmark
   > with the name of the topic, which is a mess of course. You could work
   > around that by modifying the template to give them a different Git ref
   > to avoid the naming clash, or add a hook removing the bookmarks, but
   > then you won’t see if the Git side was updated.

I am one of the hg-git users, who uses topics and named branches and has
to deal with git repositories.


I find the following configuration more useful (tested in bitbucket, where everybody
used mercurial+hg-git and tested in sourceforge, where everybody besides
me uses git). In the above configuration git users will see a git branch
called default, which they might find confusing.

export-additional-refs.named-branch-heads:revset   = head() and not  branch('re:\Adefault\Z')
export-additional-refs.named-branch-heads:template = refs/heads/{branch}|{topic}

As Manual said, the problem is pulling from new commits of git users,
you will obtain bookmarks with the same name as the topics/named_branch

Uwe Brauer

   > On 2020-07-29 01:14, Ernie Rael wrote:
   >> Can (should) I use topics, instead of bookmarks, with hg-git and
   >> github?
   >> -ernie
   >> _______________________________________________
   >> Mercurial mailing list
   >> [hidden email]
   >> https://www.mercurial-scm.org/mailman/listinfo/mercurial
   > _______________________________________________
   > Mercurial mailing list
   > [hidden email]
   > https://www.mercurial-scm.org/mailman/listinfo/mercurial


_______________________________________________
Mercurial mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial

smime.p7s (7K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: topics vs bookmarks and hg-git

Manuel Jacob
On 2020-07-29 09:03, Uwe Brauer wrote:

>>>> "MJ" == Manuel Jacob <[hidden email]> writes:
>
>    > Bookmarks work best with hg-git, as they can be easily mapped to
> Git
>    > refs and back.
>
>
>    > The following configuration will export all topic heads to Git
>    > branches with the name of the topic:
>
>    > [git]
>    > export-additional-refs.named-branch-heads:revset = head() and
> topic()
>    > export-additional-refs.named-branch-heads:template =
> refs/heads/{topic}
>
>
>
>
>    > With this configuration, if you push from Mercurial to Git and
> then
>    > pull from Git to Mercurial, all the topic heads will have a
> bookmark
>    > with the name of the topic, which is a mess of course. You could
> work
>    > around that by modifying the template to give them a different Git
> ref
>    > to avoid the naming clash, or add a hook removing the bookmarks,
> but
>    > then you won’t see if the Git side was updated.
>
> I am one of the hg-git users, who uses topics and named branches and
> has
> to deal with git repositories.
>
>
> I find the following configuration more useful (tested in bitbucket,
> where everybody
> used mercurial+hg-git and tested in sourceforge, where everybody
> besides
> me uses git). In the above configuration git users will see a git
> branch
> called default, which they might find confusing.

That doesn’t happen with the above configuration, as only heads with
some topic are considered and the branch name doesn’t appear in the
template.

But when including the branch name in the template, you may want to
exclude it in the revset and add another revset/template pair to map the
default branch to "master" / "main" / something else.

> export-additional-refs.named-branch-heads:revset   = head() and not
> branch('re:\Adefault\Z')
> export-additional-refs.named-branch-heads:template =
> refs/heads/{branch}|{topic}
>
> As Manual said, the problem is pulling from new commits of git users,
> you will obtain bookmarks with the same name as the topics/named_branch
>
> Uwe Brauer
>
>    > On 2020-07-29 01:14, Ernie Rael wrote:
>    >> Can (should) I use topics, instead of bookmarks, with hg-git and
>    >> github?
>    >> -ernie
>    >> _______________________________________________
>    >> Mercurial mailing list
>    >> [hidden email]
>    >> https://www.mercurial-scm.org/mailman/listinfo/mercurial
>    > _______________________________________________
>    > Mercurial mailing list
>    > [hidden email]
>    > https://www.mercurial-scm.org/mailman/listinfo/mercurial
>
>
> _______________________________________________
> Mercurial mailing list
> [hidden email]
> https://www.mercurial-scm.org/mailman/listinfo/mercurial
_______________________________________________
Mercurial mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial
Reply | Threaded
Open this post in threaded view
|

Re: topics vs bookmarks and hg-git

Manuel Jacob
In reply to this post by Manuel Jacob
On 2020-07-29 06:06, Manuel Jacob wrote:

> Bookmarks work best with hg-git, as they can be easily mapped to Git
> refs and back.
>
> Mapping topics to Git refs ("Git branches") is possible by restricting
> each topic to have a single head and assigning a Git ref to each topic
> head. Mapping Git refs back to topics is not possible in general, as
> Git refs refer a single commit while the topic name is on all
> changesets in the topic.
>
> If you use hg-git only for syncing from Mercurial to Git, but not the
> other way, you’ll find a not yet merged feature useful.
>
> You can find it in the `export-additional-refs` topic of the hg-git
> repository. There’s no documentaion so far, but see the test case:
>
> https://foss.heptapod.net/mercurial/hg-git/-/merge_requests/8/diffs?commit_id=7e2344def8a4f18aca8b4d49d45ad85c584136d5#diff-content-6af25606bfd4c7217ddbb5a602fab0c84988a0fa
>
> The following configuration will export all topic heads to Git
> branches with the name of the topic:
>
> [git]
> export-additional-refs.named-branch-heads:revset = head() and topic()
> export-additional-refs.named-branch-heads:template = refs/heads/{topic}

Oops, I left the "named-branch-heads" from where I copied the two lines.
The name between the "export-additional-refs." and ":..." can be chosen
freely. Multiple revset/template pairs can be added when using different
names.

> With this configuration, if you push from Mercurial to Git and then
> pull from Git to Mercurial, all the topic heads will have a bookmark
> with the name of the topic, which is a mess of course. You could work
> around that by modifying the template to give them a different Git ref
> to avoid the naming clash, or add a hook removing the bookmarks, but
> then you won’t see if the Git side was updated.
>
> On 2020-07-29 01:14, Ernie Rael wrote:
>> Can (should) I use topics, instead of bookmarks, with hg-git and
>> github?
>>
>> -ernie
>>
>> _______________________________________________
>> Mercurial mailing list
>> [hidden email]
>> https://www.mercurial-scm.org/mailman/listinfo/mercurial
> _______________________________________________
> Mercurial mailing list
> [hidden email]
> https://www.mercurial-scm.org/mailman/listinfo/mercurial
_______________________________________________
Mercurial mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial
Reply | Threaded
Open this post in threaded view
|

Re: topics vs bookmarks and hg-git

Manuel Jacob
In reply to this post by Manuel Jacob
On 2020-07-29 10:51, Manuel Jacob wrote:

> On 2020-07-29 09:03, Uwe Brauer wrote:
>>>>> "MJ" == Manuel Jacob <[hidden email]> writes:
>>
>>    > Bookmarks work best with hg-git, as they can be easily mapped to
>> Git
>>    > refs and back.
>>
>>
>>    > The following configuration will export all topic heads to Git
>>    > branches with the name of the topic:
>>
>>    > [git]
>>    > export-additional-refs.named-branch-heads:revset = head() and
>> topic()
>>    > export-additional-refs.named-branch-heads:template =
>> refs/heads/{topic}
>>
>>
>>
>>
>>    > With this configuration, if you push from Mercurial to Git and
>> then
>>    > pull from Git to Mercurial, all the topic heads will have a
>> bookmark
>>    > with the name of the topic, which is a mess of course. You could
>> work
>>    > around that by modifying the template to give them a different
>> Git ref
>>    > to avoid the naming clash, or add a hook removing the bookmarks,
>> but
>>    > then you won’t see if the Git side was updated.
>>
>> I am one of the hg-git users, who uses topics and named branches and
>> has
>> to deal with git repositories.
>>
>>
>> I find the following configuration more useful (tested in bitbucket,
>> where everybody
>> used mercurial+hg-git and tested in sourceforge, where everybody
>> besides
>> me uses git). In the above configuration git users will see a git
>> branch
>> called default, which they might find confusing.
>
> That doesn’t happen with the above configuration, as only heads with
> some topic are considered and the branch name doesn’t appear in the
> template.
>
> But when including the branch name in the template, you may want to
> exclude it in the revset and add another revset/template pair to map
> the default branch to "master" / "main" / something else.

Here: "it" = "the default branch". Sorry for the confusion.

To clarify: use `and not branch('re:\Adefault\Z')` if you want to
exclude the default branch. However, this would also exclude all topics
within the default branch, so it probably won’t be useful for Ernie’s
original question.

>> export-additional-refs.named-branch-heads:revset   = head() and not
>> branch('re:\Adefault\Z')
>> export-additional-refs.named-branch-heads:template =
>> refs/heads/{branch}|{topic}
>>
>> As Manual said, the problem is pulling from new commits of git users,
>> you will obtain bookmarks with the same name as the
>> topics/named_branch
>>
>> Uwe Brauer
>>
>>    > On 2020-07-29 01:14, Ernie Rael wrote:
>>    >> Can (should) I use topics, instead of bookmarks, with hg-git and
>>    >> github?
>>    >> -ernie
>>    >> _______________________________________________
>>    >> Mercurial mailing list
>>    >> [hidden email]
>>    >> https://www.mercurial-scm.org/mailman/listinfo/mercurial
>>    > _______________________________________________
>>    > Mercurial mailing list
>>    > [hidden email]
>>    > https://www.mercurial-scm.org/mailman/listinfo/mercurial
>>
>>
>> _______________________________________________
>> Mercurial mailing list
>> [hidden email]
>> https://www.mercurial-scm.org/mailman/listinfo/mercurial
> _______________________________________________
> Mercurial mailing list
> [hidden email]
> https://www.mercurial-scm.org/mailman/listinfo/mercurial
_______________________________________________
Mercurial mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial
Reply | Threaded
Open this post in threaded view
|

Re: topics vs bookmarks and hg-git

Uwe Brauer

   > On 2020-07-29 10:51, Manuel Jacob wrote:

   > Here: "it" = "the default branch". Sorry for the confusion.

   > To clarify: use `and not branch('re:\Adefault\Z')` if you want to
   > exclude the default branch. However, this would also exclude all
   > topics within the default branch, so it probably won’t be useful for
   > Ernie’s original question.

Right. This configuration was tested, when I pushed to a repository
which I only shared with git users, and I only used named branches not
topics.

Git users find the branch default confusing.

I admit that I have not testing my setting using topics with git users,
I have tested it so far with mercurial users, but I should have a look
what happens to the default branch. Thanks for point this out to me

_______________________________________________
Mercurial mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial

smime.p7s (7K) Download Attachment