Patchwork [3,of,9,PoC] mq2: update 'Node ID' when refreshing

login
register
mail settings
Submitter Mads Kiilerich
Date Aug. 29, 2014, 8:59 a.m.
Message ID <01873ea9fda12f58b90e.1409302760@localhost.localdomain>
Download mbox | patch
Permalink /patch/5615/
State Changes Requested
Headers show

Comments

Mads Kiilerich - Aug. 29, 2014, 8:59 a.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1409301991 -7200
#      Fri Aug 29 10:46:31 2014 +0200
# Node ID 01873ea9fda12f58b90e8a3f720dfe30b84c24e6
# Parent  608e1f1b2b20f5ea54458edcbcbf406d66cbdf42
mq2: update 'Node ID' when refreshing

Patch

diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -240,6 +240,22 @@  class patchheader(object):
                 pass
         self.parent = parent
 
+    def setnodeid(self, nodeid):
+        if not self.plainmode and not self.updateheader(['# Node ID '], nodeid):
+            try:
+                patchheaderat = self.comments.index('# HG changeset patch')
+            except ValueError:
+                pass
+            else:
+                for i, l in enumerate(self.comments):
+                     if i < patchheaderat:
+                          continue
+                     if l.startswith('# ') and not l.startswith('# Parent '):
+                          continue
+                     self.comments.insert(i, '# Node ID ' + nodeid)
+                     break
+        self.nodeid = nodeid
+
     def setmessage(self, message):
         if self.comments:
             self._delmsg()
@@ -1694,6 +1710,7 @@  class queue(object):
                     self.putsubstate2changes(substatestate, c)
                 chunks = patchmod.diff(repo, patchparent,
                                        changes=c, opts=diffopts)
+                ph.setnodeid(hex(n))
                 comments = str(ph)
                 if comments:
                     patchf.write(comments)
diff --git a/tests/test-mq-git.t b/tests/test-mq-git.t
--- a/tests/test-mq-git.t
+++ b/tests/test-mq-git.t
@@ -64,6 +64,7 @@  git=auto: regular patch after qrefresh w
 
   $ cat .hg/patches/git
   # HG changeset patch
+  # Node ID 017ef854e040bb4a95a08313edf87d5b8923d8b0
   # Parent 99586d5f048c399e20f81cee41fbb3809c0e735d
   # Date 0 0
   
@@ -105,6 +106,7 @@  git=keep: git patch after qrefresh witho
 
   $ cat .hg/patches/git
   # HG changeset patch
+  # Node ID 47e3ba58a18c29320eeaeb60d44d87d735164580
   # Parent 0000000000000000000000000000000000000000
   # Date 0 0
   
@@ -147,6 +149,7 @@  git=yes: git patch after qrefresh:
 
   $ cat .hg/patches/git
   # HG changeset patch
+  # Node ID 47e3ba58a18c29320eeaeb60d44d87d735164580
   # Parent 0000000000000000000000000000000000000000
   # Date 0 0
   
@@ -192,6 +195,7 @@  git=no: regular patch after qrefresh wit
 
   $ cat .hg/patches/regular
   # HG changeset patch
+  # Node ID cf0bfe72686a47d8d7d7b4529a3adb8b0b449a9f
   # Parent ef8dafc9fa4caff80f6e243eb0171bcd60c455b4
   # Date 0 0
   
diff --git a/tests/test-mq-header-date.t b/tests/test-mq-header-date.t
--- a/tests/test-mq-header-date.t
+++ b/tests/test-mq-header-date.t
@@ -560,6 +560,7 @@ 
   ==== qref
   adding 1
   # HG changeset patch
+  # Node ID 8c640e9949a893e61cfac9928aa087a2a87e9b43
   # Parent 
   # Date 3 0
   
@@ -571,6 +572,7 @@ 
   0: [mq]: 1.patch - test - 3.00
   ==== qref -d
   # HG changeset patch
+  # Node ID 4a67dfeea97489d65d35274ac4b91262efde2c6e
   # Parent 
   # Date 4 0
   
@@ -583,6 +585,7 @@ 
   ==== qnew
   adding 2
   # HG changeset patch
+  # Node ID 722eb9860cde40bd552b8cff108ff2bcdb2c5885
   # Parent 
   # Date 1 0
   
@@ -595,6 +598,7 @@ 
   0: [mq]: 1.patch - test
   ==== qref -d
   # HG changeset patch
