Bug 1265115 - Git fails to export to hg repo from which it was cloned
Git fails to export to hg repo from which it was cloned
Status: CLOSED ERRATA
Product: Fedora
Classification: Fedora
Component: git-remote-hg (Show other bugs)
22
x86_64 Linux
high Severity high
: ---
: ---
Assigned To: pstodulk
Fedora Extras Quality Assurance
: Patch
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2015-09-22 03:38 EDT by Dr I JOrmshaw
Modified: 2016-01-04 03:53 EST (History)
3 users (show)

See Also:
Fixed In Version: git-remote-hg-0.2-7.fc23 git-remote-hg-0.2-6.fc22
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2016-01-02 17:22:29 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
input for git-remote-hg (338 bytes, text/plain)
2015-11-16 05:15 EST, pstodulk
no flags Details
patch (1.17 KB, patch)
2015-11-27 09:09 EST, pstodulk
no flags Details | Diff

  None (edit)
Description Dr I JOrmshaw 2015-09-22 03:38:37 EDT
Description of problem:

create a hg repo create a file in it. Clone it to a git repo change the file and add a new one.  Pushing back to hg fails

Version-Release number of selected component (if applicable):

git.x86_64           2.4.3-6.fc22
git-remote-hg.noarch 0.2-5.fc22
mercurial.x86_64     3.3.3-1.fc22

How reproducible:
100%

Steps to Reproduce:

hg init hg.repo
cd hg.repo
echo "Test hg <--> git" > readme.txt
hg add readme.txt
hg commit -m "hg commit"
cd ..
git clone hg::hg.repo git.repo
cd git.repo
echo "git change" >> readme.txt
echo "Nothing to install" >> install
git add install
git commit -a -m "git commit"
git push hg::../hg.repo


Actual results:

push fails as below:

Traceback (most recent call last):
  File "/usr/bin/git-remote-hg", line 1318, in <module>
    sys.exit(main(sys.argv))
  File "/usr/bin/git-remote-hg", line 1304, in main
    do_export(parser)
  File "/usr/bin/git-remote-hg", line 1101, in do_export
    parse_reset(parser)
  File "/usr/bin/git-remote-hg", line 884, in parse_reset
    parse_commit(parser)
  File "/usr/bin/git-remote-hg", line 872, in parse_commit
    node = hghex(repo.commitctx(ctx))
  File "/usr/lib64/python2.7/site-packages/mercurial/localrepo.py", line 64, in wrapper
    return orig(repo.unfiltered(), *args, **kwargs)
  File "/usr/lib64/python2.7/site-packages/mercurial/localrepo.py", line 1455, in commitctx
    trp, changed)
  File "/usr/lib64/python2.7/site-packages/mercurial/localrepo.py", line 1238, in _filecommit
    if fparent2 != nullid or flog.cmp(fparent1, text) or meta:
  File "/usr/lib64/python2.7/site-packages/mercurial/filelog.py", line 80, in cmp
    if text.startswith('\1\n'):
AttributeError: 'bool' object has no attribute 'startswith'
error: failed to push some refs to 'hg::../hg.repo'

Expected results:

Push should succeed

Additional info:
Comment 1 pstodulk 2015-11-16 05:15 EST
Created attachment 1094828 [details]
input for git-remote-hg

So from my investigation not sure yet if it is bug for git-remote-hg or mercurial itself - it is likelier 2nd option.

Inside git-remote-hg is important line 865, where is created object ctx (class memctx in context). Input seems OK and in ctx._data should be stored some string. However there is bool False - that's whole problem. I can't debug creation of object step by step due to troubles/exceptions(? don't remember result now) inside, but you can try "next" sucessfully and check created object.

For easier testing added attachment which contains example, what is awaited on stdin of git-remote-hg - otherwise you will need modify script /usr/bin/git-remote-hg to get some usefull information, if you use just git.

run git-remote-hg from git repository (see reproducer above) like:
$ GIT_DIR=.git git-remote-hg 'hg::../hg.repo' '../hg.repo'

My next idea / plans:
- check how mercurial creates this object / commits
- check upstream for changes (yeah, I haven't checked this yet)

I will be glad for help with investigation due to time deficit.
Comment 2 pstodulk 2015-11-16 05:23:39 EST
P.S. in attachment missing some empty lines on the EOF, just add it to you file or push enter few times (>= 1)
Comment 3 pstodulk 2015-11-16 05:24:44 EST
Add Neal to CC list as mercurial maintainer.
Comment 4 pstodulk 2015-11-16 05:26:44 EST
P.P.S - If you go through actual traceback, probably you solved the problem. For complete push directly with git-remote-hg you will need do some another steps, but you can try again just:
$ git push hg::../hg.repo

to see the result.
Comment 5 pstodulk 2015-11-27 09:09 EST
Created attachment 1099700 [details]
patch

Mercurial changed API and context.memfilectx requires new parameter "repo" as first. Thanks Tomas Tomecek for help.
Comment 6 Fedora Update System 2015-11-27 10:12:23 EST
git-remote-hg-0.2-6.fc22 has been submitted as an update to Fedora 22. https://bodhi.fedoraproject.org/updates/FEDORA-2015-b59ee5851b
Comment 7 Fedora Update System 2015-11-27 17:20:52 EST
git-remote-hg-0.2-6.fc22 has been pushed to the Fedora 22 testing repository. If problems still persist, please make note of it in this bug report.
If you want to test the update, you can install it with
$ su -c 'dnf --enablerepo=updates-testing update git-remote-hg'
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2015-b59ee5851b
Comment 8 Fedora Update System 2015-11-27 21:19:44 EST
git-remote-hg-0.2-7.fc23 has been pushed to the Fedora 23 testing repository. If problems still persist, please make note of it in this bug report.
If you want to test the update, you can install it with
$ su -c 'dnf --enablerepo=updates-testing update git-remote-hg'
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2015-45c6241f40
Comment 9 Fedora Update System 2016-01-02 17:22:26 EST
git-remote-hg-0.2-7.fc23 has been pushed to the Fedora 23 stable repository. If problems still persist, please make note of it in this bug report.
Comment 10 Fedora Update System 2016-01-02 18:21:16 EST
git-remote-hg-0.2-6.fc22 has been pushed to the Fedora 22 stable repository. If problems still persist, please make note of it in this bug report.

Note You need to log in before you can comment on or make changes to this bug.