Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Potential for error when importing from HG to Git #143

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
2 participants

I haven't yet determined the root cause of the problem, but for whatever reason when attempting to pull into one of my HG repos from a Git mirror it failed due to bad metadata in the Git commit message.

The commit message in questions:
commit 59357b920e7b40a0b5719771a101b2ec6337bf26
Author: Carl Meyer carl@oddbird.net
Date: Tue Sep 21 17:57:28 2010 -0400

    add .gitignore for git mirror work; can be removed later

    --HG--
    branch : conditional-questions

Obviously this syntax is actually correct, but when it was being processed by extract_hg_metadata() it would fail. Adding some debugging to the method I was able to determine that after the message.split("\n--HG--\n", 1), the metadata was instead coming through as:
branch: conditional-questions

This obviously causes the next split (command, data = line.split(" : ", 1)) to fail. My change fixes this issue and allowed the pull to proceed as it should, though I still can't explain the actual cause of the problem.

@durin42 durin42 commented on the diff Mar 24, 2011

hggit/git_handler.py
@@ -788,7 +788,9 @@ class GitHandler(object):
if line == '':
continue
- command, data = line.split(" : ", 1)
+ command, data = line.split(":", 1)
+ command = string.strip(command)
@durin42

durin42 Mar 24, 2011

Collaborator

why this and not command = command.strip()? ditto data on the next line.

@joshourisman

joshourisman Mar 24, 2011

Because the split was actually failing as it was, for whatever reason it was inconsistent about whether or not there was a space between 'branch' and ':' so that line.split(" : ", 1) sometimes simply failed because that substring did not exist.

@durin42

durin42 Mar 24, 2011

Collaborator

Ping this thread when I should look again at pulling.

Thanks!

On Thu, Mar 24, 2011 at 10:24 AM, joshourisman
reply@reply.github.com
wrote:

@@ -788,7 +788,9 @@ class GitHandler(object):
                 if line == '':
                     continue

  •                command, data = line.split(" : ", 1)
  •                command, data = line.split(":", 1)
  •                command = string.strip(command)

Because the split was actually failing as it was, for whatever reason it was inconsistent about whether or not there was a space between 'branch' and ':'.

Reply to this email directly or view it on GitHub:
https://github.com/schacon/hg-git/pull/143/files#r11599

Collaborator

durin42 commented Mar 24, 2011

1 inline comment.

Can you come up with a test case?

@durin42 durin42 closed this Oct 5, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment