push: restore old behavior of default-push (issue5000) stable
authorYuya Nishihara <yuya@tcha.org>
Sat, 26 Dec 2015 15:18:16 +0900
branchstable
changeset 27555 ca8ada499529
parent 27532 1be02894dd6f
child 27570 44f717c87903
child 27571 6a6e78f84cc6
child 27572 ffffe735175f
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.
mercurial/commands.py
tests/test-default-push.t
--- a/mercurial/commands.py	Wed Dec 16 10:39:00 2015 -0800
+++ b/mercurial/commands.py	Sat Dec 26 15:18:16 2015 +0900
@@ -5394,11 +5394,13 @@
                 # 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)
--- a/tests/test-default-push.t	Wed Dec 16 10:39:00 2015 -0800
+++ b/tests/test-default-push.t	Sat Dec 26 15:18:16 2015 +0900
@@ -46,6 +46,14 @@
   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