equal
deleted
inserted
replaced
67 def convert_to_git_ref(branch): |
67 def convert_to_git_ref(branch): |
68 # XXX filter/map depending on git restrictions |
68 # XXX filter/map depending on git restrictions |
69 return b"refs/heads/" + branch |
69 return b"refs/heads/" + branch |
70 |
70 |
71 |
71 |
72 def write_data(buf, data, skip_newline): |
72 def write_data(buf, data, add_newline=False): |
73 buf.append(b"data %d\n" % len(data)) |
73 buf.append(b"data %d\n" % len(data)) |
74 buf.append(data) |
74 buf.append(data) |
75 if not skip_newline or data[-1:] != b"\n": |
75 if add_newline or data[-1:] != b"\n": |
76 buf.append(b"\n") |
76 buf.append(b"\n") |
77 |
77 |
78 |
78 |
79 def export_commit(ui, repo, rev, marks, authormap): |
79 def export_commit(ui, repo, rev, marks, authormap): |
80 ctx = repo[rev] |
80 ctx = repo[rev] |
101 if filerev not in marks: |
101 if filerev not in marks: |
102 mark = len(marks) + 1 |
102 mark = len(marks) + 1 |
103 marks[filerev] = mark |
103 marks[filerev] = mark |
104 data = filectx.data() |
104 data = filectx.data() |
105 buf = [b"blob\n", b"mark :%d\n" % mark] |
105 buf = [b"blob\n", b"mark :%d\n" % mark] |
106 write_data(buf, data, False) |
106 write_data(buf, data, True) |
107 ui.write(*buf, keepprogressbar=True) |
107 ui.write(*buf, keepprogressbar=True) |
108 del buf |
108 del buf |
109 |
109 |
110 # Assign a mark for the current revision for references by |
110 # Assign a mark for the current revision for references by |
111 # latter merge commits. |
111 # latter merge commits. |
120 % ( |
120 % ( |
121 convert_to_git_user(authormap, ctx.user(), revid), |
121 convert_to_git_user(authormap, ctx.user(), revid), |
122 convert_to_git_date(ctx.date()), |
122 convert_to_git_date(ctx.date()), |
123 ), |
123 ), |
124 ] |
124 ] |
125 write_data(buf, ctx.description(), True) |
125 write_data(buf, ctx.description()) |
126 if parents: |
126 if parents: |
127 buf.append(b"from :%d\n" % marks[parents[0].hex()]) |
127 buf.append(b"from :%d\n" % marks[parents[0].hex()]) |
128 if len(parents) == 2: |
128 if len(parents) == 2: |
129 buf.append(b"merge :%d\n" % marks[parents[1].hex()]) |
129 buf.append(b"merge :%d\n" % marks[parents[1].hex()]) |
130 p0ctx = repo[parents[0]] |
130 p0ctx = repo[parents[0]] |