Patchwork [3,of,3] paths: do not process default-push as pushurl of default path (issue5000)

login
register
mail settings
Submitter Yuya Nishihara
Date Dec. 26, 2015, 12:06 p.m.
Message ID <8b1635a5baefbe613290.1451131606@mimosa>
Download mbox | patch
Permalink /patch/12356/
State Accepted
Headers show

Comments

Yuya Nishihara - Dec. 26, 2015, 12:06 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1451113572 -32400
#      Sat Dec 26 16:06:12 2015 +0900
# Node ID 8b1635a5baefbe613290d9030d729c464c8d9894
# Parent  cfbbc41a45b1ddc0d2d44e655e6b1c124174228f
paths: do not process default-push as pushurl of default path (issue5000)

It didn't work because "default-push" and "default" are independent named
items. Without this patch, "hg push default" would push to "default-push"
because paths["default"].pushloc was overwritten by "default-push".

Also, we shouldn't ban a user from doing "hg push default-push" so long as
"default-push" item is defined, not "default:pushurl". Otherwise, he would
be confused by missing "default-push" path.

Tests are included in a patch for stable branch.
Augie Fackler - Dec. 29, 2015, 10:43 p.m.
On Sat, Dec 26, 2015 at 09:06:46PM +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1451113572 -32400
> #      Sat Dec 26 16:06:12 2015 +0900
> # Node ID 8b1635a5baefbe613290d9030d729c464c8d9894
> # Parent  cfbbc41a45b1ddc0d2d44e655e6b1c124174228f
> paths: do not process default-push as pushurl of default path (issue5000)

Queued, and many thanks to indygreg for reviewing.

>
> It didn't work because "default-push" and "default" are independent named
> items. Without this patch, "hg push default" would push to "default-push"
> because paths["default"].pushloc was overwritten by "default-push".
>
> Also, we shouldn't ban a user from doing "hg push default-push" so long as
> "default-push" item is defined, not "default:pushurl". Otherwise, he would
> be confused by missing "default-push" path.
>
> Tests are included in a patch for stable branch.
>
> diff --git a/mercurial/ui.py b/mercurial/ui.py
> --- a/mercurial/ui.py
> +++ b/mercurial/ui.py
> @@ -1097,23 +1097,9 @@ class paths(dict):
>              # No location is the same as not existing.
>              if not loc:
>                  continue
> -
> -            # TODO ignore default-push once all consumers stop referencing it
> -            # since it is handled specifically below.
> -
>              loc, sub = ui.configsuboptions('paths', name)
>              self[name] = path(ui, name, rawloc=loc, suboptions=sub)
>
> -        # Handle default-push, which is a one-off that defines the push URL for
> -        # the "default" path.
> -        defaultpush = ui.config('paths', 'default-push')
> -        if defaultpush:
> -            # "default-push" can be defined without "default" entry. This is a
> -            # bit weird, but is allowed for backwards compatibility.
> -            if 'default' not in self:
> -                self['default'] = path(ui, 'default', rawloc=defaultpush)
> -            self['default'].pushloc = defaultpush
> -
>      def getpath(self, name, default=None):
>          """Return a ``path`` from a string, falling back to default.
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -1097,23 +1097,9 @@  class paths(dict):
             # No location is the same as not existing.
             if not loc:
                 continue
-
-            # TODO ignore default-push once all consumers stop referencing it
-            # since it is handled specifically below.
-
             loc, sub = ui.configsuboptions('paths', name)
             self[name] = path(ui, name, rawloc=loc, suboptions=sub)
 
-        # Handle default-push, which is a one-off that defines the push URL for
-        # the "default" path.
-        defaultpush = ui.config('paths', 'default-push')
-        if defaultpush:
-            # "default-push" can be defined without "default" entry. This is a
-            # bit weird, but is allowed for backwards compatibility.
-            if 'default' not in self:
-                self['default'] = path(ui, 'default', rawloc=defaultpush)
-            self['default'].pushloc = defaultpush
-
     def getpath(self, name, default=None):
         """Return a ``path`` from a string, falling back to default.