Patchwork [V2] destutil: use scmutil.revrange for desthistedit (issue5001)

login
register
mail settings
Submitter Gregory Szorc
Date Dec. 26, 2015, 6:28 p.m.
Message ID <12e6ed23056d657aee19.1451154486@gps-mbp.local>
Download mbox | patch
Permalink /patch/12357/
State Accepted
Headers show

Comments

Gregory Szorc - Dec. 26, 2015, 6:28 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1450980990 28800
#      Thu Dec 24 10:16:30 2015 -0800
# Node ID 12e6ed23056d657aee19969b140bc1b2d5ad0b47
# Parent  e2aa9c4030c4109e5efa50462ffc6048ca30106f
destutil: use scmutil.revrange for desthistedit (issue5001)

This allows user aliases to be expanded. It also prevents the
user-provided revset from being treated as a revset expression.
Augie Fackler - Dec. 29, 2015, 10:23 p.m.
On Sat, Dec 26, 2015 at 11:28:06AM -0700, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@gmail.com>
> # Date 1450980990 28800
> #      Thu Dec 24 10:16:30 2015 -0800
> # Node ID 12e6ed23056d657aee19969b140bc1b2d5ad0b47
> # Parent  e2aa9c4030c4109e5efa50462ffc6048ca30106f
> destutil: use scmutil.revrange for desthistedit (issue5001)

Queued with delight, thanks!

>
> This allows user aliases to be expanded. It also prevents the
> user-provided revset from being treated as a revset expression.
>
> diff --git a/mercurial/destutil.py b/mercurial/destutil.py
> --- a/mercurial/destutil.py
> +++ b/mercurial/destutil.py
> @@ -204,11 +204,14 @@ def destmerge(repo):
>  histeditdefaultrevset = 'reverse(only(.) and not public() and not ::merge())'
>
>  def desthistedit(ui, repo):
>      """Default base revision to edit for `hg histedit`."""
> +    # Avoid cycle: scmutil -> revset -> destutil
> +    from . import scmutil
> +
>      default = ui.config('histedit', 'defaultrev', histeditdefaultrevset)
>      if default:
> -        revs = repo.revs(default)
> +        revs = scmutil.revrange(repo, [default])
>          if revs:
>              # The revset supplied by the user may not be in ascending order nor
>              # take the first revision. So do this manually.
>              revs.sort()
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/destutil.py b/mercurial/destutil.py
--- a/mercurial/destutil.py
+++ b/mercurial/destutil.py
@@ -204,11 +204,14 @@  def destmerge(repo):
 histeditdefaultrevset = 'reverse(only(.) and not public() and not ::merge())'
 
 def desthistedit(ui, repo):
     """Default base revision to edit for `hg histedit`."""
+    # Avoid cycle: scmutil -> revset -> destutil
+    from . import scmutil
+
     default = ui.config('histedit', 'defaultrev', histeditdefaultrevset)
     if default:
-        revs = repo.revs(default)
+        revs = scmutil.revrange(repo, [default])
         if revs:
             # The revset supplied by the user may not be in ascending order nor
             # take the first revision. So do this manually.
             revs.sort()