+  # Node ID 1d9a6a118fd1d2b2f0d04bdebc451f8f655b1633
   # Parent 
   # Date 5 0
   
@@ -619,6 +623,7 @@ 
   ==== qref
   adding 3
   # HG changeset patch
+  # Node ID 7f19ad9eea7b30e7a61ec2aa1f4f5e116e28563f
   # Parent 
   # Date 6 0
   
@@ -633,6 +638,7 @@ 
   0: [mq]: 1.patch - test - 4.00
   ==== qref -m
   # HG changeset patch
+  # Node ID 7ff7377793e36dff43543230decc31cb29da2752
   # Parent 
   # Date 6 0
   
@@ -647,6 +653,7 @@ 
   0: [mq]: 1.patch - test - 4.00
   ==== qref -d
   # HG changeset patch
+  # Node ID d89d3144f51897f68812b107802a98b5e0638d99
   # Parent 
   # Date 7 0
   
@@ -661,6 +668,7 @@ 
   0: [mq]: 1.patch - test - 4.00
   ==== qref -d -m
   # HG changeset patch
+  # Node ID b1b6b0fe0e6d78b1206ee2ff4b6bb713a395956a
   # Parent 
   # Date 8 0
   
@@ -676,6 +684,7 @@ 
   ==== qnew -m
   adding 4
   # HG changeset patch
+  # Node ID ef1967e37f50bac58090b48066506d4657578df7
   # Parent 
   # Date 1 0
   
@@ -691,6 +700,7 @@ 
   0: [mq]: 1.patch - test
   ==== qref -d
   # HG changeset patch
+  # Node ID 1a651320cf8e3144a1a35a3c9d44890d0d7b847c
   # Parent 
   # Date 9 0
   
@@ -721,6 +731,7 @@ 
   Date: 1 0
   
   # HG changeset patch
+  # Node ID 5dbf69c07df9226c47ab6bb38f1acb4c102b1cf1
   # Parent 
   # Date 10 0
   
@@ -736,6 +747,7 @@ 
   Date: 11 0
   
   # HG changeset patch
+  # Node ID 049de6af0c1df2ef43f0af9bc5d05fdcacd6b4d4
   # Parent 
   # Date 11 0
   
@@ -787,6 +799,7 @@ 
   ==== qnew -u
   adding 6
   # HG changeset patch
+  # Node ID bbc7eb8cd361357efa98293af0cf54ac73e9bc7d
   # Parent 
   # User jane
   # Date 1 0
@@ -802,6 +815,7 @@ 
   0: [mq]: 1.patch - test
   ==== qref -d
   # HG changeset patch
+  # Node ID 5702c529dfe926c59f294681367f5ba74efc6c6a
   # Parent 
   # User jane
   # Date 12 0
@@ -820,6 +834,7 @@ 
   ==== qnew -d
   adding 7
   # HG changeset patch
+  # Node ID 8dd1eb8d41326382d3caa3e51a73398a923af9b0
   # Parent 
   # Date 13 0
   
@@ -835,6 +850,7 @@ 
   ==== qref -u
   # HG changeset patch
   # User john
+  # Node ID 4f9d07369cc4ee447a49f98f50e1c3830f93e690
   # Parent 
   # Date 13 0
   
@@ -850,6 +866,7 @@ 
   ==== qnew
   adding 8
   # HG changeset patch
+  # Node ID 5b45bbc41eb86b45f86abd0315c45708d5516ed5
   # Parent 
   # Date 1 0
   
@@ -866,6 +883,7 @@ 
   ==== qref -u -d
   # HG changeset patch
   # User john
+  # Node ID b1e878ae55b923ea2bbe1f292acaf756fc22c43f
   # Parent 
   # Date 14 0
   
@@ -884,6 +902,7 @@ 
   ==== qnew -m
   adding 9
   # HG changeset patch
+  # Node ID fed8fefa505504dbd8f7a5b611f225331ccb1b49
   # Parent 
   # Date 1 0
   
@@ -902,6 +921,7 @@ 
   ==== qref -u -d
   # HG changeset patch
   # User john
+  # Node ID a0de5bf6e9f7aa226ac275bcf5f3781023a6d88e
   # Parent 
   # Date 15 0
   
diff --git a/tests/test-mq-header-from.t b/tests/test-mq-header-from.t
--- a/tests/test-mq-header-from.t
+++ b/tests/test-mq-header-from.t
@@ -442,6 +442,7 @@ 
   ==== qref
   adding 1
   # HG changeset patch
