Patchwork metadataonlyctx: replace "changeset()[0]" to "manifestnode()"

login
register
mail settings
Submitter Jun Wu
Date April 7, 2017, 6:10 p.m.
Message ID <0d57661098e3f93e7d1a.1491588630@x1c>
Download mbox | patch
Permalink /patch/20005/
State Accepted
Headers show

Comments

Jun Wu - April 7, 2017, 6:10 p.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1491588163 25200
#      Fri Apr 07 11:02:43 2017 -0700
# Node ID 0d57661098e3f93e7d1ab4e206d87d39c6ce4f84
# Parent  c39e7c4b535c654d5b2f7790efebff2909986a04
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 0d57661098e3
metadataonlyctx: replace "changeset()[0]" to "manifestnode()"

As Yuya pointed out [1], "changeset()[0]" could be simplified to
"manifestnode()". I didn't notice that method earlier. It should definitely
be used - it's easier to read, and faster.

[1]: https://www.mercurial-scm.org/pipermail/mercurial-devel/2017-March/095716.html
Yuya Nishihara - April 8, 2017, 7:34 a.m.
On Fri, 7 Apr 2017 11:10:30 -0700, Jun Wu wrote:
> # HG changeset patch
> # User Jun Wu <quark@fb.com>
> # Date 1491588163 25200
> #      Fri Apr 07 11:02:43 2017 -0700
> # Node ID 0d57661098e3f93e7d1ab4e206d87d39c6ce4f84
> # Parent  c39e7c4b535c654d5b2f7790efebff2909986a04
> # Available At https://bitbucket.org/quark-zju/hg-draft
> #              hg pull https://bitbucket.org/quark-zju/hg-draft -r 0d57661098e3
> metadataonlyctx: replace "changeset()[0]" to "manifestnode()"

Queued, thanks.

I hesitated to change that in flight since metadataonlyctx appeared not
covered by tests. ;)

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -2055,8 +2055,8 @@  class metadataonlyctx(committablectx):
         # manifests of our commit parents
         mp1, mp2 = self.manifestctx().parents
-        if p1 != nullid and p1.changeset()[0] != mp1:
+        if p1 != nullid and p1.manifestnode() != mp1:
             raise RuntimeError('can\'t reuse the manifest: '
                                'its p1 doesn\'t match the new ctx p1')
-        if p2 != nullid and p2.changeset()[0] != mp2:
+        if p2 != nullid and p2.manifestnode() != mp2:
             raise RuntimeError('can\'t reuse the manifest: '
                                'its p2 doesn\'t match the new ctx p2')