Comments (20)
After trying out many different suggested solutions, this one is what worked for me (thanks to @frej): make unnamed heads into branches (my unnamed head was at revision 156)
(~/dev) $ hg clone repo repo-hg
updating to branch default
75 files updated, 0 files merged, 0 files removed, 0 files unresolved
(~/dev) $ cd repo-hg
(~/dev/repo-hg) $ hg update -r 156
22 files updated, 0 files merged, 66 files removed, 0 files unresolved
(~/dev/repo-hg) $ hg branch r156-fix-git-conversion
marked working directory as branch r156-fix-git-conversion
(~/dev/repo-hg) $ hg commit -m "Fix git conversion (unnamed head r156)"
(~/dev/repo-hg) $ hg update default
74 files updated, 0 files merged, 14 files removed, 0 files unresolved
(~/dev/repo-hg) $ cd ..
(~/dev) $ git init repo-git
(~/dev) $ cd repo-git
(~/dev/repo-git) $ ~/fast-export/hg-fast-export.sh -r ../repo-hg
... many lines without any error are expected here
(~/dev/repo-git) $ git checkout HEAD
(~/dev/repo-git) $ git status
On branch master
nothing to commit, working tree clean
from fast-export.
Thanks. --force
did what I needed.
from fast-export.
Hi Michal,
I expect that in git terminology it complains about "detached
head". Does anybody know how to fix it?
The problem is that there is no way for git to represent a branch with
two heads. You could run with --force which will let fast-export do the
conversion, then you'll end up with a single branch (which head you'll
end up with is undefined).
Your best bet is to figure out a way to transform the input repository
(on the hg side) into a form that can be represented by git. Perhaps you
could make the heads into branches with names synthesized from the name
of the parent branch?
--Frej
from fast-export.
The repository is: https://bitbucket.org/alanmi/abc
I'm getting the error on one of the closed hg heads.Loaded 20 authors
Error: repository has at least one unnamed head: hg r3098
You either run with --force, name them on the hg-side (if you want to
preserve them), or do a clone (again on the hg-side) with -b to drop the
branches you are not interested in.
from fast-export.
I also got this now:
Error: repository has at least one unnamed head: hg r4592
The problem is that that revision is actually a "branch close" in hg, so it's not really a head... I believe it would be nice if fast-export could handle these cases. We normally close named branches after a while (when we no longer need to support them), so we have a bunch of these loose "heads" hanging around. :-)
from fast-export.
I also got this now:
Error: repository has at least one unnamed head: hg r4592
The problem is that that revision is actually a "branch close" in hg, so it's
not really a head... I believe it would be nice if fast-export could handle
these cases. We normally close named branches after a while (when we no longer
need to support them), so we have a bunch of these loose "heads" hanging
around. :-)
You do not give a reference to a repo that exhibits this behaviour and I
can't reproduce the problem. Doing:
mkdir hg
cd hg
hg init
touch foo
hg add foo
hg commit -m "Initial"
hg branch to_close
touch bar
hg add bar
hg commit -m "on branch to_close"
hg branches
to_close 1:011c507cd940
default 0:3f440d901ea3 (inactive)
hg commit --close-branch -m 'close the branch'
hg up -C default
cd ..
mkdir git
cd git
git init
hg-fast-export.sh -r ../hg/
works fine.
Cheers,
--Frej
from fast-export.
I am also seeing "Error: repository has at least one unnamed head: hg r573"
Which is a commit that closes a branch.
Unlike your example, all my closed branches are unnamed branches.
I can replicate the problem by taking your example and creating an unnamed branch instead of the 'to_close' branch and closing it.
from fast-export.
As said previously in this issue thread, git does not do unnamed branches, if it is a branch it has to have a name. How can you talk about anything if you don't give it a name! Philosophy aside, if you have unnamed branches you need to give them names, see #9 (comment)
from fast-export.
Sorry, I might be getting the mercurial terminology wrong. There were multiple heads in the default branch, and they were so diverged from the main head that it didn't make sense to merge them and have rubbish in the branch history. Trying to turn them into a named branch just seemed to create a new branch in addition to the existing head :/
So I closed them, and apparently you aren't supposed to do that.
I gave up and just stripped those revisions out of the repo completely.
from fast-export.
Getting this, too.
The repository is: https://bitbucket.org/alanmi/abc
I'm getting the error on one of the closed hg heads.
Loaded 20 authors
Error: repository has at least one unnamed head: hg r3098
git-fast-import statistics:
$ hg head
changeset: 3417:e176dbefc432
tag: tip
user: [email protected]
date: Fri Oct 07 18:00:06 2016 +0200
summary: Soften an overzealous assert
changeset: 3353:15f3be226d03
branch: hier-npn_fast-exact
user: Ana Petkovska <[email protected]>
date: Sat Jun 18 18:51:38 2016 +0200
summary: Return the class representative of each function.
changeset: 3227:73982477d6f9
branch: fxch_implementation
user: Bruno Schmitt
date: Wed May 11 19:41:31 2016 -0300
summary: Add a new module which implements the fast extract with cube hashing (fxch) algorithm.
changeset: 2567:4fd5b8de5f9a
branch: grigora/fixed-hang-issue-in-bm-command-1413034154897
parent: 2564:cae34096a164
user: grigora <[email protected]>
date: Sat Oct 11 13:30:02 2014 +0000
summary: Fixed "bm" command hang issue.
changeset: 2364:376aefd8fcdc
branch: unfold2-dev
user: Jiang Long <[email protected]>
date: Wed Jun 04 23:21:13 2014 -0700
summary: ci
$ hg head -c
[...]
changeset: 3098:dc1935e167d1
parent: 618:8d5cb5a0d1fc
user: Baruch Sterin <[email protected]>
date: Sat Nov 21 01:04:03 2015 -0800
summary: closing head created by mistake
how do I remove the closed hg heads?
(not a hg person)
from fast-export.
I tried the -f option now, but I end up with an empty directory.
git log looks ok, but git status shows uncommitted changes, all of them deleted files.
comitting did not fix it...
from fast-export.
from fast-export.
Oh, sorry.. you're likely right...
In the meantime I've been successful using the hg-git
plugin. With that I ran into problems trying to push
via https(broken pipe.. ip timeout or a bug.. unsure..).
using a bare local repo worked... then pulled from that
with git and pushed to https...
from fast-export.
Workaround (seen in http://stackoverflow.com/questions/30580756/get-rid-of-nameless-node-in-mercurial-repository):
hg tags # Creates .hg/cache/tags2-visible
# Fix the nameless tag
sed -rie 's/^([^ ]+) $/\1 \1/' .hg/cache/tags2-visible
from fast-export.
How do you name a head on the HG side?
I have several closed (but named) branches, but I am still getting this error.
from fast-export.
Ah, I think the issue is that I have a named branch with multiple heads.
See below link:
http://idontsov.blogspot.com/2017/12/fixing-repository-has-at-least-one.html
from fast-export.
Thanks.
--force
did what I needed.
--force
needs to be at the end of a command line.
hg-fast-export.sh -r /path_to/some_repository.hg -A ~/hg_to_git/authors --force
from fast-export.
In my case, using --force
resulted in almost all commits being absent from the resulting git repository.
I resolved the problem by merging the main branch containing most of the commits into the tip. Used TortoiseHg to visualise. This still discarded any unnamed branches that were not in the main branch, but I kept the commits that mattered.
from fast-export.
aercolino's post is useful and gives the procedure, but it did not work for me when someone had closed that unnamed head. The error message is the same (Error: repository has an unnamed head: hg r####). If I run hg log -G I get an inkling that things might not work: there is a bit of a blank in the vertical line :-). I ended up using "hg strip -r ####", and then doing it again 2 more times (!) Thanks for this thread: it was very instructive.
from fast-export.
I tried to import https://eric-ide.python-projects.org/eric-code.html using github import tool, but it failed with unknown problems. And I tried this tool, it failed with a similar error (Error: repository has an unnamed head: hg r8747), and --force
option seems work for me.
@liudonghua123 ➜ /workspaces/scratch-app/eric (main) $ hg-fast-export.sh -r ../eric_hg
Warning: sanitized branch [Variables Viewer] to [Variables_Viewer]
Warning: sanitized branch [debugger fine grinding] to [debugger_fine_grinding]
Warning: sanitized branch [debugger speed] to [debugger_speed]
Warning: sanitized branch [Py2 comp.] to [Py2_comp_]
Error: repository has an unnamed head: hg r8747
fast-import statistics:
---------------------------------------------------------------------
Alloc'd objects: 5000
Total objects: 0 ( 0 duplicates )
blobs : 0 ( 0 duplicates 0 deltas of 0 attempts)
trees : 0 ( 0 duplicates 0 deltas of 0 attempts)
commits: 0 ( 0 duplicates 0 deltas of 0 attempts)
tags : 0 ( 0 duplicates 0 deltas of 0 attempts)
Total branches: 0 ( 0 loads )
marks: 1024 ( 0 unique )
atoms: 0
Memory total: 2399 KiB
pools: 2048 KiB
objects: 351 KiB
---------------------------------------------------------------------
pack_report: getpagesize() = 4096
pack_report: core.packedGitWindowSize = 1073741824
pack_report: core.packedGitLimit = 35184372088832
pack_report: pack_used_ctr = 0
pack_report: pack_mmap_calls = 0
pack_report: pack_open_windows = 0 / 0
pack_report: pack_mapped = 0 / 0
---------------------------------------------------------------------
@liudonghua123 ➜ /workspaces/scratch-app/eric (main) $
from fast-export.
Related Issues (20)
- export project with submodules does not contain a valid uri HOT 1
- .hgsub is still available after conversion HOT 1
- .hgignore is not replaced by .gitignore HOT 1
- Reduce repository size HOT 1
- Not all modules are defined in mapping file. HOT 2
- Commit messages are decoded as cp1252 with parameter -e utf8 HOT 1
- Yet another "cannot lock ref", mapping seems not to help HOT 2
- no difference between empty and no plugin option HOT 4
- Branch mapping not working with quotation mark HOT 6
- fast-export only converts default branch HOT 3
- Support for Python 3.12 (e.g. replace `imp` usage for Python 3 users)
- hg-fast-export.py fails due to missing hg2git module HOT 3
- Cannot execute fast export due to missing module importlib.machinery HOT 6
- Renaming files ignores file deletions HOT 1
- Importing mercurial repository fails with syntax error HOT 1
- Error -5 while decompressing data HOT 2
- Archives doesn't contain sharness folder HOT 2
- Running content filter fails, maybe because of an empty commit HOT 2
- git checkout HEAD ERROR HOT 4
- Add tag filtering in plugins HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fast-export.