diff mercurial/patch.py @ 43097:27c4f93d07a9

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.
author Denis Laxalde <denis@laxalde.org>
date Sun, 06 Oct 2019 13:06:19 +0200
parents eef9a2d67051
children 74802979dd9d
line wrap: on
line diff
--- 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']')