+  # Node ID 6f9a8477343b019f26127d73521da033e1c4a3fc
   # Parent 
   # User test
   # Date 1 0
@@ -454,6 +455,7 @@ 
   0: [mq]: 1.patch - test
   ==== qref -u
   # HG changeset patch
+  # Node ID b5fb1b74f7c3f2cc2570cb7df6bb949e5f4ee28d
   # Parent 
   # User mary
   # Date 1 0
@@ -467,6 +469,7 @@ 
   ==== qnew
   adding 2
   # HG changeset patch
+  # Node ID b64552836d98d192c7e1a78d07aca4616cae2adc
   # Parent 
   # Date 1 0
   
@@ -480,6 +483,7 @@ 
   ==== qref -u
   # HG changeset patch
   # User jane
+  # Node ID 2bb7e229348a21c6a8f40c1e31018bf895841d40
   # Parent 
   # Date 1 0
   
@@ -504,6 +508,7 @@ 
   ==== qref
   adding 3
   # HG changeset patch
+  # Node ID fbc8534f7d799473c32d2d81ddb2ea3097f5c97f
   # Parent 
   # User test
   # Date 1 0
@@ -520,6 +525,7 @@ 
   0: [mq]: 1.patch - mary
   ==== qref -m
   # HG changeset patch
+  # Node ID 3bbb4f6ec74d70c81c00c4a2b3686fdc8cdf9892
   # Parent 
   # User test
   # Date 1 0
@@ -536,6 +542,7 @@ 
   0: [mq]: 1.patch - mary
   ==== qref -u
   # HG changeset patch
+  # Node ID a94ee07d2f1094eadb3f1f35419f6d564003bac9
   # Parent 
   # User mary
   # Date 1 0
@@ -552,6 +559,7 @@ 
   0: [mq]: 1.patch - mary
   ==== qref -u -m
   # HG changeset patch
+  # Node ID edbb63251a84dd39aeeece909a46eb25756a25ea
   # Parent 
   # User maria
   # Date 1 0
@@ -569,6 +577,7 @@ 
   ==== qnew -m
   adding 4of
   # HG changeset patch
+  # Node ID 15179334451ac2359708a794687b15ee4883a63b
   # Parent 
   # Date 1 0
   
@@ -586,6 +595,7 @@ 
   ==== qref -u
   # HG changeset patch
   # User jane
+  # Node ID e3df474dd6bb4907d4a4a218b1c29161280256df
   # Parent 
   # Date 1 0
   
@@ -618,6 +628,7 @@ 
   Date: 1 0
   
   # HG changeset patch
+  # Node ID 19ebd8c5531d035fa3e3ed5487d8f58dc9c6f0bc
   # Parent 
   # User johndoe
   
@@ -635,6 +646,7 @@ 
   Date: 1 0
   
   # HG changeset patch
+  # Node ID e5256e5d83bb2e8e44e0db707e6ced373bd88cc0
   # Parent 
   # User test
   
@@ -652,6 +664,7 @@ 
   Date: 1 0
   
   # HG changeset patch
+  # Node ID 9e5babbc2c49d3cf3fb9436b840b67cf6032bb57
   # Parent 
   # User johndeere
   
@@ -758,6 +771,7 @@ 
   ==== qref
   adding 1
   # HG changeset patch
+  # Node ID 6f9a8477343b019f26127d73521da033e1c4a3fc
   # Parent 
   # User test
   # Date 1 0
@@ -770,6 +784,7 @@ 
   0: [mq]: 1.patch - test
   ==== qref -u
   # HG changeset patch
+  # Node ID b5fb1b74f7c3f2cc2570cb7df6bb949e5f4ee28d
   # Parent 
   # User mary
   # Date 1 0
@@ -783,6 +798,7 @@ 
   ==== qnew
   adding 2
   # HG changeset patch
+  # Node ID b64552836d98d192c7e1a78d07aca4616cae2adc
   # Parent 
   # Date 1 0
   
@@ -796,6 +812,7 @@ 
   ==== qref -u
   # HG changeset patch
   # User jane
+  # Node ID 2bb7e229348a21c6a8f40c1e31018bf895841d40
   # Parent 
   # Date 1 0
   
@@ -820,6 +837,7 @@ 
   ==== qref
   adding 3
   # HG changeset patch
+  # Node ID fbc8534f7d799473c32d2d81ddb2ea3097f5c97f
   # Parent 
   # User test
   # Date 1 0
