Bug 1265115 - Git fails to export to hg repo from which it was cloned
Summary: Git fails to export to hg repo from which it was cloned
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: git-remote-hg
Version: 22
Hardware: x86_64
OS: Linux
high
high
Target Milestone: ---
Assignee: Petr Stodulka
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-09-22 07:38 UTC by Dr I J Ormshaw
Modified: 2016-01-04 08:53 UTC (History)
3 users (show)

Fixed In Version: git-remote-hg-0.2-7.fc23 git-remote-hg-0.2-6.fc22
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-01-02 22:22:29 UTC
Type: Bug
Embargoed:


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

Description Dr I J Ormshaw 2015-09-22 07:38:37 UTC
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 Petr Stodulka 2015-11-16 10:15:08 UTC
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 Petr Stodulka 2015-11-16 10:23:39 UTC
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 Petr Stodulka 2015-11-16 10:24:44 UTC
Add Neal to CC list as mercurial maintainer.

Comment 4 Petr Stodulka 2015-11-16 10:26:44 UTC
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 Petr Stodulka 2015-11-27 14:09:44 UTC
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 15:12:23 UTC
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 22:20:52 UTC
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-28 02:19:44 UTC
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 22:22:26 UTC
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 23:21:16 UTC
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.