sapling/tests/test-phases-exchange.t

486 lines
11 KiB
Perl
Raw Normal View History

$ cat >> $HGRCPATH <<EOF
> [extensions]
> graphlog=
> EOF
$ alias hgph='hg log --template "{rev} {phase} {desc} - {node|short}\n"'
$ mkcommit() {
> echo "$1" > "$1"
> hg add "$1"
> hg ci -m "$1"
> }
$ hg init alpha
$ cd alpha
$ mkcommit a-A
$ mkcommit a-B
$ mkcommit a-C
$ mkcommit a-D
$ hgph
3 1 a-D - b555f63b6063
2 1 a-C - 54acac6f23ab
1 1 a-B - 548a3d25dbf0
0 1 a-A - 054250a37db4
$ hg init ../beta
$ hg push -r 1 ../beta
pushing to ../beta
searching for changes
adding changesets
adding manifests
adding file changes
added 2 changesets with 2 changes to 2 files
$ hgph
3 1 a-D - b555f63b6063
2 1 a-C - 54acac6f23ab
1 0 a-B - 548a3d25dbf0
0 0 a-A - 054250a37db4
$ cd ../beta
$ hgph
1 0 a-B - 548a3d25dbf0
0 0 a-A - 054250a37db4
$ hg up -q
$ mkcommit b-A
$ hgph
2 1 b-A - f54f1bb90ff3
1 0 a-B - 548a3d25dbf0
0 0 a-A - 054250a37db4
$ hg pull ../alpha
pulling from ../alpha
searching for changes
adding changesets
adding manifests
adding file changes
added 2 changesets with 2 changes to 2 files (+1 heads)
(run 'hg heads' to see heads, 'hg merge' to merge)
$ hgph
4 0 a-D - b555f63b6063
3 0 a-C - 54acac6f23ab
2 1 b-A - f54f1bb90ff3
1 0 a-B - 548a3d25dbf0
0 0 a-A - 054250a37db4
pull did not updated ../alpha state.
push from alpha to beta should update phase even if nothing is transfered
$ cd ../alpha
$ hgph # not updated by remote pull
3 1 a-D - b555f63b6063
2 1 a-C - 54acac6f23ab
1 0 a-B - 548a3d25dbf0
0 0 a-A - 054250a37db4
$ hg push ../beta
pushing to ../beta
searching for changes
no changes found
$ hgph
3 0 a-D - b555f63b6063
2 0 a-C - 54acac6f23ab
1 0 a-B - 548a3d25dbf0
0 0 a-A - 054250a37db4
update must update phase of common changeset too
$ hg pull ../beta # getting b-A
pulling from ../beta
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files (+1 heads)
(run 'hg heads' to see heads, 'hg merge' to merge)
$ cd ../beta
$ hgph # not updated by remote pull
4 0 a-D - b555f63b6063
3 0 a-C - 54acac6f23ab
2 1 b-A - f54f1bb90ff3
1 0 a-B - 548a3d25dbf0
0 0 a-A - 054250a37db4
$ hg pull ../alpha
pulling from ../alpha
searching for changes
no changes found
$ hgph
4 0 a-D - b555f63b6063
3 0 a-C - 54acac6f23ab
2 0 b-A - f54f1bb90ff3
1 0 a-B - 548a3d25dbf0
0 0 a-A - 054250a37db4
phases: add a phases.publish option What is a "publishing repository"? ================================== Setting a repository as "publishing" alter its behavior **when used as a server**: all changesets are **seen** as public changesets by clients. So, pushing to a "publishing" repository is the most common way to make changesets public: pushed changesets are seen as public on the remote side and marked as such on local side. Note: the "publishing" property have no effects for local operations. Old repository are publishing ============================= Phase is the first step of a series of features aiming at handling mutable history within mercurial. Old client do not support such feature and are unable to hold phase data. The safest solution is to consider as public any changeset going through an old client. Moreover, most hosting solution will not support phase from the beginning. Having old clients seen as public repositories will not change their usage: public repositories where you push *immutable* public changesets *shared* with others. Why is "publishing" the default? ================================ We discussed above that any changeset from a non-phase aware repository should be seen as public. This means that in the following scenario, X is pulled as public:: ~/A$ old-hg init ~/A$ echo 'babar' > jungle ~/A$ old-hg commit -mA 'X' ~/A$ cd ../B ~/B$ new-hg pull ../A # let's pretend A is served by old-hg ~/B$ new-hg log -r tip summary: X phase: public We want to keep this behavior while creating/serving the A repository with ``new-hg``. Although committing with any ``new-hg`` creates a draft changeset. To stay backward compatible, the pull must see the new commit as public. Non-publishing server will advertise them as draft. Having publishing repository the default is thus necessary to ensure this backward compatibility. This default value can also be expressed with the following sentence: "By default, without any configuration, everything you exchange with the outside is immutable.". This behaviour seems sane. Why allow draft changeset in publishing repository ===================================================== Note: The publish option is aimed at controlling the behavior of *server*. Changeset in any state on a publishing server will **always*** be seen as public by other client. "Passive" repository which are only used as server for pull and push operation are not "affected" by this section. As in the choice for default, the main reason to allow draft changeset in publishing server is backward compatibility. With an old client, the following scenario is valid:: ~/A$ old-hg init ~/A$ echo 'babar' > jungle ~/A$ old-hg commit -mA 'X' ~/A$ old-hg qimport -r . # or any other mutable operation on X If the default is publishing and new commits in such repository are "public" The following operation will be denied as X will be an **immutable** public changeset. However as other clients see X as public, any pull//push (or event pull//pull) will mark X as public in repo A. Allowing enforcement of public changeset only repository through config is probably something to do. This could be done with another "strict" option or a third value config for phase related option (mode=public, publishing(default), mutable)
2011-12-15 14:57:33 +04:00
Publish configuration option
----------------------------
Pull
````
phases: add a phases.publish option What is a "publishing repository"? ================================== Setting a repository as "publishing" alter its behavior **when used as a server**: all changesets are **seen** as public changesets by clients. So, pushing to a "publishing" repository is the most common way to make changesets public: pushed changesets are seen as public on the remote side and marked as such on local side. Note: the "publishing" property have no effects for local operations. Old repository are publishing ============================= Phase is the first step of a series of features aiming at handling mutable history within mercurial. Old client do not support such feature and are unable to hold phase data. The safest solution is to consider as public any changeset going through an old client. Moreover, most hosting solution will not support phase from the beginning. Having old clients seen as public repositories will not change their usage: public repositories where you push *immutable* public changesets *shared* with others. Why is "publishing" the default? ================================ We discussed above that any changeset from a non-phase aware repository should be seen as public. This means that in the following scenario, X is pulled as public:: ~/A$ old-hg init ~/A$ echo 'babar' > jungle ~/A$ old-hg commit -mA 'X' ~/A$ cd ../B ~/B$ new-hg pull ../A # let's pretend A is served by old-hg ~/B$ new-hg log -r tip summary: X phase: public We want to keep this behavior while creating/serving the A repository with ``new-hg``. Although committing with any ``new-hg`` creates a draft changeset. To stay backward compatible, the pull must see the new commit as public. Non-publishing server will advertise them as draft. Having publishing repository the default is thus necessary to ensure this backward compatibility. This default value can also be expressed with the following sentence: "By default, without any configuration, everything you exchange with the outside is immutable.". This behaviour seems sane. Why allow draft changeset in publishing repository ===================================================== Note: The publish option is aimed at controlling the behavior of *server*. Changeset in any state on a publishing server will **always*** be seen as public by other client. "Passive" repository which are only used as server for pull and push operation are not "affected" by this section. As in the choice for default, the main reason to allow draft changeset in publishing server is backward compatibility. With an old client, the following scenario is valid:: ~/A$ old-hg init ~/A$ echo 'babar' > jungle ~/A$ old-hg commit -mA 'X' ~/A$ old-hg qimport -r . # or any other mutable operation on X If the default is publishing and new commits in such repository are "public" The following operation will be denied as X will be an **immutable** public changeset. However as other clients see X as public, any pull//push (or event pull//pull) will mark X as public in repo A. Allowing enforcement of public changeset only repository through config is probably something to do. This could be done with another "strict" option or a third value config for phase related option (mode=public, publishing(default), mutable)
2011-12-15 14:57:33 +04:00
changegroup are added without phase movement
$ hg bundle -a ../base.bundle
5 changesets found
$ cd ..
$ hg init mu
$ cd mu
$ cat > .hg/hgrc << EOF
> [phases]
> publish=0
> EOF
$ hg unbundle ../base.bundle
adding changesets
adding manifests
adding file changes
added 5 changesets with 5 changes to 5 files (+1 heads)
(run 'hg heads' to see heads, 'hg merge' to merge)
$ hgph
4 1 a-D - b555f63b6063
3 1 a-C - 54acac6f23ab
2 1 b-A - f54f1bb90ff3
1 1 a-B - 548a3d25dbf0
0 1 a-A - 054250a37db4
$ cd ..
Pulling from publish=False to publish=False does not move boundary.
$ hg init nu
$ cd nu
$ cat > .hg/hgrc << EOF
> [phases]
> publish=0
> EOF
$ hg pull ../mu -r 54acac6f23ab
pulling from ../mu
adding changesets
adding manifests
adding file changes
added 3 changesets with 3 changes to 3 files
(run 'hg update' to get a working copy)
$ hgph
2 1 a-C - 54acac6f23ab
1 1 a-B - 548a3d25dbf0
0 1 a-A - 054250a37db4
Even for common
$ hg pull ../mu -r f54f1bb90ff3
pulling from ../mu
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files (+1 heads)
(run 'hg heads' to see heads, 'hg merge' to merge)
$ hgph
3 1 b-A - f54f1bb90ff3
2 1 a-C - 54acac6f23ab
1 1 a-B - 548a3d25dbf0
0 1 a-A - 054250a37db4
Pulling from Publish=True to Publish=False move boundary in common set.
we are in nu
$ hg pull ../alpha -r b555f63b6063
pulling from ../alpha
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files
(run 'hg update' to get a working copy)
$ hgph
4 0 a-D - b555f63b6063
3 0 b-A - f54f1bb90ff3
2 0 a-C - 54acac6f23ab
1 0 a-B - 548a3d25dbf0
0 0 a-A - 054250a37db4
pulling from Publish=False to publish=False with some public
$ hg up -q f54f1bb90ff3
$ mkcommit n-A
$ mkcommit n-B
$ hgph
6 1 n-B - 145e75495359
5 1 n-A - d6bcb4f74035
4 0 a-D - b555f63b6063
3 0 b-A - f54f1bb90ff3
2 0 a-C - 54acac6f23ab
1 0 a-B - 548a3d25dbf0
0 0 a-A - 054250a37db4
$ cd ../mu
$ hg pull ../nu
pulling from ../nu
searching for changes
adding changesets
adding manifests
adding file changes
added 2 changesets with 2 changes to 2 files
(run 'hg update' to get a working copy)
$ hgph
6 1 n-B - 145e75495359
5 1 n-A - d6bcb4f74035
4 0 a-D - b555f63b6063
3 0 a-C - 54acac6f23ab
2 0 b-A - f54f1bb90ff3
1 0 a-B - 548a3d25dbf0
0 0 a-A - 054250a37db4
$ cd ..
pulling into publish=True
$ cd alpha
$ hgph
4 0 b-A - f54f1bb90ff3
3 0 a-D - b555f63b6063
2 0 a-C - 54acac6f23ab
1 0 a-B - 548a3d25dbf0
0 0 a-A - 054250a37db4
$ hg pull ../mu
pulling from ../mu
searching for changes
adding changesets
adding manifests
adding file changes
added 2 changesets with 2 changes to 2 files
(run 'hg update' to get a working copy)
$ hgph
6 0 n-B - 145e75495359
5 0 n-A - d6bcb4f74035
4 0 b-A - f54f1bb90ff3
3 0 a-D - b555f63b6063
2 0 a-C - 54acac6f23ab
1 0 a-B - 548a3d25dbf0
0 0 a-A - 054250a37db4
$ cd ..
pulling back into original repo
$ cd nu
$ hg pull ../alpha
pulling from ../alpha
searching for changes
no changes found
$ hgph
6 0 n-B - 145e75495359
5 0 n-A - d6bcb4f74035
4 0 a-D - b555f63b6063
3 0 b-A - f54f1bb90ff3
2 0 a-C - 54acac6f23ab
1 0 a-B - 548a3d25dbf0
0 0 a-A - 054250a37db4
$ cd ..
Push
````
initial setup
$ cd alpha
$ hg glog
o changeset: 6:145e75495359
| tag: tip
| user: test
| date: Thu Jan 01 00:00:00 1970 +0000
| summary: n-B
|
o changeset: 5:d6bcb4f74035
| user: test
| date: Thu Jan 01 00:00:00 1970 +0000
| summary: n-A
|
o changeset: 4:f54f1bb90ff3
| parent: 1:548a3d25dbf0
| user: test
| date: Thu Jan 01 00:00:00 1970 +0000
| summary: b-A
|
| @ changeset: 3:b555f63b6063
| | user: test
| | date: Thu Jan 01 00:00:00 1970 +0000
| | summary: a-D
| |
| o changeset: 2:54acac6f23ab
|/ user: test
| date: Thu Jan 01 00:00:00 1970 +0000
| summary: a-C
|
o changeset: 1:548a3d25dbf0
| user: test
| date: Thu Jan 01 00:00:00 1970 +0000
| summary: a-B
|
o changeset: 0:054250a37db4
user: test
date: Thu Jan 01 00:00:00 1970 +0000
summary: a-A
$ mkcommit a-E
$ mkcommit a-F
$ mkcommit a-G
$ hg up d6bcb4f74035 -q
$ mkcommit a-H
created new head
$ hgph
10 1 a-H - 967b449fbc94
9 1 a-G - 3e27b6f1eee1
8 1 a-F - b740e3e5c05d
7 1 a-E - e9f537e46dea
6 0 n-B - 145e75495359
5 0 n-A - d6bcb4f74035
4 0 b-A - f54f1bb90ff3
3 0 a-D - b555f63b6063
2 0 a-C - 54acac6f23ab
1 0 a-B - 548a3d25dbf0
0 0 a-A - 054250a37db4
Pushing to Publish=False (unknown changeset)
$ hg push ../mu -r b740e3e5c05d # a-F
pushing to ../mu
searching for changes
adding changesets
adding manifests
adding file changes
added 2 changesets with 2 changes to 2 files
$ hgph
10 1 a-H - 967b449fbc94
9 1 a-G - 3e27b6f1eee1
8 1 a-F - b740e3e5c05d
7 1 a-E - e9f537e46dea
6 0 n-B - 145e75495359
5 0 n-A - d6bcb4f74035
4 0 b-A - f54f1bb90ff3
3 0 a-D - b555f63b6063
2 0 a-C - 54acac6f23ab
1 0 a-B - 548a3d25dbf0
0 0 a-A - 054250a37db4
$ cd ../mu
$ hgph # d6bcb4f74035 and 145e75495359 changed because common is too smart
8 1 a-F - b740e3e5c05d
7 1 a-E - e9f537e46dea
6 0 n-B - 145e75495359
5 0 n-A - d6bcb4f74035
4 0 a-D - b555f63b6063
3 0 a-C - 54acac6f23ab
2 0 b-A - f54f1bb90ff3
1 0 a-B - 548a3d25dbf0
0 0 a-A - 054250a37db4
Pushing to Publish=True (unknown changeset)
$ hg push ../beta -r b740e3e5c05d
pushing to ../beta
searching for changes
adding changesets
adding manifests
adding file changes
added 2 changesets with 2 changes to 2 files
$ hgph # again d6bcb4f74035 and 145e75495359 changed because common is too smart
8 0 a-F - b740e3e5c05d
7 0 a-E - e9f537e46dea
6 0 n-B - 145e75495359
5 0 n-A - d6bcb4f74035
4 0 a-D - b555f63b6063
3 0 a-C - 54acac6f23ab
2 0 b-A - f54f1bb90ff3
1 0 a-B - 548a3d25dbf0
0 0 a-A - 054250a37db4
Pushing to Publish=True (common changeset)
$ cd ../beta
$ hg push ../alpha
pushing to ../alpha
searching for changes
no changes found
$ hgph
6 0 a-F - b740e3e5c05d
5 0 a-E - e9f537e46dea
4 0 a-D - b555f63b6063
3 0 a-C - 54acac6f23ab
2 0 b-A - f54f1bb90ff3
1 0 a-B - 548a3d25dbf0
0 0 a-A - 054250a37db4
$ cd ../alpha
$ hgph # e9f537e46dea and b740e3e5c05d should have been sync to 0
10 1 a-H - 967b449fbc94
9 1 a-G - 3e27b6f1eee1
8 0 a-F - b740e3e5c05d
7 0 a-E - e9f537e46dea
6 0 n-B - 145e75495359
5 0 n-A - d6bcb4f74035
4 0 b-A - f54f1bb90ff3
3 0 a-D - b555f63b6063
2 0 a-C - 54acac6f23ab
1 0 a-B - 548a3d25dbf0
0 0 a-A - 054250a37db4
Pushing to Publish=False (common changeset that change phase + unknown one)
$ hg push ../mu -r 967b449fbc94 -f
pushing to ../mu
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files (+1 heads)
$ hgph
10 1 a-H - 967b449fbc94
9 1 a-G - 3e27b6f1eee1
8 0 a-F - b740e3e5c05d
7 0 a-E - e9f537e46dea
6 0 n-B - 145e75495359
5 0 n-A - d6bcb4f74035
4 0 b-A - f54f1bb90ff3
3 0 a-D - b555f63b6063
2 0 a-C - 54acac6f23ab
1 0 a-B - 548a3d25dbf0
0 0 a-A - 054250a37db4
$ cd ../mu
$ hgph # d6bcb4f74035 should have changed phase
> # again d6bcb4f74035 and 145e75495359 changed because common was too smart
9 1 a-H - 967b449fbc94
8 0 a-F - b740e3e5c05d
7 0 a-E - e9f537e46dea
6 0 n-B - 145e75495359
5 0 n-A - d6bcb4f74035
4 0 a-D - b555f63b6063
3 0 a-C - 54acac6f23ab
2 0 b-A - f54f1bb90ff3
1 0 a-B - 548a3d25dbf0
0 0 a-A - 054250a37db4
Pushing to Publish=True (common changeset from publish=False)
$ hg push ../alpha
pushing to ../alpha
searching for changes
no changes found
$ hgph
9 0 a-H - 967b449fbc94
8 0 a-F - b740e3e5c05d
7 0 a-E - e9f537e46dea
6 0 n-B - 145e75495359
5 0 n-A - d6bcb4f74035
4 0 a-D - b555f63b6063
3 0 a-C - 54acac6f23ab
2 0 b-A - f54f1bb90ff3
1 0 a-B - 548a3d25dbf0
0 0 a-A - 054250a37db4
$ hgph -R ../alpha # a-H should have been synced to 0
10 0 a-H - 967b449fbc94
9 1 a-G - 3e27b6f1eee1
8 0 a-F - b740e3e5c05d
7 0 a-E - e9f537e46dea
6 0 n-B - 145e75495359
5 0 n-A - d6bcb4f74035
4 0 b-A - f54f1bb90ff3
3 0 a-D - b555f63b6063
2 0 a-C - 54acac6f23ab
1 0 a-B - 548a3d25dbf0
0 0 a-A - 054250a37db4