[PATCH V2] outgoing: Support pushrev (issue6106)

Kim Alvefur zash at zash.se
Thu Mar 28 14:06:10 EDT 2019


# HG changeset patch
# User Kim Alvefur <zash at 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 ]
+
     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
+  


More information about the Mercurial-devel mailing list