[PATCH 1 of 8] ui: path option to declare which revisions to push by default
Pulkit Goyal
7895pulkit at gmail.com
Mon Jun 27 09:45:27 EDT 2016
Ignore this series as I messed with some merges.
On Mon, Jun 27, 2016 at 7:13 PM, Pulkit Goyal <7895pulkit at gmail.com> wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc at gmail.com>
> # Date 1466905662 25200
> # Sat Jun 25 18:47:42 2016 -0700
> # Node ID 4d9dd700e77bdfdbc2d68b07e9e8746bc9cff105
> # Parent b62bce819d0cafcd94e3838e97062b42c9cb13b2
> ui: path option to declare which revisions to push by default
>
> Now that we have a mechanism for declaring path sub-options, we can
> start to pile on features!
>
> Many power users have expressed frustration that bare `hg push`
> attempts to push all local revisions to the remote. This patch
> introduces the "pushrev" path sub-option to control which revisions
> are pushed when no "-r" argument is specified.
>
> The value of this sub-option is a revset, naturally.
>
> A future feature addition could potentially introduce a "pushnames"
> sub-options that declares the list of names (branches, bookmarks,
> topics, etc) to push by default. The entire "what to push by default"
> feature should probably be considered before this patch lands.
>
> diff -r b62bce819d0c -r 4d9dd700e77b mercurial/commands.py
> --- a/mercurial/commands.py Sat Jun 25 18:35:14 2016 -0700
> +++ b/mercurial/commands.py Sat Jun 25 18:47:42 2016 -0700
> @@ -5942,6 +5942,14 @@
> if not revs:
> raise error.Abort(_("specified revisions evaluate to an empty set"),
> hint=_("use different revision arguments"))
> + elif path.pushrev:
> + # It doesn't make any sense to specify ancestor revisions. So limit
> + # to DAG heads to make discovery simpler.
> + revs = scmutil.revrange(repo, ['heads(%s)' % path.pushrev])
> + revs = [repo[rev].node() for rev in revs]
> + if not revs:
> + raise error.Abort(_('default push revset for path evaluates to an '
> + 'empty set'))
>
> repo._subtoppath = dest
> try:
> diff -r b62bce819d0c -r 4d9dd700e77b mercurial/help/config.txt
> --- a/mercurial/help/config.txt Sat Jun 25 18:35:14 2016 -0700
> +++ b/mercurial/help/config.txt Sat Jun 25 18:47:42 2016 -0700
> @@ -1282,6 +1282,15 @@
> The URL to use for push operations. If not defined, the location
> defined by the path's main entry is used.
>
> +``pushrev``
> + A revset defining which revisions to push by default.
> +
> + When :hg:`push` is executed without a ``-r`` argument, the revset
> + defined by this sub-option is evaluated to determine what to push.
> +
> + For example, a value of ``.`` will push the working directory's
> + revision by default.
> +
> The following special named paths exist:
>
> ``default``
> diff -r b62bce819d0c -r 4d9dd700e77b mercurial/ui.py
> --- a/mercurial/ui.py Sat Jun 25 18:35:14 2016 -0700
> +++ b/mercurial/ui.py Sat Jun 25 18:47:42 2016 -0700
> @@ -1281,6 +1281,10 @@
>
> return str(u)
>
> + at pathsuboption('pushrev', 'pushrev')
> +def pushrevpathoption(ui, path, value):
> + return value
> +
> class path(object):
> """Represents an individual path and its configuration."""
>
> diff -r b62bce819d0c -r 4d9dd700e77b tests/test-default-push.t
> --- a/tests/test-default-push.t Sat Jun 25 18:35:14 2016 -0700
> +++ b/tests/test-default-push.t Sat Jun 25 18:47:42 2016 -0700
> @@ -105,4 +105,31 @@
> adding file changes
> added 1 changesets with 1 changes to 1 files
>
> +:pushrev is used when no -r is passed
> +
> + $ cat >> .hg/hgrc << EOF
> + > default:pushrev = .
> + > EOF
> + $ hg -q up -r 0
> + $ echo head1 > foo
> + $ hg -q commit -A -m head1
> + $ hg -q up -r 0
> + $ echo head2 > foo
> + $ hg -q commit -A -m head2
> + $ hg push -f
> + pushing to file:/*/$TESTTMP/pushurlsource/../pushurldest (glob)
> + searching for changes
> + adding changesets
> + adding manifests
> + adding file changes
> + added 1 changesets with 1 changes to 1 files (+1 heads)
> +
> + $ hg --config 'paths.default:pushrev=draft()' push -f
> + pushing to file:/*/$TESTTMP/pushurlsource/../pushurldest (glob)
> + searching for changes
> + adding changesets
> + adding manifests
> + adding file changes
> + added 1 changesets with 1 changes to 1 files (+1 heads)
> +
> $ cd ..
> diff -r b62bce819d0c -r 4d9dd700e77b tests/test-help.t
> --- a/tests/test-help.t Sat Jun 25 18:35:14 2016 -0700
> +++ b/tests/test-help.t Sat Jun 25 18:47:42 2016 -0700
> @@ -1515,6 +1515,15 @@
> The URL to use for push operations. If not defined, the location
> defined by the path's main entry is used.
>
> + "pushrev"
> + A revset defining which revisions to push by default.
> +
> + When 'hg push' is executed without a "-r" argument, the revset defined
> + by this sub-option is evaluated to determine what to push.
> +
> + For example, a value of "." will push the working directory's revision
> + by default.
> +
> The following special named paths exist:
>
> "default"
More information about the Mercurial-devel
mailing list