diff --git a/mercurial/patch.py b/mercurial/patch.py
index 89b806a09a6640c01b7d68e6c6c34cfbe9c8ac51_bWVyY3VyaWFsL3BhdGNoLnB5..a6d51dcb18239b191fb3a9d71ea251fae5fa35be_bWVyY3VyaWFsL3BhdGNoLnB5 100644
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -188,7 +188,6 @@
             subject = '\n'.join(': '.join(h) for h in msg.items()) + '\n'
 
         # should try to parse msg['Date']
-        nodeid = None
         parents = []
 
         if subject:
@@ -236,7 +235,7 @@
                         elif line.startswith("# Branch "):
                             data['branch'] = line[9:]
                         elif line.startswith("# Node ID "):
-                            nodeid = line[10:]
+                            data['nodeid'] = line[10:]
                         elif line.startswith("# Parent "):
                             parents.append(line[9:].lstrip())
                         elif not line.startswith("# "):
@@ -273,7 +272,6 @@
             data['p2'] = parents.pop(0)
 
     data['filename'] = tmpname
-    data['nodeid'] = nodeid
     return data
 
 class patchmeta(object):