# HG changeset patch # User Denis Laxalde # Date 1570359979 -7200 # Node ID 27c4f93d07a969be8d5fdfa11fac7300867c3395 # Parent 813aa8cc55d4ed26a8a52cbd7c934051e01c62d7 import: read X-Mercurial-Node email header to determine nodeid This would be useful to import and obsolete patches sent using 'hg email --plain', using evolve's --obsolete option of 'hg import'. If email body contains Mercurial patch header ('# HG changeset patch' block), nodeid parsed from X-Mercurial-Node header will still be overridden by respective value found in body. diff -r 813aa8cc55d4 -r 27c4f93d07a9 mercurial/patch.py --- a/mercurial/patch.py Wed Oct 02 07:35:22 2019 +0900 +++ b/mercurial/patch.py Sun Oct 06 13:06:19 2019 +0200 @@ -256,6 +256,11 @@ # should try to parse msg['Date'] parents = [] + nodeid = msg[r'X-Mercurial-Node'] + if nodeid: + data[b'nodeid'] = nodeid = mail.headdecode(nodeid) + ui.debug(b'Node ID: %s\n' % nodeid) + if subject: if subject.startswith(b'[PATCH'): pend = subject.find(b']') diff -r 813aa8cc55d4 -r 27c4f93d07a9 tests/test-import.t --- a/tests/test-import.t Wed Oct 02 07:35:22 2019 +0900 +++ b/tests/test-import.t Sun Oct 06 13:06:19 2019 +0200 @@ -237,7 +237,6 @@ [255] $ rm -r b - hg -R repo import put the clone in a subdir - having a directory named "a" used to hide a bug. @@ -396,6 +395,48 @@ summary: second change $ rm -r b +hg email --plain, should read X-Mercurial-Node header + + $ cat >> a/.hg/hgrc << EOF + > [extensions] + > patchbomb = + > [email] + > from = foo + > cc = foo + > to = bar + > EOF + $ hg --cwd a email -m ../tip-plain.mbox --plain --date '1970-1-1 0:1' tip + this patch series consists of 1 patches. + + + sending [PATCH] second change ... + + $ hg clone -r0 a b -q + $ hg --cwd b import --debug ../tip-plain.mbox + applying ../tip-plain.mbox + Node ID: 1d4bd90af0e43687763d158dfa83ff2a4b6c0c32 + Subject: second change + From: foo + Content-Type: text/plain + found patch at byte 0 + message: + second change + patching file a + committing files: + a + committing manifest + committing changelog + created de620f6fe949 + updating the branch cache + $ hg --cwd b tip + changeset: 1:de620f6fe949 + tag: tip + user: foo + date: Thu Jan 01 00:00:00 1970 +0000 + summary: second change + + $ rm -r b + subject: duplicate detection, removal of [PATCH] The '---' tests the gitsendmail handling without proper mail headers