1122 dodiff(sys.stdout, ui, repo, node1, node2, fns, match=matchfn, |
1122 dodiff(sys.stdout, ui, repo, node1, node2, fns, match=matchfn, |
1123 text=opts['text']) |
1123 text=opts['text']) |
1124 |
1124 |
1125 def doexport(ui, repo, changeset, seqno, total, revwidth, opts): |
1125 def doexport(ui, repo, changeset, seqno, total, revwidth, opts): |
1126 node = repo.lookup(changeset) |
1126 node = repo.lookup(changeset) |
1127 prev, other = repo.changelog.parents(node) |
1127 parents = [p for p in repo.changelog.parents(node) if p != nullid] |
|
1128 prev = (parents and parents[0]) or nullid |
1128 change = repo.changelog.read(node) |
1129 change = repo.changelog.read(node) |
1129 |
1130 |
|
1131 if opts['switch_parent']: |
|
1132 parents.reverse() |
1130 fp = make_file(repo, repo.changelog, opts['output'], |
1133 fp = make_file(repo, repo.changelog, opts['output'], |
1131 node=node, total=total, seqno=seqno, |
1134 node=node, total=total, seqno=seqno, |
1132 revwidth=revwidth) |
1135 revwidth=revwidth) |
1133 if fp != sys.stdout: |
1136 if fp != sys.stdout: |
1134 ui.note("%s\n" % fp.name) |
1137 ui.note("%s\n" % fp.name) |
1135 |
1138 |
1136 fp.write("# HG changeset patch\n") |
1139 fp.write("# HG changeset patch\n") |
1137 fp.write("# User %s\n" % change[1]) |
1140 fp.write("# User %s\n" % change[1]) |
1138 fp.write("# Node ID %s\n" % hex(node)) |
1141 fp.write("# Node ID %s\n" % hex(node)) |
1139 fp.write("# Parent %s\n" % hex(prev)) |
1142 fp.write("# Parent %s\n" % hex(prev)) |
1140 if other != nullid: |
1143 if len(parents) > 1: |
1141 fp.write("# Parent %s\n" % hex(other)) |
1144 fp.write("# Parent %s\n" % hex(parents[1])) |
1142 fp.write(change[4].rstrip()) |
1145 fp.write(change[4].rstrip()) |
1143 fp.write("\n\n") |
1146 fp.write("\n\n") |
1144 |
1147 |
1145 dodiff(fp, ui, repo, prev, node, text=opts['text']) |
1148 dodiff(fp, ui, repo, prev, node, text=opts['text']) |
1146 if fp != sys.stdout: |
1149 if fp != sys.stdout: |
1167 %r zero-padded changeset revision number |
1170 %r zero-padded changeset revision number |
1168 |
1171 |
1169 Without the -a option, export will avoid generating diffs of files |
1172 Without the -a option, export will avoid generating diffs of files |
1170 it detects as binary. With -a, export will generate a diff anyway, |
1173 it detects as binary. With -a, export will generate a diff anyway, |
1171 probably with undesirable results. |
1174 probably with undesirable results. |
|
1175 |
|
1176 With the --switch-parent option, the diff will be against the second |
|
1177 parent. It can be useful to review a merge. |
1172 """ |
1178 """ |
1173 if not changesets: |
1179 if not changesets: |
1174 raise util.Abort(_("export requires at least one changeset")) |
1180 raise util.Abort(_("export requires at least one changeset")) |
1175 seqno = 0 |
1181 seqno = 0 |
1176 revs = list(revrange(ui, repo, changesets)) |
1182 revs = list(revrange(ui, repo, changesets)) |
2261 ('X', 'exclude', [], _('exclude names matching the given patterns'))], |
2267 ('X', 'exclude', [], _('exclude names matching the given patterns'))], |
2262 _('hg diff [-a] [-I] [-X] [-r REV1 [-r REV2]] [FILE]...')), |
2268 _('hg diff [-a] [-I] [-X] [-r REV1 [-r REV2]] [FILE]...')), |
2263 "^export": |
2269 "^export": |
2264 (export, |
2270 (export, |
2265 [('o', 'output', "", _('print output to file with formatted name')), |
2271 [('o', 'output', "", _('print output to file with formatted name')), |
2266 ('a', 'text', None, _('treat all files as text'))], |
2272 ('a', 'text', None, _('treat all files as text')), |
|
2273 ('', 'switch-parent', None, _('diff against the second parent'))], |
2267 "hg export [-a] [-o OUTFILE] REV..."), |
2274 "hg export [-a] [-o OUTFILE] REV..."), |
2268 "forget": |
2275 "forget": |
2269 (forget, |
2276 (forget, |
2270 [('I', 'include', [], _('include names matching the given patterns')), |
2277 [('I', 'include', [], _('include names matching the given patterns')), |
2271 ('X', 'exclude', [], _('exclude names matching the given patterns'))], |
2278 ('X', 'exclude', [], _('exclude names matching the given patterns'))], |