Patchwork [v2] outgoing: respect ":pushurl" paths (issue5365)

login
register
mail settings
Submitter Hollis Blanchard
Date Nov. 3, 2017, 9:07 p.m.
Message ID <a952cae0303fa38d1b24.1509743274@aurora.wv.mentorg.com>
Download mbox | patch
Permalink /patch/25380/
State Accepted
Headers show

Comments

Hollis Blanchard - Nov. 3, 2017, 9:07 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 a952cae0303fa38d1b246561704071d41bbfa1ea
# Parent  f445b10dc7fb3495d24d1c22b0996148864c77f7
[v2] outgoing: respect ":pushurl" paths (issue5365)

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

'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'.
Yuya Nishihara - Nov. 4, 2017, 6:18 a.m.
On Fri, 3 Nov 2017 14:07:54 -0700, 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 a952cae0303fa38d1b246561704071d41bbfa1ea
> # Parent  f445b10dc7fb3495d24d1c22b0996148864c77f7
> [v2] outgoing: respect ":pushurl" paths (issue5365)
> 
> Make 'hg outgoing' respect "paths.default:pushurl" in addition to
> "paths.default-push".
> 
> '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'.

I heard from Greg that the current behavior was intentional.

https://bz.mercurial-scm.org/show_bug.cgi?id=5365#c3
https://www.mercurial-scm.org/pipermail/mercurial-devel/2014-September/062091.html

Just to be clear, I'm not against this patch, but this will be a breaking
change for some users.
Pulkit Goyal - Nov. 4, 2017, 9:34 a.m.
You can use the `--flag` option of `hg email` to add email flags like V2.

On Sat, Nov 4, 2017 at 11:48 AM, Yuya Nishihara <yuya@tcha.org> wrote:
> On Fri, 3 Nov 2017 14:07:54 -0700, 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 a952cae0303fa38d1b246561704071d41bbfa1ea
>> # Parent  f445b10dc7fb3495d24d1c22b0996148864c77f7
>> [v2] outgoing: respect ":pushurl" paths (issue5365)
>>
>> Make 'hg outgoing' respect "paths.default:pushurl" in addition to
>> "paths.default-push".
>>
>> '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'.
>
> I heard from Greg that the current behavior was intentional.
>
> https://bz.mercurial-scm.org/show_bug.cgi?id=5365#c3
> https://www.mercurial-scm.org/pipermail/mercurial-devel/2014-September/062091.html
>
> Just to be clear, I'm not against this patch, but this will be a breaking
> change for some users.
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Hollis Blanchard - Nov. 10, 2017, 5:21 p.m.
Any additional comments?

Hollis Blanchard <hollis_blanchard@mentor.com>
Mentor Graphics Emulation Division

On 11/03/2017 02:07 PM, 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 a952cae0303fa38d1b246561704071d41bbfa1ea
> # Parent  f445b10dc7fb3495d24d1c22b0996148864c77f7
> [v2] outgoing: respect ":pushurl" paths (issue5365)
>
> Make 'hg outgoing' respect "paths.default:pushurl" in addition to
> "paths.default-push".
>
> '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'.
>
> 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-incoming-outgoing.t b/tests/test-incoming-outgoing.t
> --- a/tests/test-incoming-outgoing.t
> +++ b/tests/test-incoming-outgoing.t
> @@ -491,3 +491,71 @@ incoming from empty remote repository
>     searching for changes
>     no changes found
>     [1]
> +
> +Create a "split" repo that pulls from r1 and pushes to r2, using default-push
> +
> +  $ hg clone r1 split
> +  updating to branch default
> +  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
> +  $ ed -s split/.hg/hgrc << EOF
> +  > /^default
> +  > a
> +  > default-push = file://$TESTTMP/r2
> +  > .
> +  > w
> +  > q
> +  > EOF
> +  default = $TESTTMP/r1
> +  $ hg -R split paths
> +  default = $TESTTMP/r1
> +  default-push = file://$TESTTMP/r2
> +  $ hg -R split outgoing
> +  comparing with file://$TESTTMP/r2
> +  searching for changes
> +  changeset:   0:3e92d79f743a
> +  tag:         tip
> +  user:        test
> +  date:        Thu Jan 01 00:00:00 1970 +0000
> +  summary:     a
> +
> +
> +Use default:pushurl instead of default-push
> +
> +  $ ed -s split/.hg/hgrc <<EOF
> +  > /^default-push
> +  > c
> +  > default:pushurl = file://$PWD/r2
> +  > .
> +  > w
> +  > EOF
> +  default-push = file://$TESTTMP/r2
> +  $ hg -R split paths
> +  default = $TESTTMP/r1
> +  default:pushurl = file://$TESTTMP/r2
> +  $ hg -R split outgoing
> +  comparing with file://$TESTTMP/r2
> +  searching for changes
> +  changeset:   0:3e92d79f743a
> +  tag:         tip
> +  user:        test
> +  date:        Thu Jan 01 00:00:00 1970 +0000
> +  summary:     a
> +
> +
> +Push and then double-check outgoing
> +
> +  $ echo a >> split/foo
> +  $ hg -R split commit -Ama
> +  $ hg -R split push
> +  pushing to file://$TESTTMP/r2
> +  searching for changes
> +  adding changesets
> +  adding manifests
> +  adding file changes
> +  added 2 changesets with 2 changes to 1 files
> +  $ hg -R split outgoing
> +  comparing with file://$TESTTMP/r2
> +  searching for changes
> +  no changes found
> +  [1]
> +
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Augie Fackler - Nov. 10, 2017, 11:06 p.m.
> On Nov 10, 2017, at 12:21, Hollis Blanchard <hollis_blanchard@mentor.com> wrote:
> 
> Any additional comments?