@@ -836,6 +854,7 @@ 
   0: [mq]: 1.patch - mary
   ==== qref -m
   # HG changeset patch
+  # Node ID 3bbb4f6ec74d70c81c00c4a2b3686fdc8cdf9892
   # Parent 
   # User test
   # Date 1 0
@@ -852,6 +871,7 @@ 
   0: [mq]: 1.patch - mary
   ==== qref -u
   # HG changeset patch
+  # Node ID a94ee07d2f1094eadb3f1f35419f6d564003bac9
   # Parent 
   # User mary
   # Date 1 0
@@ -868,6 +888,7 @@ 
   0: [mq]: 1.patch - mary
   ==== qref -u -m
   # HG changeset patch
+  # Node ID edbb63251a84dd39aeeece909a46eb25756a25ea
   # Parent 
   # User maria
   # Date 1 0
@@ -885,6 +906,7 @@ 
   ==== qnew -m
   adding 4of
   # HG changeset patch
+  # Node ID 15179334451ac2359708a794687b15ee4883a63b
   # Parent 
   # Date 1 0
   
@@ -902,6 +924,7 @@ 
   ==== qref -u
   # HG changeset patch
   # User jane
+  # Node ID e3df474dd6bb4907d4a4a218b1c29161280256df
   # Parent 
   # Date 1 0
   
@@ -934,6 +957,7 @@ 
   Date: 1 0
   
   # HG changeset patch
+  # Node ID 19ebd8c5531d035fa3e3ed5487d8f58dc9c6f0bc
   # Parent 
   # User johndoe
   
@@ -951,6 +975,7 @@ 
   Date: 1 0
   
   # HG changeset patch
+  # Node ID e5256e5d83bb2e8e44e0db707e6ced373bd88cc0
   # Parent 
   # User test
   
@@ -968,6 +993,7 @@ 
   Date: 1 0
   
   # HG changeset patch
+  # Node ID 9e5babbc2c49d3cf3fb9436b840b67cf6032bb57
   # Parent 
   # User johndeere
   
diff --git a/tests/test-mq-qfold.t b/tests/test-mq-qfold.t
--- a/tests/test-mq-qfold.t
+++ b/tests/test-mq-qfold.t
@@ -89,6 +89,7 @@  Fold git patch into a regular patch, exp
 
   $ cat .hg/patches/regular
   # HG changeset patch
+  # Node ID 29f18cba15fbc2d0f714138c1cd740c245888702
   # Parent ???????????????????????????????????????? (glob)
   # Date 1 0
   
@@ -132,6 +133,7 @@  Fold regular patch into a git patch, exp
 
   $ cat .hg/patches/git
   # HG changeset patch
+  # Node ID 53c931819af246e79976515bac260ad86fc7ddc9
   # Parent ???????????????????????????????????????? (glob)
   # Date 1 0
   
diff --git a/tests/test-mq-qrefresh.t b/tests/test-mq-qrefresh.t
--- a/tests/test-mq-qrefresh.t
+++ b/tests/test-mq-qrefresh.t
@@ -51,6 +51,7 @@ 
 
   $ cat .hg/patches/mqbase
   # HG changeset patch
+  # Node ID 7e85c4e631533714a95964d49094220b322548b2
   # Parent e7af5904b465cd1f4f3cf6b26fe14e8db6f63eaa
   # Date 1 0
   
@@ -102,6 +103,7 @@ 
 
   $ cat .hg/patches/mqbase
   # HG changeset patch
+  # Node ID 2eae623b52e8c57bc38a51fe3599aa5d237c0d8e
   # Parent e7af5904b465cd1f4f3cf6b26fe14e8db6f63eaa
   # Date 1 0
   
@@ -148,6 +150,7 @@  qrefresh . in subdir:
 
   $ cat .hg/patches/mqbase
   # HG changeset patch
+  # Node ID 2eae623b52e8c57bc38a51fe3599aa5d237c0d8e
   # Parent e7af5904b465cd1f4f3cf6b26fe14e8db6f63eaa
   # Date 1 0
   
@@ -194,6 +197,7 @@  qrefresh in hg-root again:
 
   $ cat .hg/patches/mqbase
   # HG changeset patch
+  # Node ID 7e85c4e631533714a95964d49094220b322548b2
   # Parent e7af5904b465cd1f4f3cf6b26fe14e8db6f63eaa
   # Date 1 0
   
