[PATCH] revset: add update() revset to return target rev for 'hg update'

Matt Mackall mpm at selenic.com
Sat Feb 9 15:55:50 CST 2013


On Sat, 2013-02-09 at 21:46 +0000, Kevin Bullock wrote:
> # HG changeset patch
> # User Kevin Bullock <kbullock at ringworld.org>
> # Date 1360405949 0
> # Node ID 57ba45c914886c80342df5d0f130fbc72780f2e7
> # Parent  9d727e125244520c4fe60a4b8d60e29269d24af3
> revset: add update() revset to return target rev for 'hg update'
> 
> diff --git a/mercurial/revset.py b/mercurial/revset.py
> --- a/mercurial/revset.py
> +++ b/mercurial/revset.py
> @@ -13,6 +13,7 @@ from i18n import _
>  import encoding
>  import obsolete as obsmod
>  import repoview
> +import bookmarks, scmutil

Hrm, circular import.

>  def _revancestors(repo, revs, followfirst):
>      """Like revlog.ancestors(), but supports followfirst."""
> @@ -1514,6 +1515,15 @@ def unstable(repo, subset, x):
>      unstables = obsmod.getrevs(repo, 'unstable')
>      return [r for r in subset if r in unstables]
>  
> +def update(repo, subset, x):
> +    """``update()``
> +    The target revisions that a bare 'hg update' will update to.
> +    """
> +    if repo._bookmarkcurrent and not bookmarks.iscurrent(repo):
> +        target = repo._bookmarks[repo._bookmarkcurrent].rev()
> +    target = scmutil.revsingle(repo, None, 'tip').rev()

Hmm. don't see how this deals with the current branch.

> +    repo.ui.debug(repr(target) + '\n')

Left-over?

> +    return [r for r in subset if r == target]
>  
>  def user(repo, subset, x):
>      """``user(string)``
> @@ -1600,6 +1610,7 @@ symbols = {
>      "tagged": tagged,
>      "user": user,
>      "unstable": unstable,
> +    "update": update,
>      "_list": _list,
>  }
>  
> diff --git a/tests/test-revset.t b/tests/test-revset.t
> --- a/tests/test-revset.t
> +++ b/tests/test-revset.t
> @@ -446,6 +446,11 @@ we can use patterns when searching for t
>    $ log 'branch(unknown)'
>    abort: unknown revision 'unknown'!
>    [255]
> +  $ log 'update()'
> +  9
> +  $ hg up 8
> +  $ log 'update()'
> +  9
>    $ log 'user(bob)'
>    2
>  
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel


-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list