Patchwork [STABLE] push: restore old behavior of default-push (issue5000)

login
register
mail settings
Submitter Yuya Nishihara
Date Dec. 26, 2015, 12:02 p.m.
Message ID <11ec0887bf0e7b1cdc13.1451131340@mimosa>
Download mbox | patch
Permalink /patch/12353/
State Accepted
Headers show

Comments

Yuya Nishihara - Dec. 26, 2015, 12:02 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1451110696 -32400
#      Sat Dec 26 15:18:16 2015 +0900
# Branch stable
# Node ID 11ec0887bf0e7b1cdc13996fab9cbd1fae0b5c52
# Parent  707cdf2c370093601865bc4a489fbc3e1b167aa0
push: restore old behavior of default-push (issue5000)

This effectively backs out dceaef70e410 and 10917b062adf.

We can't handle "default-push" just like "default:pushurl" because it is a
stand-alone named path. Instead, I have two ideas to work around the issue:

 a. two defaults: getpath(dest, default=('default-push', 'default'))
 b. virtual path: getpath(dest, default=':default')

(a) is conservative approach and will have less trouble, but callers have
to specify they need "default-push" or "default". (b) generates hidden
":default" path from "default" and "default-push", and callers request
":default". This will require some tricks and won't work if there are
conflicting sub-options valid for both "pull" and "push".

I'll take (a) for default branch. This patch should NOT BE MERGED to default
except for tests because it would break handling of "pushurl" sub-option.
Gregory Szorc - Dec. 26, 2015, 5:32 p.m.
> On Dec 26, 2015, at 05:02, Yuya Nishihara <yuya@tcha.org> wrote:
> 
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1451110696 -32400
> #      Sat Dec 26 15:18:16 2015 +0900
> # Branch stable
> # Node ID 11ec0887bf0e7b1cdc13996fab9cbd1fae0b5c52
> # Parent  707cdf2c370093601865bc4a489fbc3e1b167aa0
> push: restore old behavior of default-push (issue5000)

This patch LGTM for stable.

> 
> This effectively backs out dceaef70e410 and 10917b062adf.
> 
> We can't handle "default-push" just like "default:pushurl" because it is a
> stand-alone named path. Instead, I have two ideas to work around the issue:
> 
> a. two defaults: getpath(dest, default=('default-push', 'default'))
> b. virtual path: getpath(dest, default=':default')
> 
> (a) is conservative approach and will have less trouble, but callers have
> to specify they need "default-push" or "default". (b) generates hidden
> ":default" path from "default" and "default-push", and callers request
> ":default". This will require some tricks and won't work if there are
> conflicting sub-options valid for both "pull" and "push".
> 
> I'll take (a) for default branch. This patch should NOT BE MERGED to default
> except for tests because it would break handling of "pushurl" sub-option.
> 
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -5394,11 +5394,13 @@ def push(ui, repo, dest=None, **opts):
>                 # this lets simultaneous -r, -b options continue working
>                 opts.setdefault('rev', []).append("null")
> 
> -    path = ui.paths.getpath(dest, default='default')
> +    path = ui.paths.getpath(dest, default='default-push')
> +    if not path:
> +        path = ui.paths.getpath(dest, default='default')
>     if not path:
>         raise error.Abort(_('default repository not configured!'),
>                          hint=_('see the "path" section in "hg help config"'))
> -    dest, branches = path.pushloc, (path.branch, opts.get('branch') or [])
> +    dest, branches = path.loc, (path.branch, opts.get('branch') or [])
>     ui.status(_('pushing to %s\n') % util.hidepassword(dest))
>     revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev'))
>     other = hg.peer(repo, opts, dest)
> diff --git a/tests/test-default-push.t b/tests/test-default-push.t
> --- a/tests/test-default-push.t
> +++ b/tests/test-default-push.t
> @@ -46,6 +46,14 @@ Push should push to 'default-push' when 
>   adding file changes
>   added 1 changesets with 1 changes to 1 files
> 
> +But push should push to 'default' if explicitly specified (issue5000):
> +
> +  $ hg --cwd b push default
> +  pushing to $TESTTMP/a (glob)
> +  searching for changes
> +  no changes found
> +  [1]
> +
> Push should push to 'default-push' when 'default' is not set
> 
>   $ hg -q clone a push-default-only
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel
Sean Farley - Dec. 26, 2015, 9:18 p.m.
Yuya Nishihara <yuya@tcha.org> writes:

> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1451110696 -32400
> #      Sat Dec 26 15:18:16 2015 +0900
> # Branch stable
> # Node ID 11ec0887bf0e7b1cdc13996fab9cbd1fae0b5c52
> # Parent  707cdf2c370093601865bc4a489fbc3e1b167aa0
> push: restore old behavior of default-push (issue5000)
>
> This effectively backs out dceaef70e410 and 10917b062adf.
>
> We can't handle "default-push" just like "default:pushurl" because it is a
> stand-alone named path. Instead, I have two ideas to work around the issue:
>
>  a. two defaults: getpath(dest, default=('default-push', 'default'))
>  b. virtual path: getpath(dest, default=':default')
>
> (a) is conservative approach and will have less trouble, but callers have
> to specify they need "default-push" or "default". (b) generates hidden
> ":default" path from "default" and "default-push", and callers request
> ":default". This will require some tricks and won't work if there are
> conflicting sub-options valid for both "pull" and "push".
>
> I'll take (a) for default branch. This patch should NOT BE MERGED to default
> except for tests because it would break handling of "pushurl" sub-option.

