Patchwork [V2] outgoing: Support pushrev (issue6106)

login
register
mail settings
Submitter Kim Alvefur
Date March 28, 2019, 6:06 p.m.
Message ID <df9b2ef3a948be54c618.1553796370@carcharodon.zash.se>
Download mbox | patch
Permalink /patch/39410/
State New
Headers show

Comments

Kim Alvefur - March 28, 2019, 6:06 p.m.
# HG changeset patch
# User Kim Alvefur <zash@zash.se>
# Date 1553614536 -3600
#      Tue Mar 26 16:35:36 2019 +0100
# Node ID df9b2ef3a948be54c6180e2b6595e0f61522e740
# Parent  00c1ee0f746a5f427e81e6d18e681f6a70a2639d
outgoing: Support pushrev  (issue6106)

It should mirror behaviour of `hg push`.
Yuya Nishihara - March 28, 2019, 10:45 p.m.
On Thu, 28 Mar 2019 19:06:10 +0100, Kim Alvefur wrote:
> # HG changeset patch
> # User Kim Alvefur <zash@zash.se>
> # Date 1553614536 -3600
> #      Tue Mar 26 16:35:36 2019 +0100
> # Node ID df9b2ef3a948be54c6180e2b6595e0f61522e740
> # Parent  00c1ee0f746a5f427e81e6d18e681f6a70a2639d
> outgoing: Support pushrev  (issue6106)
> 
> It should mirror behaviour of `hg push`.
> 
> diff -r 00c1ee0f746a -r df9b2ef3a948 mercurial/commands.py
> --- a/mercurial/commands.py	Sun Mar 24 20:13:13 2019 -0400
> +++ b/mercurial/commands.py	Tue Mar 26 16:35:36 2019 +0100
> @@ -4091,6 +4091,10 @@ def outgoing(ui, repo, dest=None, **opts
>                            hint=_("see 'hg help config.paths'"))
>  
>      opts = pycompat.byteskwargs(opts)
> +
> +    if path.pushrev and not opts.get('rev'):
> +        opts['rev'] = [ path.pushrev ]

Can you test behavior with -b/--branch or PATH#REV syntax?
I think commands.push() won't take :pushrev if any revision is specified.

Maybe we can move the pushrev resolution to hg._outgoing().
Kim Alvefur - April 6, 2019, 1:22 p.m.
Hello,

On Fri, Mar 29, 2019 at 07:45:55AM +0900, Yuya Nishihara wrote:
> Can you test behavior with -b/--branch or PATH#REV syntax?
> I think commands.push() won't take :pushrev if any revision is specified.

Oh dear, I didn't even know about path#rev. I guess there's also the
`outgoing()` revset that should be considered.

How should -r, -b path#rev and pathrev interact?

> Maybe we can move the pushrev resolution to hg._outgoing().

Sounds senible.
Yuya Nishihara - April 7, 2019, 12:54 a.m.
On Sat, 6 Apr 2019 15:22:32 +0200, Kim Alvefur wrote:
> On Fri, Mar 29, 2019 at 07:45:55AM +0900, Yuya Nishihara wrote:
> > Can you test behavior with -b/--branch or PATH#REV syntax?
> > I think commands.push() won't take :pushrev if any revision is specified.
> 
> Oh dear, I didn't even know about path#rev. I guess there's also the
> `outgoing()` revset that should be considered.
> 
> How should -r, -b path#rev and pathrev interact?

Appears that the rev of path#rev is basically appended to the -rREVS list.

https://www.mercurial-scm.org/repo/hg/file/4.9.1/mercurial/hg.py#l100

Patch

diff -r 00c1ee0f746a -r df9b2ef3a948 mercurial/commands.py
--- a/mercurial/commands.py	Sun Mar 24 20:13:13 2019 -0400
+++ b/mercurial/commands.py	Tue Mar 26 16:35:36 2019 +0100
@@ -4091,6 +4091,10 @@  def outgoing(ui, repo, dest=None, **opts
                           hint=_("see 'hg help config.paths'"))
 
     opts = pycompat.byteskwargs(opts)
+
+    if path.pushrev and not opts.get('rev'):
+        opts['rev'] = [ path.pushrev ]
+
     if opts.get('graph'):
         logcmdutil.checkunsupportedgraphflags([], opts)
         o, other = hg._outgoing(ui, repo, dest, opts)
diff -r 00c1ee0f746a -r df9b2ef3a948 tests/test-outgoing-pushrev.t
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-outgoing-pushrev.t	Tue Mar 26 16:35:36 2019 +0100
@@ -0,0 +1,138 @@ 
+
+  $ hg init upstream
+  $ cd upstream
+  $ for i in 0 1 2 3; do
+  >     echo $i >> foo
+  >     hg commit -A -m $i
+  > done
+  adding foo
+
+  $ cd ..
+  $ hg clone upstream test
+  updating to branch default
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ cd test
+
+Add some local commits
+
+  $ for i in 4 5 6; do
+  >     echo $i >> foo
+  >     hg commit -A -m $i
+  > done
+  $ hg bookmark trunk
+
+Create two heads
+
+  $ hg up 3
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (leaving bookmark trunk)
+  $ for i in 7 8 9; do
+  >     echo $i >> foo
+  >     hg commit -A -m $i
+  > done
+  created new head
+
+By default it should consider all the new commits
+
+  $ hg out
+  comparing with $TESTTMP/upstream
+  searching for changes
+  changeset:   4:70d7eb252d49
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     4
+  
+  changeset:   5:ad284ee3b5ee
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     5
+  
+  changeset:   6:e9229f2de384
+  bookmark:    trunk
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     6
+  
+  changeset:   7:c251eb9c1267
+  parent:      3:376476025137
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     7
+  
+  changeset:   8:4d2b78a91fad
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     8
+  
+  changeset:   9:83868e57a98a
+  tag:         tip
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     9
+  
+
+Only ancenstors of an explictly mentioned commit
+
+  $ hg out -r 9
+  comparing with $TESTTMP/upstream
+  searching for changes
+  changeset:   7:c251eb9c1267
+  parent:      3:376476025137
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     7
+  
+  changeset:   8:4d2b78a91fad
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     8
+  
+  changeset:   9:83868e57a98a
+  tag:         tip
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     9
+
+With pushrev, that should act as the default commit
+
+  $ hg out --config paths.default:pushrev=trunk
+  comparing with $TESTTMP/upstream
+  searching for changes
+  changeset:   4:70d7eb252d49
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     4
+  
+  changeset:   5:ad284ee3b5ee
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     5
+  
+  changeset:   6:e9229f2de384
+  bookmark:    trunk
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     6
+
+Explicit commit should override pushrev
+
+  $ hg out --config paths.default:pushrev=trunk -r 9
+  comparing with $TESTTMP/upstream
+  searching for changes
+  changeset:   7:c251eb9c1267
+  parent:      3:376476025137
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     7
+  
+  changeset:   8:4d2b78a91fad
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     8
+  
+  changeset:   9:83868e57a98a
+  tag:         tip
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     9
+