Patchwork [3,of,3,STABLE] rust: add comment about lack of wdirrev handling

login
register
mail settings
Submitter Yuya Nishihara
Date Jan. 20, 2019, 3:11 a.m.
Message ID <13c23396c7fe1633a233.1547953871@mimosa>
Download mbox | patch
Permalink /patch/37889/
State Accepted
Headers show

Comments

Yuya Nishihara - Jan. 20, 2019, 3:11 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1547953056 -32400
#      Sun Jan 20 11:57:36 2019 +0900
# Branch stable
# Node ID 13c23396c7fe1633a2336b29e3a32b9b76274f28
# Parent  66102f6fa10aa533a658532b198cd6879a538406
rust: add comment about lack of wdirrev handling

If hg is compiled with rust support, 'only(wdir())' crashed as
"rustext.GraphError: ('ParentOutOfRange', 2147483647)", which should instead
say "abort: working directory revision cannot be specified."
via Mercurial-devel - Jan. 20, 2019, 5:51 a.m.
On Sat, Jan 19, 2019 at 7:16 PM Yuya Nishihara <yuya@tcha.org> wrote:

> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1547953056 -32400
> #      Sun Jan 20 11:57:36 2019 +0900
> # Branch stable
> # Node ID 13c23396c7fe1633a2336b29e3a32b9b76274f28
> # Parent  66102f6fa10aa533a658532b198cd6879a538406
> rust: add comment about lack of wdirrev handling
>

Queued these, thanks.
Georges Racinet - Jan. 21, 2019, 4 p.m.
Le 20 janvier 2019 04:11:11 GMT+01:00, Yuya Nishihara <yuya@tcha.org> a écrit :
># HG changeset patch
># User Yuya Nishihara <yuya@tcha.org>
># Date 1547953056 -32400
>#      Sun Jan 20 11:57:36 2019 +0900
># Branch stable
># Node ID 13c23396c7fe1633a2336b29e3a32b9b76274f28
># Parent  66102f6fa10aa533a658532b198cd6879a538406
>rust: add comment about lack of wdirrev handling
>
>If hg is compiled with rust support, 'only(wdir())' crashed as
>"rustext.GraphError: ('ParentOutOfRange', 2147483647)", which should
>instead
>say "abort: working directory revision cannot be specified."

I can fix that easily if you like, and it seems possible to me that rust-core could get awareness of wdirrev and that rust-cpython would raise the proper exception.

If that's too much for the stable branch, a simple try/except as is already done in the C case would be enough.


>
>diff --git a/mercurial/revlog.py b/mercurial/revlog.py
>--- a/mercurial/revlog.py
>+++ b/mercurial/revlog.py
>@@ -896,6 +896,8 @@ class revlog(object):
>             common = [nullrev]
> 
>         if rustext is not None:
>+            # TODO: WdirUnsupported should be raised instead of
>GraphError
>+            # if common includes wdirrev
>           return rustext.ancestor.MissingAncestors(self.index, common)
>   return ancestor.incrementalmissingancestors(self.parentrevs, common)
> 
>_______________________________________________
>Mercurial-devel mailing list
>Mercurial-devel@mercurial-scm.org
>https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Yuya Nishihara - Jan. 21, 2019, 10:42 p.m.
On Mon, 21 Jan 2019 17:00:38 +0100, Georges Racinet wrote:
> Le 20 janvier 2019 04:11:11 GMT+01:00, Yuya Nishihara <yuya@tcha.org> a écrit :
> ># HG changeset patch
> ># User Yuya Nishihara <yuya@tcha.org>
> ># Date 1547953056 -32400
> >#      Sun Jan 20 11:57:36 2019 +0900
> ># Branch stable
> ># Node ID 13c23396c7fe1633a2336b29e3a32b9b76274f28
> ># Parent  66102f6fa10aa533a658532b198cd6879a538406
> >rust: add comment about lack of wdirrev handling
> >
> >If hg is compiled with rust support, 'only(wdir())' crashed as
> >"rustext.GraphError: ('ParentOutOfRange', 2147483647)", which should
> >instead
> >say "abort: working directory revision cannot be specified."
> 
> I can fix that easily if you like, and it seems possible to me that rust-core could get awareness of wdirrev and that rust-cpython would raise the proper exception.
> 
> If that's too much for the stable branch, a simple try/except as is already done in the C case would be enough.

Thanks. I think it's better to translate wdirrev to error in Rust part.
try-catch won't be viable solution as Rust core gets more laziness and
object APIs.

Patch

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -896,6 +896,8 @@  class revlog(object):
             common = [nullrev]
 
         if rustext is not None:
+            # TODO: WdirUnsupported should be raised instead of GraphError
+            # if common includes wdirrev
             return rustext.ancestor.MissingAncestors(self.index, common)
         return ancestor.incrementalmissingancestors(self.parentrevs, common)