I think you mean 'for stable branch'?
Yuya Nishihara - Dec. 27, 2015, 4:29 p.m.
On Sat, 26 Dec 2015 15:18:42 -0600, Sean Farley wrote:
> Yuya Nishihara <yuya@tcha.org> writes:
> > # HG changeset patch
> > # User Yuya Nishihara <yuya@tcha.org>
> > # Date 1451110696 -32400
> > #      Sat Dec 26 15:18:16 2015 +0900
> > # Branch stable
> > # Node ID 11ec0887bf0e7b1cdc13996fab9cbd1fae0b5c52
> > # Parent  707cdf2c370093601865bc4a489fbc3e1b167aa0
> > push: restore old behavior of default-push (issue5000)
> >
> > This effectively backs out dceaef70e410 and 10917b062adf.
> >
> > We can't handle "default-push" just like "default:pushurl" because it is a
> > stand-alone named path. Instead, I have two ideas to work around the issue:
> >
> >  a. two defaults: getpath(dest, default=('default-push', 'default'))
> >  b. virtual path: getpath(dest, default=':default')
> >
> > (a) is conservative approach and will have less trouble, but callers have
> > to specify they need "default-push" or "default". (b) generates hidden
> > ":default" path from "default" and "default-push", and callers request
> > ":default". This will require some tricks and won't work if there are
> > conflicting sub-options valid for both "pull" and "push".
> >
> > I'll take (a) for default branch. This patch should NOT BE MERGED to default
> > except for tests because it would break handling of "pushurl" sub-option.
> 
> I think you mean 'for stable branch'?

I meant

 - this patch for stable,
 - (a) for default
 - this patch and (a) will conflict, so
  - pick (a) for commands.py
  - pick this patch for test-default-push.t

Sorry for confusion.
Augie Fackler - Dec. 29, 2015, 10:43 p.m.
On Sat, Dec 26, 2015 at 09:02:20PM +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1451110696 -32400
> #      Sat Dec 26 15:18:16 2015 +0900
> # Branch stable
> # Node ID 11ec0887bf0e7b1cdc13996fab9cbd1fae0b5c52
> # Parent  707cdf2c370093601865bc4a489fbc3e1b167aa0
> push: restore old behavior of default-push (issue5000)

Queued for stable per indygreg.

>
> This effectively backs out dceaef70e410 and 10917b062adf.
>
> We can't handle "default-push" just like "default:pushurl" because it is a
> stand-alone named path. Instead, I have two ideas to work around the issue:
>
>  a. two defaults: getpath(dest, default=('default-push', 'default'))
>  b. virtual path: getpath(dest, default=':default')
>
> (a) is conservative approach and will have less trouble, but callers have
> to specify they need "default-push" or "default". (b) generates hidden
> ":default" path from "default" and "default-push", and callers request
> ":default". This will require some tricks and won't work if there are
> conflicting sub-options valid for both "pull" and "push".
>
> I'll take (a) for default branch. This patch should NOT BE MERGED to default
> except for tests because it would break handling of "pushurl" sub-option.
>
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -5394,11 +5394,13 @@ def push(ui, repo, dest=None, **opts):
>                  # this lets simultaneous -r, -b options continue working
>                  opts.setdefault('rev', []).append("null")
>
> -    path = ui.paths.getpath(dest, default='default')
> +    path = ui.paths.getpath(dest, default='default-push')
> +    if not path:
> +        path = ui.paths.getpath(dest, default='default')
>      if not path:
>          raise error.Abort(_('default repository not configured!'),
>                           hint=_('see the "path" section in "hg help config"'))
> -    dest, branches = path.pushloc, (path.branch, opts.get('branch') or [])
> +    dest, branches = path.loc, (path.branch, opts.get('branch') or [])
>      ui.status(_('pushing to %s\n') % util.hidepassword(dest))
>      revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev'))
>      other = hg.peer(repo, opts, dest)
> diff --git a/tests/test-default-push.t b/tests/test-default-push.t
> --- a/tests/test-default-push.t
> +++ b/tests/test-default-push.t
> @@ -46,6 +46,14 @@ Push should push to 'default-push' when
>    adding file changes
>    added 1 changesets with 1 changes to 1 files
>
> +But push should push to 'default' if explicitly specified (issue5000):
> +
> +  $ hg --cwd b push default
> +  pushing to $TESTTMP/a (glob)
> +  searching for changes
> +  no changes found
> +  [1]
> +
>  Push should push to 'default-push' when 'default' is not set
>
>    $ hg -q clone a push-default-only
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -5394,11 +5394,13 @@  def push(ui, repo, dest=None, **opts):
                 # this lets simultaneous -r, -b options continue working
                 opts.setdefault('rev', []).append("null")
 
-    path = ui.paths.getpath(dest, default='default')
+    path = ui.paths.getpath(dest, default='default-push')
+    if not path:
+        path = ui.paths.getpath(dest, default='default')
     if not path:
         raise error.Abort(_('default repository not configured!'),
                          hint=_('see the "path" section in "hg help config"'))
-    dest, branches = path.pushloc, (path.branch, opts.get('branch') or [])
+    dest, branches = path.loc, (path.branch, opts.get('branch') or [])
     ui.status(_('pushing to %s\n') % util.hidepassword(dest))
     revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev'))
     other = hg.peer(repo, opts, dest)
diff --git a/tests/test-default-push.t b/tests/test-default-push.t
--- a/tests/test-default-push.t
+++ b/tests/test-default-push.t
@@ -46,6 +46,14 @@  Push should push to 'default-push' when 
   adding file changes
   added 1 changesets with 1 changes to 1 files
 
+But push should push to 'default' if explicitly specified (issue5000):
+
+  $ hg --cwd b push default
+  pushing to $TESTTMP/a (glob)
+  searching for changes
+  no changes found
+  [1]
+
 Push should push to 'default-push' when 'default' is not set
 
   $ hg -q clone a push-default-only