@@ -244,6 +248,7 @@  qrefresh --short tests:
 
   $ cat .hg/patches/mqbase
   # HG changeset patch
+  # Node ID 7e85c4e631533714a95964d49094220b322548b2
   # Parent e7af5904b465cd1f4f3cf6b26fe14e8db6f63eaa
   # Date 1 0
   
@@ -279,6 +284,7 @@  Before starting exclusive tests:
 
   $ cat .hg/patches/mqbase
   # HG changeset patch
+  # Node ID 7e85c4e631533714a95964d49094220b322548b2
   # Parent e7af5904b465cd1f4f3cf6b26fe14e8db6f63eaa
   # Date 1 0
   
@@ -303,6 +309,7 @@  Exclude 2/base:
 
   $ cat .hg/patches/mqbase
   # HG changeset patch
+  # Node ID 2eae623b52e8c57bc38a51fe3599aa5d237c0d8e
   # Parent e7af5904b465cd1f4f3cf6b26fe14e8db6f63eaa
   # Date 1 0
   
@@ -328,6 +335,7 @@  Remove 1/base and add 2/base again but n
 
   $ cat .hg/patches/mqbase
   # HG changeset patch
+  # Node ID a0ea3a0ac7938e7d6112e1f69965813a360d2b05
   # Parent e7af5904b465cd1f4f3cf6b26fe14e8db6f63eaa
   # Date 1 0
   
@@ -346,6 +354,7 @@  Add 1/base with include filter - and thu
 
   $ cat .hg/patches/mqbase
   # HG changeset patch
+  # Node ID 2eae623b52e8c57bc38a51fe3599aa5d237c0d8e
   # Parent e7af5904b465cd1f4f3cf6b26fe14e8db6f63eaa
   # Date 1 0
   
@@ -473,6 +482,7 @@  refresh with tip != qtip:
 
   $ cat .hg/patches/patch
   # HG changeset patch
+  # Node ID ac68f83fc28ec5409f69cc8f940569f94bc58243
   # Parent 1a60229be7ac3e4a7f647508e99b87bef1f03593
   # Date 1 0
   
diff --git a/tests/test-mq-qrename.t b/tests/test-mq-qrename.t
--- a/tests/test-mq-qrename.t
+++ b/tests/test-mq-qrename.t
@@ -115,6 +115,7 @@  Test renaming to a folded patch (issue30
   $ hg qmv addb
   $ cat .hg/patches/addb
   # HG changeset patch
+  # Node ID fc5600169097e484a3b390d361e74035ea897131
   # Parent 0000000000000000000000000000000000000000
   # Date 1 0
   
diff --git a/tests/test-mq-subrepo.t b/tests/test-mq-subrepo.t
--- a/tests/test-mq-subrepo.t
+++ b/tests/test-mq-subrepo.t
@@ -484,6 +484,7 @@  check whether qrefresh imports updated .
   # HG changeset patch
   # Date 0 0
   # User test
+  # Node ID d987bec230f4eaafa22d86e2f21a09fd110192fc
   # Parent 05b056bb9c8c05ff15258b84fd42ab3527271033
   
   diff -r 05b056bb9c8c .hgsubstate
@@ -509,6 +510,7 @@  check whether qrefresh imports updated .
   # HG changeset patch
   # Date 0 0
   # User test
+  # Node ID d987bec230f4eaafa22d86e2f21a09fd110192fc
   # Parent 05b056bb9c8c05ff15258b84fd42ab3527271033
   
   diff -r 05b056bb9c8c .hgsubstate
diff --git a/tests/test-mq2.t b/tests/test-mq2.t
--- a/tests/test-mq2.t
+++ b/tests/test-mq2.t
@@ -31,6 +31,7 @@ 
   $ hg qref -m b -d '47 0'
   $ cat .hg/patches/b
   # HG changeset patch
+  # Node ID 3506c28d72aa3a31f8ce50ca4cfcb812af131450
   # Parent cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
   # Date 47 0
   b
@@ -97,6 +98,7 @@ 
 
   $ cat .hg/patches/b
   # HG changeset patch
+  # Node ID 3506c28d72aa3a31f8ce50ca4cfcb812af131450
   # Parent cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
   # Date 47 0
   b
@@ -112,6 +114,7 @@ 
   now at: b
   $ cat .hg/patches/b
   # HG changeset patch
+  # Node ID 3506c28d72aa3a31f8ce50ca4cfcb812af131450
   # Parent cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
   # Date 47 0
   b