Show More
@@ -1141,6 +1141,39 b' extraexport = []' | |||
|
1141 | 1141 | # it is given two arguments (sequencenumber, changectx) |
|
1142 | 1142 | extraexportmap = {} |
|
1143 | 1143 | |
|
1144 | def _exportsingle(repo, ctx, match, switch_parent, rev, seqno, write, diffopts): | |
|
1145 | node = ctx.node() | |
|
1146 | parents = [p.node() for p in ctx.parents() if p] | |
|
1147 | branch = ctx.branch() | |
|
1148 | if switch_parent: | |
|
1149 | parents.reverse() | |
|
1150 | ||
|
1151 | if parents: | |
|
1152 | prev = parents[0] | |
|
1153 | else: | |
|
1154 | prev = nullid | |
|
1155 | ||
|
1156 | write("# HG changeset patch\n") | |
|
1157 | write("# User %s\n" % ctx.user()) | |
|
1158 | write("# Date %d %d\n" % ctx.date()) | |
|
1159 | write("# %s\n" % util.datestr(ctx.date())) | |
|
1160 | if branch and branch != 'default': | |
|
1161 | write("# Branch %s\n" % branch) | |
|
1162 | write("# Node ID %s\n" % hex(node)) | |
|
1163 | write("# Parent %s\n" % hex(prev)) | |
|
1164 | if len(parents) > 1: | |
|
1165 | write("# Parent %s\n" % hex(parents[1])) | |
|
1166 | ||
|
1167 | for headerid in extraexport: | |
|
1168 | header = extraexportmap[headerid](seqno, ctx) | |
|
1169 | if header is not None: | |
|
1170 | write('# %s\n' % header) | |
|
1171 | write(ctx.description().rstrip()) | |
|
1172 | write("\n\n") | |
|
1173 | ||
|
1174 | for chunk, label in patch.diffui(repo, prev, node, match, opts=diffopts): | |
|
1175 | write(chunk, label=label) | |
|
1176 | ||
|
1144 | 1177 | def export(repo, revs, fntemplate='hg-%h.patch', fp=None, switch_parent=False, |
|
1145 | 1178 | opts=None, match=None): |
|
1146 | 1179 | '''export changesets as hg patches |
@@ -1172,62 +1205,31 b" def export(repo, revs, fntemplate='hg-%h" | |||
|
1172 | 1205 | revwidth = max(len(str(rev)) for rev in revs) |
|
1173 | 1206 | filemode = {} |
|
1174 | 1207 | |
|
1175 | def single(rev, seqno, fp): | |
|
1208 | for seqno, rev in enumerate(revs, 1): | |
|
1176 | 1209 | ctx = repo[rev] |
|
1177 |
|
|
|
1178 | parents = [p.node() for p in ctx.parents() if p] | |
|
1179 | branch = ctx.branch() | |
|
1180 | if switch_parent: | |
|
1181 | parents.reverse() | |
|
1182 | ||
|
1183 | if parents: | |
|
1184 | prev = parents[0] | |
|
1185 | else: | |
|
1186 | prev = nullid | |
|
1187 | ||
|
1188 | shouldclose = False | |
|
1210 | fo = None | |
|
1211 | dest = '<unnamed>' | |
|
1189 | 1212 | if not fp and len(fntemplate) > 0: |
|
1190 | 1213 | desc_lines = ctx.description().rstrip().split('\n') |
|
1191 | 1214 | desc = desc_lines[0] #Commit always has a first line. |
|
1192 |
f |
|
|
1193 |
seqno=seqno, revwidth=revwidth, |
|
|
1194 | modemap=filemode) | |
|
1195 |
|
|
|
1196 | if fp and not getattr(fp, 'name', '<unnamed>').startswith('<'): | |
|
1197 | repo.ui.note("%s\n" % fp.name) | |
|
1198 | ||
|
1199 | if not fp: | |
|
1200 | write = repo.ui.write | |
|
1201 | else: | |
|
1215 | fo = makefileobj(repo, fntemplate, ctx.node(), desc=desc, | |
|
1216 | total=total, seqno=seqno, revwidth=revwidth, | |
|
1217 | mode='wb', modemap=filemode) | |
|
1218 | dest = fo.name | |
|
1219 | def write(s, **kw): | |
|
1220 | fo.write(s) | |
|
1221 | elif fp: | |
|
1222 | dest = getattr(fp, 'name', dest) | |
|
1202 | 1223 | def write(s, **kw): |
|
1203 | 1224 | fp.write(s) |
|
1204 | ||
|
1205 | write("# HG changeset patch\n") | |
|
1206 | write("# User %s\n" % ctx.user()) | |
|
1207 | write("# Date %d %d\n" % ctx.date()) | |
|
1208 | write("# %s\n" % util.datestr(ctx.date())) | |
|
1209 | if branch and branch != 'default': | |
|
1210 | write("# Branch %s\n" % branch) | |
|
1211 | write("# Node ID %s\n" % hex(node)) | |
|
1212 | write("# Parent %s\n" % hex(prev)) | |
|
1213 | if len(parents) > 1: | |
|
1214 | write("# Parent %s\n" % hex(parents[1])) | |
|
1215 | ||
|
1216 | for headerid in extraexport: | |
|
1217 | header = extraexportmap[headerid](seqno, ctx) | |
|
1218 | if header is not None: | |
|
1219 | write('# %s\n' % header) | |
|
1220 | write(ctx.description().rstrip()) | |
|
1221 | write("\n\n") | |
|
1222 | ||
|
1223 | for chunk, label in patch.diffui(repo, prev, node, match, opts=opts): | |
|
1224 | write(chunk, label=label) | |
|
1225 | ||
|
1226 | if shouldclose: | |
|
1227 | fp.close() | |
|
1228 | ||
|
1229 | for seqno, rev in enumerate(revs): | |
|
1230 | single(rev, seqno + 1, fp) | |
|
1225 | else: | |
|
1226 | write = repo.ui.write | |
|
1227 | if not dest.startswith('<'): | |
|
1228 | repo.ui.note("%s\n" % dest) | |
|
1229 | _exportsingle( | |
|
1230 | repo, ctx, match, switch_parent, rev, seqno, write, opts) | |
|
1231 | if fo is not None: | |
|
1232 | fo.close() | |
|
1231 | 1233 | |
|
1232 | 1234 | def diffordiffstat(ui, repo, diffopts, node1, node2, match, |
|
1233 | 1235 | changes=None, stat=False, fp=None, prefix='', |
General Comments 0
You need to be logged in to leave comments.
Login now