Patchwork [1,of,1] outgoing: respect ":pushurl" paths

login
register
mail settings
Submitter Hollis Blanchard
Date Nov. 3, 2017, 6:25 p.m.
Message ID <666d3aaffadc4e92acfe.1509733515@aurora.wv.mentorg.com>
Download mbox | patch
Permalink /patch/25379/
State Changes Requested
Headers show

Comments

Hollis Blanchard - Nov. 3, 2017, 6:25 p.m.
# HG changeset patch
# User Hollis Blanchard <hollis_blanchard@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".
Hollis Blanchard - Nov. 3, 2017, 7:01 p.m.
On 11/03/2017 11:25 AM, Hollis Blanchard wrote:
> # HG changeset patch
> # User Hollis Blanchard <hollis_blanchard@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".
Here's some context I didn't think belonged in the commit message:

'hg outgoing' has always meant "what will happen if I run 'hg push'?" 
and it's
still documented that way:

     Show changesets not found in the specified destination repository 
or the
     default push location. These are the changesets that would be 
pushed if a
     push was requested.

If the user uses the now-deprecated "paths.default-push" path, it 
continues to
work that way. However, as described at
https://bz.mercurial-scm.org/show_bug.cgi?id=5365, it doesn't behave the 
same
with "paths.default:pushurl".

Why does it matter? Similar to the bugzilla reporter, I have a read-only 
mirror
of a non-Mercurial repository:

upstream -> imported mirror -> user clone
        ^-----------------------/


Users push directly to upstream, and that content is then imported into the
mirror. However, those repositories are not the same; it's possible that the
mirroring has either broken completely, or an import process is running 
and not
yet complete. In those cases, 'hg outgoing' will list changesets that have
already been pushed.

Mozilla's desired behavior described in bug 5365 can be accomplished through
other means (e.g. 'hg outgoing default'), preserving the consistency and
meaning of 'hg outgoing'.

Hollis Blanchard <hollis_blanchard@mentor.com>
Mentor Graphics Emulation Division
Augie Fackler - Nov. 3, 2017, 7:03 p.m.
> On Nov 3, 2017, at 15:01, Hollis Blanchard <hollis_blanchard@mentor.com> wrote:
> 
> On 11/03/2017 11:25 AM, Hollis Blanchard wrote:
>> # HG changeset patch
>> # User Hollis Blanchard <hollis_blanchard@mentor.com> <mailto:hollis_blanchard@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".
> Here's some context I didn't think belonged in the commit message:
> 
> 'hg outgoing' has always meant "what will happen if I run 'hg push'?" and it's
> still documented that way:
> 
>     Show changesets not found in the specified destination repository or the
>     default push location. These are the changesets that would be pushed if a
>     push was requested.
> 
> If the user uses the now-deprecated "paths.default-push" path, it continues to
> work that way. However, as described at
> https://bz.mercurial-scm.org/show_bug.cgi?id=5365 <https://bz.mercurial-scm.org/show_bug.cgi?id=5365>, it doesn't behave the same
> with "paths.default:pushurl".

Yep, clear bug.

This context is totally fine in a commit message. As I mentioned on IRC, maybe fold the test into test-outgoing.t? I can find time for it (next week probably, given how today has gone) if you don't have time, but if you're willing to do a v2 with that, could you also put (issue5365) at the end of the first line of the commit message so our bug bot notices?

Thanks!

> 
> Why does it matter? Similar to the bugzilla reporter, I have a read-only mirror
> of a non-Mercurial repository:
> 
> upstream -> imported mirror -> user clone
>        ^-----------------------/
> 
> Users push directly to upstream, and that content is then imported into the
> mirror. However, those repositories are not the same; it's possible that the
> mirroring has either broken completely, or an import process is running and not
> yet complete. In those cases, 'hg outgoing' will list changesets that have
> already been pushed.
> 
> Mozilla's desired behavior described in bug 5365 can be accomplished through
> other means (e.g. 'hg outgoing default'), preserving the consistency and
> meaning of 'hg outgoing'.
> 
> Hollis Blanchard <hollis_blanchard@mentor.com> <mailto:hollis_blanchard@mentor.com>
> Mentor Graphics Emulation Division
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

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