Hearing nothing else from anyone, I've queued this.
> Hollis Blanchard <hollis_blanchard@mentor.com> <mailto:hollis_blanchard@mentor.com>
> Mentor Graphics Emulation Division
> On 11/03/2017 02:07 PM, 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 a952cae0303fa38d1b246561704071d41bbfa1ea
>> # Parent  f445b10dc7fb3495d24d1c22b0996148864c77f7
>> [v2] outgoing: respect ":pushurl" paths (issue5365)
>> 
>> Make 'hg outgoing' respect "paths.default:pushurl" in addition to
>> "paths.default-push".
>> 
>> '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".
>> 
>> 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'.
>> 
>> 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-incoming-outgoing.t b/tests/test-incoming-outgoing.t
>> --- a/tests/test-incoming-outgoing.t
>> +++ b/tests/test-incoming-outgoing.t
>> @@ -491,3 +491,71 @@ incoming from empty remote repository
>>    searching for changes
>>    no changes found
>>    [1]
>> +
>> +Create a "split" repo that pulls from r1 and pushes to r2, using default-push
>> +
>> +  $ hg clone r1 split
>> +  updating to branch default
>> +  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
>> +  $ ed -s split/.hg/hgrc << EOF
>> +  > /^default
>> +  > a
>> +  > default-push = file://$TESTTMP/r2 <file://$testtmp/r2>
>> +  > .
>> +  > w
>> +  > q
>> +  > EOF
>> +  default = $TESTTMP/r1
>> +  $ hg -R split paths
>> +  default = $TESTTMP/r1
>> +  default-push = file://$TESTTMP/r2 <file://$testtmp/r2>
>> +  $ hg -R split outgoing
>> +  comparing with file://$TESTTMP/r2 <file://$testtmp/r2>
>> +  searching for changes
>> +  changeset:   0:3e92d79f743a
>> +  tag:         tip
>> +  user:        test
>> +  date:        Thu Jan 01 00:00:00 1970 +0000
>> +  summary:     a
>> +  
>> +
>> +Use default:pushurl instead of default-push
>> +
>> +  $ ed -s split/.hg/hgrc <<EOF
>> +  > /^default-push
>> +  > c
>> +  > default:pushurl = file://$PWD/r2 <file://$pwd/r2>
>> +  > .
>> +  > w
>> +  > EOF
>> +  default-push = file://$TESTTMP/r2 <file://$testtmp/r2>
>> +  $ hg -R split paths
>> +  default = $TESTTMP/r1
>> +  default:pushurl = file://$TESTTMP/r2 <file://$testtmp/r2>
>> +  $ hg -R split outgoing
>> +  comparing with file://$TESTTMP/r2 <file://$testtmp/r2>
>> +  searching for changes
>> +  changeset:   0:3e92d79f743a
>> +  tag:         tip
>> +  user:        test
>> +  date:        Thu Jan 01 00:00:00 1970 +0000
>> +  summary:     a
>> +  
>> +
>> +Push and then double-check outgoing
>> +
>> +  $ echo a >> split/foo
>> +  $ hg -R split commit -Ama
>> +  $ hg -R split push
>> +  pushing to file://$TESTTMP/r2 <file://$testtmp/r2>
>> +  searching for changes
>> +  adding changesets
>> +  adding manifests
>> +  adding file changes
>> +  added 2 changesets with 2 changes to 1 files
>> +  $ hg -R split outgoing
>> +  comparing with file://$TESTTMP/r2 <file://$testtmp/r2>
>> +  searching for changes
>> +  no changes found
>> +  [1]
>> +
>> _______________________________________________
>> Mercurial-devel mailing list
>> Mercurial-devel@mercurial-scm.org <mailto:Mercurial-devel@mercurial-scm.org>
>> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel <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-incoming-outgoing.t b/tests/test-incoming-outgoing.t
--- a/tests/test-incoming-outgoing.t
+++ b/tests/test-incoming-outgoing.t
@@ -491,3 +491,71 @@  incoming from empty remote repository
   searching for changes
   no changes found
   [1]
+
+Create a "split" repo that pulls from r1 and pushes to r2, using default-push
+
+  $ hg clone r1 split
+  updating to branch default
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ ed -s split/.hg/hgrc << EOF
+  > /^default
+  > a
+  > default-push = file://$TESTTMP/r2
+  > .
+  > w
+  > q
+  > EOF
+  default = $TESTTMP/r1
+  $ hg -R split paths
+  default = $TESTTMP/r1
+  default-push = file://$TESTTMP/r2
+  $ hg -R split outgoing
+  comparing with file://$TESTTMP/r2
+  searching for changes
+  changeset:   0:3e92d79f743a
+  tag:         tip
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     a
+  
+
+Use default:pushurl instead of default-push
+
+  $ ed -s split/.hg/hgrc <<EOF
+  > /^default-push
+  > c
+  > default:pushurl = file://$PWD/r2
+  > .
+  > w
+  > EOF
+  default-push = file://$TESTTMP/r2
+  $ hg -R split paths
+  default = $TESTTMP/r1
+  default:pushurl = file://$TESTTMP/r2
+  $ hg -R split outgoing
+  comparing with file://$TESTTMP/r2
+  searching for changes
+  changeset:   0:3e92d79f743a
+  tag:         tip
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     a
+  
+
+Push and then double-check outgoing
+
+  $ echo a >> split/foo
+  $ hg -R split commit -Ama
+  $ hg -R split push
+  pushing to file://$TESTTMP/r2
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 2 changesets with 2 changes to 1 files
+  $ hg -R split outgoing
+  comparing with file://$TESTTMP/r2
+  searching for changes
+  no changes found
+  [1]
+