import to named branches: could git's name-rev be useful

4 views
Skip to first unread message

Uwe Brauer

unread,
Mar 9, 2023, 8:36:53 AM3/9/23
to via hg-git

Hi,

As I said I use Manuel Jacob's patch to export named branches (or topic) to git repositories.

So I run the following experiment.

hg init
echo "First" > test.org
hg add test.org
hg commit -u "Bernhard Riemann <bernhard...@gmail.com>" -m "First into default"
echo "Second" >> test.org
hg commit -u "Bernhard Riemann <bernhard...@gmail.com>" -m "Second into default"
hg up 1
hg branch feature
echo "Third" >> test.org
hg commit -u "Bernhard Riemann <bernhard...@gmail.com>" -m "Third into feature branch"
echo "Forth" >> test.org
hg commit -u "Bernhard Riemann <bernhard...@gmail.com>" -m "Forth into feature branch"
hg up 1
hg branch testbranch
echo "Fifth" >> test.org
hg commit -u "Bernhard Riemann <bernhard...@gmail.com>" -m "Fifth into testbranch"
echo "Six" >> test.org
hg commit -u "Bernhard Riemann <bernhard...@gmail.com>" -m "Six into testbranch"

That gives the following graph


◍ changeset: 5:181ab28b8336
│ tag: default/testbranch
│ tag: tip
│ Branch: testbranch
│ Author: Bernhard Riemann <bernhard...@gmail.com>
│ Date: Thu, 09 Mar 2023 13:34:27 +0100
│ Phase: draft
│ Summary: Six into testbranch

○ changeset: 4:4442b600a7fb
│ Branch: testbranch
│ Author: Bernhard Riemann <bernhard...@gmail.com>
│ Date: Thu, 09 Mar 2023 13:34:27 +0100
│ Phase: draft
│ Summary: Fifth into testbranch

│ ○ changeset: 3:05afcfa7cba3
│ │ tag: default/feature
│ │ Branch: feature
│ │ Author: Bernhard Riemann <bernhard...@gmail.com>
│ │ Date: Thu, 09 Mar 2023 13:34:25 +0100
│ │ Phase: draft
│ │ Summary: Forth into feature branch
│ │
│ ○ changeset: 2:d66190ca5188
│╱ Branch: feature
│ Author: Bernhard Riemann <bernhard...@gmail.com>
│ Date: Thu, 09 Mar 2023 13:34:25 +0100
│ Phase: draft
│ Summary: Third into feature branch
○ changeset: 1:d71759638c18
│ Branch: default
│ Author: Bernhard Riemann <bernhard...@gmail.com>
│ Date: Thu, 09 Mar 2023 13:34:24 +0100
│ Phase: draft
│ Summary: Second into default

○ changeset: 0:4ffc518c03f6
Branch: default
Author: Bernhard Riemann <bernhard...@gmail.com>
Date: Thu, 09 Mar 2023 13:34:24 +0100
Phase: draft
Summary: First into default

So I push that to a freshly created git repository (in gitlab) and clone
it back with git.

Using
git log --graph --color=always --all --since=2years --decorate --pretty | git name-rev --annotate-stdin | less -R

I obtain the following graph



* commit 506df625c2a65103c2ec467e30012ea1c47bd230 (remotes/origin/testbranch) (origin/testbranch)
| Author: Bernhard Riemann <bernhard...@gmail.com>
| Date: Thu Mar 9 13:34:27 2023 +0100
|
| Six into testbranch
|
| --HG--
| branch : testbranch
|
* commit afe815dc8407c76811a26bec2b0fff3d5f659a90 (remotes/origin/testbranch~1)
| Author: Bernhard Riemann <bernhard...@gmail.com>
| Date: Thu Mar 9 13:34:27 2023 +0100
|
| Fifth into testbranch
|
| --HG--
| branch : testbranch
|
| * commit 1f3900c3d1f32ee3c6074cf11bb69fb9c5b46979 (feature) (HEAD -> feature, origin/feature, origin/HEAD)
| | Author: Bernhard Riemann <bernhard...@gmail.com>
| | Date: Thu Mar 9 13:34:25 2023 +0100
| |
| | Forth into feature branch
| |
| | --HG--
| | branch : feature
| |
| * commit 78fcae41a55ed989536f6b4ecb11d19b0e4e6954 (feature~1)
|/ Author: Bernhard Riemann <bernhard...@gmail.com>
| Date: Thu Mar 9 13:34:25 2023 +0100
|
| Third into feature branch
|
| --HG--
| branch : feature
|
* commit 191e063069efe7a92e651f47e52164effa66b6e5 (feature~2)
| Author: Bernhard Riemann <bernhard...@gmail.com>
| Date: Thu Mar 9 13:34:24 2023 +0100
|
| Second into default
|
* commit 0fe95081ff7a73a883e8cb9e14903618fe422329 (feature~3)
Author: Bernhard Riemann <bernhard...@gmail.com>
Date: Thu Mar 9 13:34:24 2023 +0100

First into default

Which looks very similar.

Now name-rev is determined on the fly by git as I understand it and not
stored anywhere. But maybe one could clone/pull a git repository with
git first to the machine and then import that bridge into mercurial and
importing the git branches into named branches?

A problem could be to find out where the branch started.

https://stackoverflow.com/questions/1527234/finding-a-branch-point-with-git

Any comments?

Thanks and regards

Uwe Brauer

--
Warning: Content may be disturbing to some audiences
I strongly condemn Putin's war of aggression against the Ukraine.
I support to deliver weapons to Ukraine's military.
I support the ban of Russia from SWIFT.
I support the EU membership of the Ukraine.
https://addons.thunderbird.net/en-US/thunderbird/addon/gmail-conversation-view/
Reply all
Reply to author
Forward
0 new messages