[PATCH 1 of 1] outgoing: respect ":pushurl" paths

Hollis Blanchard hollis_blanchard at mentor.com
Fri Nov 3 14:25:15 EDT 2017


# HG changeset patch
# User Hollis Blanchard <hollis_blanchard at mentor.com>
# Date 1509731952 25200
#      Fri Nov 03 10:59:12 2017 -0700
# Branch stable
# Node ID 666d3aaffadc4e92acfe3e4098ae8f2fa4086b7d
# Parent  f445b10dc7fb3495d24d1c22b0996148864c77f7
outgoing: respect ":pushurl" paths

Make 'hg outgoing' respect "paths.default:pushurl" in addition to
"paths.default-push".

diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -910,7 +910,11 @@ def incoming(ui, repo, source, opts):
     return _incoming(display, subreporecurse, ui, repo, source, opts)
 
 def _outgoing(ui, repo, dest, opts):
-    dest = ui.expandpath(dest or 'default-push', dest or 'default')
+    path = ui.paths.getpath(dest, default=('default-push', 'default'))
+    if not path:
+        raise error.Abort(_('default repository not configured!'),
+                hint=_("see 'hg help config.paths'"))
+    dest = path.pushloc or path.loc
     dest, branches = parseurl(dest, opts.get('branch'))
     ui.status(_('comparing with %s\n') % util.hidepassword(dest))
     revs, checkout = addbranchrevs(repo, repo, branches, opts.get('rev'))
diff --git a/tests/test-paths-pushurl.t b/tests/test-paths-pushurl.t
new file mode 100644
--- /dev/null
+++ b/tests/test-paths-pushurl.t
@@ -0,0 +1,113 @@
+
+  $ hg init pullfrom.hg
+  $ echo 1 > pullfrom.hg/foo.txt
+  $ hg --cwd pullfrom.hg commit -A -m "r1"
+  adding foo.txt
+
+  $ hg clone pullfrom.hg pushto.hg
+  updating to branch default
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+Create user.hg: pulls from pullto.hg, pushes to pushto.hg
+
+  $ hg clone pullfrom.hg user.hg
+  updating to branch default
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+commit to pullfrom.hg
+
+  $ echo 2 > pullfrom.hg/foo.txt
+  $ hg --cwd pullfrom.hg commit -m "r2"
+
+pull it into user.hg
+
+  $ hg --cwd user.hg incoming
+  comparing with $TESTTMP/pullfrom.hg
+  searching for changes
+  changeset:   1:75cc8a476e40
+  tag:         tip
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     r2
+  
+  $ hg --cwd user.hg pull -u
+  pulling from $TESTTMP/pullfrom.hg
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files
+  new changesets 75cc8a476e40
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+commit to user
+
+  $ echo 3 > user.hg/foo.txt
+  $ hg --cwd user.hg commit -m "r3"
+
+Make sure outgoing with default-push still works
+
+  $ ed -s user.hg/.hg/hgrc << EOF
+  > /^default
+  > a
+  > default-push = file://$TESTTMP/pushto.hg
+  > .
+  > w
+  > q
+  > EOF
+  default = $TESTTMP/pullfrom.hg
+  $ hg --cwd user.hg paths
+  default = $TESTTMP/pullfrom.hg
+  default-push = file://$TESTTMP/pushto.hg
+  $ hg --cwd user.hg outgoing
+  comparing with file://$TESTTMP/pushto.hg
+  searching for changes
+  changeset:   1:75cc8a476e40
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     r2
+  
+  changeset:   2:0225157b9457
+  tag:         tip
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     r3
+  
+
+Outgoing with default:pushurl syntax
+
+  $ ed -s user.hg/.hg/hgrc <<EOF
+  > /^default-push
+  > c
+  > default:pushurl = file://$PWD/pushto.hg
+  > .
+  > w
+  > EOF
+  default-push = file://$TESTTMP/pushto.hg
+  $ hg --cwd user.hg paths
+  default = $TESTTMP/pullfrom.hg
+  default:pushurl = file://$TESTTMP/pushto.hg
+  $ hg --cwd user.hg outgoing
+  comparing with file://$TESTTMP/pushto.hg
+  searching for changes
+  changeset:   1:75cc8a476e40
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     r2
+  
+  changeset:   2:0225157b9457
+  tag:         tip
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     r3
+  
+
+Push with default:pushurl
+
+  $ hg --cwd user.hg push
+  pushing to file://$TESTTMP/pushto.hg
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 2 changesets with 2 changes to 1 files


More information about the Mercurial-devel mailing list