[PATCH 1 of 3] error: add a new exception named WdirRevNotSupportedError

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH 1 of 3] error: add a new exception named WdirRevNotSupportedError

Pulkit Goyal
# HG changeset patch
# User Pulkit Goyal <[hidden email]>
# Date 1495201237 -19800
#      Fri May 19 19:10:37 2017 +0530
# Node ID 10bab5388a7f11060a76c10d28d60578b428fdb0
# Parent  67026d65a4fcea1a121930b9736469687c095e3e
error: add a new exception named WdirRevNotSupportedError

This error will be raised when we try to use the 'wdir()' revset and support
for it has not added yet.

diff --git a/mercurial/error.py b/mercurial/error.py
--- a/mercurial/error.py
+++ b/mercurial/error.py
@@ -177,6 +177,9 @@
 class ProgrammingError(RuntimeError):
     """Raised if a mercurial (core or extension) developer made a mistake"""
 
+class WdirRevNotSupportedError(IndexError):
+    """An exception which is raised when 'wdir()' is not supported"""
+
 # bundle2 related errors
 class BundleValueError(ValueError):
     """error raised when bundle2 cannot be processed"""
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

[PATCH 2 of 3] revlog: raise WdirRevNotSupportedError when wdirrev is passed

Pulkit Goyal
# HG changeset patch
# User Pulkit Goyal <[hidden email]>
# Date 1495201326 -19800
#      Fri May 19 19:12:06 2017 +0530
# Node ID e2a67243cdbcfef442f53ac8a566c91b9e34a93d
# Parent  10bab5388a7f11060a76c10d28d60578b428fdb0
revlog: raise WdirRevNotSupportedError when wdirrev is passed

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -26,6 +26,7 @@
     hex,
     nullid,
     nullrev,
+    wdirrev,
 )
 from .i18n import _
 from . import (
@@ -475,7 +476,12 @@
         return self.index[rev][4]
 
     def parentrevs(self, rev):
-        return self.index[rev][5:7]
+        try:
+            return self.index[rev][5:7]
+        except IndexError:
+            if rev == wdirrev:
+                raise error.WdirRevNotSupportedError()
+            raise
 
     def node(self, rev):
         return self.index[rev][7]
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

[PATCH 3 of 3] revset: make `hg log -r 'wdir()^'` work (issue4905)

Pulkit Goyal
In reply to this post by Pulkit Goyal
# HG changeset patch
# User Pulkit Goyal <[hidden email]>
# Date 1495204605 -19800
#      Fri May 19 20:06:45 2017 +0530
# Node ID 9310019e4eb9ae6e7d740da88d89112ce85f7dd0
# Parent  e2a67243cdbcfef442f53ac8a566c91b9e34a93d
revset: make `hg log -r 'wdir()^'` work (issue4905)

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -1408,7 +1408,10 @@
     ps = set()
     cl = repo.changelog
     for r in getset(repo, fullreposet(repo), x):
-        ps.add(cl.parentrevs(r)[0])
+        try:
+            ps.add(cl.parentrevs(r)[0])
+        except error.WdirRevNotSupportedError:
+            ps.add(repo[r].parents()[0].rev())
     ps -= {node.nullrev}
     # XXX we should turn this into a baseset instead of a set, smartset may do
     # some optimizations from the fact this is a baseset.
diff --git a/tests/test-revset.t b/tests/test-revset.t
--- a/tests/test-revset.t
+++ b/tests/test-revset.t
@@ -1221,6 +1221,15 @@
 Test working-directory revision
   $ hg debugrevspec 'wdir()'
   2147483647
+  $ hg debugrevspec 'wdir()^'
+  9
+  $ hg up 7
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ hg debugrevspec 'wdir()^'
+  7
+For tests consistency
+  $ hg up 9
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg debugrevspec 'tip or wdir()'
   9
   2147483647
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 1 of 3] error: add a new exception named WdirRevNotSupportedError

Yuya Nishihara
In reply to this post by Pulkit Goyal
On Fri, 19 May 2017 20:37:52 +0530, Pulkit Goyal wrote:
> # HG changeset patch
> # User Pulkit Goyal <[hidden email]>
> # Date 1495201237 -19800
> #      Fri May 19 19:10:37 2017 +0530
> # Node ID 10bab5388a7f11060a76c10d28d60578b428fdb0
> # Parent  67026d65a4fcea1a121930b9736469687c095e3e
> error: add a new exception named WdirRevNotSupportedError

general direction seems fine and is quite similar to my draft patches.
Can you include more details in commit message? (e.g. why it makes sense
to raise an exception.)

> --- a/mercurial/error.py
> +++ b/mercurial/error.py
> @@ -177,6 +177,9 @@
>  class ProgrammingError(RuntimeError):
>      """Raised if a mercurial (core or extension) developer made a mistake"""
>  
> +class WdirRevNotSupportedError(IndexError):
> +    """An exception which is raised when 'wdir()' is not supported"""

Nit: Strictly speaking, this isn't an error but an indication that a storage
class can't process wdir() so upper layer should do in place. So I would name
it WdirUnsupported or something, and make it not be inherited from IndexError.
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 1 of 3] error: add a new exception named WdirRevNotSupportedError

Pulkit Goyal


On Sun, May 21, 2017 at 5:30 PM, Yuya Nishihara <[hidden email]> wrote:
On Fri, 19 May 2017 20:37:52 +0530, Pulkit Goyal wrote:
> # HG changeset patch
> # User Pulkit Goyal <[hidden email]>
> # Date 1495201237 -19800
> #      Fri May 19 19:10:37 2017 +0530
> # Node ID 10bab5388a7f11060a76c10d28d60578b428fdb0
> # Parent  67026d65a4fcea1a121930b9736469687c095e3e
> error: add a new exception named WdirRevNotSupportedError

general direction seems fine and is quite similar to my draft patches.
Can you include more details in commit message? (e.g. why it makes sense
to raise an exception.)

​The direction is motivated from your comments on the previous series which was send couple of months ago.
I will make commit message more descriptive in V2.​
 

_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 1 of 3] error: add a new exception named WdirRevNotSupportedError

Yuya Nishihara
On Sun, 21 May 2017 18:40:17 +0530, Pulkit Goyal wrote:

> On Sun, May 21, 2017 at 5:30 PM, Yuya Nishihara <[hidden email]> wrote:
> > On Fri, 19 May 2017 20:37:52 +0530, Pulkit Goyal wrote:
> > > # HG changeset patch
> > > # User Pulkit Goyal <[hidden email]>
> > > # Date 1495201237 -19800
> > > #      Fri May 19 19:10:37 2017 +0530
> > > # Node ID 10bab5388a7f11060a76c10d28d60578b428fdb0
> > > # Parent  67026d65a4fcea1a121930b9736469687c095e3e
> > > error: add a new exception named WdirRevNotSupportedError
> >
> > general direction seems fine and is quite similar to my draft patches.
> > Can you include more details in commit message? (e.g. why it makes sense
> > to raise an exception.)
>
> ​The direction is motivated from your comments on the previous series which
> was send couple of months ago.

Yeah, I was doing some experiment last summer, and lost time to see how well
that would work and how ugly that would be. We'll also need to handle the
ff... hash, which is another hard thing.

> I will make commit message more descriptive in V2.​

Thanks.
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel