Commit ffde7caf authored by Pierre-Yves David's avatar Pierre-Yves David 🐙
Browse files

branching: merge with stable

Pipeline #22639 failed with stage
in 5 minutes and 18 seconds
......@@ -8,6 +8,17 @@ Changelog
* evolve: use a more stable criteria for picking p1 when solving
content-divergence (most recent evolution will be used).
10.3.2 - in progress
--------------------
* next: remove duplicated targets when updating from an unstable changeset
* evolve: use "served" repo filter to guess what the server will publish
topic (0.22.2)
* topic: don't lose any file changes when changing topic of a merge commit
* topic: announce ext-topics-publish capability in case of SSH and HTTP too
10.3.1 -- 2021-04-25
--------------------
......
......@@ -882,6 +882,11 @@ def cmdnext(ui, repo, **opts):
if repo[rev].topic() != topic)
aspchildren = [rev for rev in aspchildren if rev not in filtered]
# Let's make sure we don't have any duplicates between children and
# aspiring children
filtered.update(ctx.rev() for ctx in children)
aspchildren = [rev for rev in aspchildren if rev not in filtered]
# To catch and prevent the case when `next` would get confused by split,
# lets filter those aspiring children which can be stablized on one of
# the aspiring children itself.
......@@ -898,8 +903,7 @@ def cmdnext(ui, repo, **opts):
if needevolve and opts['evolve']:
hint = _(b'use `hg amend`, `hg revert` or `hg shelve`')
cmdutil.bailifchanged(repo, hint=hint)
if not (opts['merge'] or (needevolve and opts['evolve'])):
elif not opts['merge']:
# we only skip the check if noconflict is set
if ui.config(b'commands', b'update.check') == b'noconflict':
pass
......
......@@ -38,6 +38,10 @@ if b'auto-publish' not in configitems.coreitems.get(b'experimental', {}):
published = repo.filtered(b'served').revs(b"not public()")
else:
published = repo.revs(b"::%ln - public()", pushop.revs)
# we want to use pushop.revs in the revset even if they
# themselves are secret, but we don't want to have anything
# that the server won't see in the result of this expression
published &= repo.filtered(b'served')
if published:
if behavior == b'warn':
ui.warn(_(b'%i changesets about to be published\n')
......
......@@ -589,7 +589,9 @@ def reposetup(ui, repo):
topicmodeserver = self.ui.config(b'experimental',
b'topic-mode.server', b'ignore')
ispush = (desc.startswith(b'push') or desc.startswith(b'serve'))
publishbare = self.ui.configbool(b'experimental',
b'topic.publish-bare-branch')
ispush = desc.startswith((b'push', b'serve'))
if (topicmodeserver != b'ignore' and ispush):
if util.safehasattr(tr, 'validator'): # hg <= 4.7 (ebbba3ba3f66)
origvalidator = tr.validator
......@@ -615,10 +617,7 @@ def reposetup(ui, repo):
else:
tr.addvalidator(b'000-reject-untopiced', _validate)
elif (self.ui.configbool(b'experimental', b'topic.publish-bare-branch')
and (desc.startswith(b'push')
or desc.startswith(b'serve'))
):
elif publishbare and ispush:
origclose = tr.close
trref = weakref.ref(tr)
......@@ -1060,6 +1059,14 @@ def _changetopics(ui, repo, revs, newtopic):
for r in revs:
c = repo[r]
if len(c.parents()) > 1:
# ctx.files() isn't reliable for merges, so fall back to the
# slower repo.status() method
st = c.p1().status(c)
files = set(st.modified) | set(st.added) | set(st.removed)
else:
files = set(c.files())
def filectxfn(repo, ctx, path):
try:
return c[path]
......@@ -1098,7 +1105,7 @@ def _changetopics(ui, repo, revs, newtopic):
mc = context.memctx(repo,
(p1, p2),
c.description(),
c.files(),
files,
filectxfn,
user=c.user(),
date=c.date(),
......
......@@ -152,6 +152,11 @@ def replacecheckpublish(orig, pushop):
published = repo.filtered(b'served').revs(b'not public()')
else:
published = repo.revs(b'::%ln - public()', pushop.revs)
# we want to use pushop.revs in the revset even if they themselves are
# secret, but we don't want to have anything that the server won't see
# in the result of this expression
published &= repo.filtered(b'served')
if mode == b'auto':
published = repo.revs(b'%ld::(%ld - topic())', published, published)
if published:
......
......@@ -71,6 +71,13 @@ def wireprotocaps(orig, repo, proto):
caps = orig(repo, proto)
if common.hastopicext(repo) and repo.peer().capable(b'topics'):
caps.append(b'_exttopics_heads')
if repo.ui.configbool(b'phases', b'publish'):
mode = b'all'
elif repo.ui.configbool(b'experimental', b'topic.publish-bare-branch'):
mode = b'auto'
else:
mode = b'none'
caps.append(b'ext-topics-publish=%s' % mode)
return caps
def setupserver(ui):
......
This test amends a merge commit using various commands, including topics
$ . $TESTDIR/testlib/common.sh
$ cat >> $HGRCPATH << EOF
> [extensions]
> evolve =
> topic =
> EOF
$ hg init amending-a-merge
$ cd amending-a-merge
$ mkcommit root
$ mkcommit apple
$ hg up 'desc("root")'
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
$ mkcommit banana
created new head
(consider using topic for lightweight branches. See 'hg help topic')
$ hg up 'desc("apple")'
1 files updated, 0 files merged, 1 files removed, 0 files unresolved
$ hg merge 'desc("banana")'
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
$ hg ci -m merge
$ hg diff -r 'p1(.)' -r '.'
diff -r 88a060ab6523 -r c20705a6a8c4 banana
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/banana Thu Jan 01 00:00:00 1970 +0000
@@ -0,0 +1,1 @@
+banana
$ hg diff -r 'p2(.)' -r '.'
diff -r d8c7baf0ca58 -r c20705a6a8c4 apple
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/apple Thu Jan 01 00:00:00 1970 +0000
@@ -0,0 +1,1 @@
+apple
amend
$ hg amend -m 'merge, amend'
$ hg diff -r 'p1(.)' -r '.'
diff -r 88a060ab6523 -r 456753fae3cd banana
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/banana Thu Jan 01 00:00:00 1970 +0000
@@ -0,0 +1,1 @@
+banana
$ hg diff -r 'p2(.)' -r '.'
diff -r d8c7baf0ca58 -r 456753fae3cd apple
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/apple Thu Jan 01 00:00:00 1970 +0000
@@ -0,0 +1,1 @@
+apple
metaedit
$ hg metaedit -m 'merge, metaedit'
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg diff -r 'p1(.)' -r '.'
diff -r 88a060ab6523 -r 1528d42f3e83 banana
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/banana Thu Jan 01 00:00:00 1970 +0000
@@ -0,0 +1,1 @@
+banana
$ hg diff -r 'p2(.)' -r '.'
diff -r d8c7baf0ca58 -r 1528d42f3e83 apple
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/apple Thu Jan 01 00:00:00 1970 +0000
@@ -0,0 +1,1 @@
+apple
topics
$ hg topics -r . foo
switching to topic foo
changed topic on 1 changesets to "foo"
$ hg diff -r 'p1(.)' -r '.'
diff -r 88a060ab6523 -r 52150b9639f7 banana
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/banana Thu Jan 01 00:00:00 1970 +0000
@@ -0,0 +1,1 @@
+banana
$ hg diff -r 'p2(.)' -r '.'
diff -r d8c7baf0ca58 -r 52150b9639f7 apple
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/apple Thu Jan 01 00:00:00 1970 +0000
@@ -0,0 +1,1 @@
+apple
$ hg files
apple
banana
root
$ hg cat apple banana
apple
banana
......@@ -35,7 +35,7 @@ Archiving to a separate location to avoid hardlink mess when the repo is shared
$ tar -tzf hg-evolve-*.tar.gz | sed 's|^hg-evolve-[^/]*/||' | sort > files
$ wc -l files
350 files
351 files
$ fgrep debian files
tests/test-check-debian.t
$ fgrep __init__.py files
......
......@@ -132,6 +132,7 @@ Check topic isolation
[1]
$ hg debugcapabilities http://$LOCALIP:$HGPORT/repo-topic | egrep 'topics|evoext'
_exttopics_heads
ext-topics-publish=all
topics
$ hg debugcapabilities http://$LOCALIP:$HGPORT/repo-no-ext | egrep 'topics|evoext'
[1]
......@@ -145,12 +146,14 @@ Check coupled isolation
_evoext_getbundle_obscommon
_evoext_obshashrange_v1
_exttopics_heads
ext-topics-publish=all
topics
$ hg debugcapabilities http://$LOCALIP:$HGPORT/repo-evo | egrep 'topics|evoext'
_evoext_getbundle_obscommon
_evoext_obshashrange_v1
$ hg debugcapabilities http://$LOCALIP:$HGPORT/repo-topic | egrep 'topics|evoext'
_exttopics_heads
ext-topics-publish=all
topics
$ hg debugcapabilities http://$LOCALIP:$HGPORT/repo-evo | egrep 'topics|evoext'
_evoext_getbundle_obscommon
......
......@@ -60,7 +60,7 @@ Test options to prevent implicite publishing of changesets
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ cd strict-publish-client
$ echo c > c
$ hg ci -qAm C c
$ hg ci -qAm C c --secret
abort behavior
......@@ -70,6 +70,17 @@ abort behavior
> eof
$ hg push -r .
pushing to $TESTTMP/source
searching for changes
no changes found (ignored 1 secret changesets)
[1]
$ hg push
pushing to $TESTTMP/source
searching for changes
no changes found (ignored 1 secret changesets)
[1]
$ hg phase --draft
$ hg push -r .
pushing to $TESTTMP/source
abort: push would publish 1 changesets
(* 'experimental.auto-publish' config) (glob)
[255]
......
......@@ -651,3 +651,58 @@ hg next --abort
$ hg next --abort --merge
abort: cannot specify both --abort and --merge
[10]
$ cd ..
Testing --merge and --evolve flags: 1 child, 1 aspchild, dirty working copy
$ hg init next-dirty-evolve
$ cd next-dirty-evolve
$ echo apple > a
$ hg ci -qAm apple
$ echo banana > b
$ hg ci -qAm banana
$ echo coconut > c
$ hg ci -qAm coconut
$ hg prev
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
[1] banana
$ echo blueberry > b
$ hg ci --amend -m blueberry
1 new orphan changesets
$ echo durian > d
$ hg ci -qAm durian
$ hg log -GT "{rev} {desc}\n"
@ 4 durian
|
o 3 blueberry
|
| * 2 coconut
| |
| x 1 banana
|/
o 0 apple
$ hg up 'desc("blueberry")'
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
$ echo avocado > a
$ hg next --no-merge --evolve --dry-run
abort: uncommitted changes
(use `hg amend`, `hg revert` or `hg shelve`)
[20]
$ hg next --no-merge --no-evolve --dry-run
abort: uncommitted changes
(do you want --merge?)
[20]
$ hg next --merge --no-evolve --dry-run
hg update db0dc1f00682;
[4] durian
$ hg next --merge --evolve --dry-run
abort: uncommitted changes
(use `hg amend`, `hg revert` or `hg shelve`)
[20]
......@@ -5,6 +5,17 @@ Test workflow options
$ . "$TESTDIR/testlib/topic_setup.sh"
$ . "$TESTDIR/testlib/common.sh"
Also testing auto-publish config option with this publishing mode
$ cat << EOF >> "$HGRCPATH"
> [ui]
> ssh = "$PYTHON" "$RUNTESTDIR/dummyssh"
> [experimental]
> auto-publish = warn
> [alias]
> tgl = log --rev 'sort(\$1, "topo")' -GT '{rev}:{node|short} {desc} {phase} {branch} {topics}'
> EOF
Publishing of bare branch
=========================
......@@ -32,12 +43,13 @@ pushing a simple branch publish it
$ mkcommit c_dB0
$ hg push
pushing to $TESTTMP/bare-branch-server
1 changesets about to be published
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files
$ hg log --rev 'sort(all(), "topo")' -GT '{rev}:{node|short} {desc} {phase} {branch} {topics}'
$ hg tgl 'all()'
@ 2:286d02a6e2a2 c_dB0 public default
|
o 1:134bc3852ad2 c_dA0 public default
......@@ -60,12 +72,13 @@ pushing two heads at the same time
(consider using topic for lightweight branches. See 'hg help topic')
$ hg push -f
pushing to $TESTTMP/bare-branch-server
2 changesets about to be published
searching for changes
adding changesets
adding manifests
adding file changes
added 2 changesets with 2 changes to 2 files (+2 heads)
$ hg log --rev 'sort(all(), "topo")' -GT '{rev}:{node|short} {desc} {phase} {branch} {topics}'
$ hg tgl 'all()'
@ 4:9bf953aa81f6 c_dD0 public default
|
| o 3:9d5b8e1f08a4 c_dC0 public default
......@@ -88,12 +101,13 @@ pushing something not on default
$ mkcommit c_aE0
$ hg push --new-branch
pushing to $TESTTMP/bare-branch-server
1 changesets about to be published
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files (+1 heads)
$ hg log --rev 'sort(all(), "topo")' -GT '{rev}:{node|short} {desc} {phase} {branch} {topics}'
$ hg tgl 'all()'
@ 5:0db08e758601 c_aE0 public branchA
|
| o 4:9bf953aa81f6 c_dD0 public default
......@@ -124,7 +138,7 @@ pushing topic
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files
$ hg log --rev 'sort(all(), "topo")' -GT '{rev}:{node|short} {desc} {phase} {branch} {topics}'
$ hg tgl 'all()'
@ 6:0867c4471796 c_dF0 draft default foo
|
o 4:9bf953aa81f6 c_dD0 public default
......@@ -153,12 +167,13 @@ pushing topic over a bare branch
(see 'hg help topics' for more information)
$ hg push
pushing to $TESTTMP/bare-branch-server
1 changesets about to be published
searching for changes
adding changesets
adding manifests
adding file changes
added 2 changesets with 2 changes to 2 files
$ hg log --rev 'sort(all(), "topo")' -GT '{rev}:{node|short} {desc} {phase} {branch} {topics}'
$ hg tgl 'all()'
@ 8:858be9a8daaf c_dH0 draft default bar
|
o 7:0e4041d324d0 c_dG0 public default
......@@ -193,12 +208,13 @@ Pushing topic in between bare branch
$ mkcommit c_aK0
$ hg push
pushing to $TESTTMP/bare-branch-server
2 changesets about to be published
searching for changes
adding changesets
adding manifests
adding file changes
added 3 changesets with 3 changes to 3 files
$ hg log --rev 'sort(all(), "topo")' -GT '{rev}:{node|short} {desc} {phase} {branch} {topics}'
$ hg tgl 'all()'
@ 11:b0a00ebdfd24 c_aK0 public branchA
|
o 5:0db08e758601 c_aE0 public branchA
......@@ -235,12 +251,13 @@ merging a topic in branch
$ hg ci -m 'c_dL0'
$ hg push
pushing to $TESTTMP/bare-branch-server
2 changesets about to be published
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 0 changes to 0 files (-1 heads)
$ hg log --rev 'sort(all(), "topo")' -GT '{rev}:{node|short} {desc} {phase} {branch} {topics}'
$ hg tgl 'all()'
@ 12:a6f9f8c6c6cc c_dL0 public default
|\
| o 9:4b5570d89f0f c_dI0 public default
......@@ -267,7 +284,7 @@ merging a topic in branch
|/
o 0:ea207398892e ROOT public default
$ hg log -R ../bare-branch-server --rev 'sort(all(), "topo")' -GT '{rev}:{node|short} {desc} {phase} {branch} {topics}'
$ hg tgl 'all()' -R ../bare-branch-server
o 12:a6f9f8c6c6cc c_dL0 public default
|\
| o 9:4b5570d89f0f c_dI0 public default
......@@ -328,12 +345,33 @@ Checking the option to prevent automatic publishing
$ hg up branchA
2 files updated, 0 files merged, 5 files removed, 0 files unresolved
Trying to push changeset without topic (would publish them)
Making sure the topic-publishing mode is announced as a capability
$ mkcommit c_aM0
$ hg debugcapabilities $TESTTMP/bare-branch-server | grep topics
ext-topics-publish=auto
topics
$ hg debugcapabilities ssh://user@dummy/bare-branch-server | grep topics
_exttopics_heads
ext-topics-publish=auto
topics
$ hg serve -R ../bare-branch-server -p $HGPORT -d --pid-file hg.pid
$ cat hg.pid >> $DAEMON_PIDS
$ hg debugcapabilities http://localhost:$HGPORT | grep topics
_exttopics_heads
ext-topics-publish=auto
topics
$ killdaemons.py
Trying to push changeset without topic (would publish them)
$ mkcommit c_aM0
$ hg phase --secret --force
$ hg push --config experimental.auto-publish=abort -r .
pushing to $TESTTMP/bare-branch-server
searching for changes
no changes found (ignored 1 secret changesets)
[1]
$ hg phase --draft
$ hg push --config experimental.auto-publish=abort -r .
pushing to $TESTTMP/bare-branch-server
abort: push would publish 1 changesets
......@@ -351,7 +389,7 @@ Pushing a changeset with topic (not publishing, no warning)
$ hg topic test-push-protection
marked working directory as topic: test-push-protection
$ mkcommit c_aL0
$ mkcommit c_aN0
active topic 'test-push-protection' grew its first changeset
(see 'hg help topics' for more information)
$ hg push --config experimental.auto-publish=abort -r .
......
......@@ -133,8 +133,23 @@ Let's make some changesets unstable
o 0 [] root
Simply walking on unstable changesets should work as expected
$ hg up 'desc("B2")'
switching to topic B
3 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg prev
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
[s1] B1
$ hg next
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
[s2] B2
B1 shouldn't be considered a target, orphan or not
$ hg up 'desc("A2")'
switching to topic A
1 files updated, 0 files merged, 2 files removed, 0 files unresolved
$ hg next
move:[s3] A3
atop:[s2] A2
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment