##// END OF EJS Templates
bookmark: fix remote bookmark deletion when the push is raced...
marmoute -
r52529:553eb132 stable
parent child Browse files
Show More
@@ -0,0 +1,153 b''
1 ============================================
2 Testing various race condition while pushing
3 ============================================
4
5 $ cat << EOF >> $HGRCPATH
6 > [command-templates]
7 > log={rev}:{node|short} {desc|firstline} {bookmarks}
8 > [ui]
9 > timeout = 20
10 > [phases]
11 > publish=False
12 > EOF
13
14 Initial Setup
15 =============
16
17 $ hg init dst
18 $ echo a > dst/a-file
19 $ hg --cwd dst add a-file
20 $ hg --cwd dst commit -m root
21 $ hg --cwd dst bookmark my-book
22 $ hg --cwd dst bookmarks
23 * my-book 0:a64e49638499
24 $ hg --cwd dst log -G
25 @ 0:a64e49638499 root my-book
26
27
28 $ hg clone ssh://user@dummy/dst src
29 requesting all changes
30 adding changesets
31 adding manifests
32 adding file changes
33 added 1 changesets with 1 changes to 1 files
34 new changesets a64e49638499 (1 drafts)
35 updating to branch default
36 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
37 $ hg --cwd src update my-book
38 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
39 (activating bookmark my-book)
40 $ hg --cwd src log -G
41 @ 0:a64e49638499 root my-book
42
43
44 $ echo b > src/a-file
45 $ hg --cwd src commit -m cA0_
46 $ hg --cwd src log -G
47 @ 1:e89d3a6ed79b cA0_ my-book
48 |
49 o 0:a64e49638499 root
50
51
52 Race condition while pushing a forward moving bookmarks
53 =======================================================
54
55 This is currently slightly broken as we eventually don't push the bookmark.
56 However at least we do not delete the remote one.
57
58 $ echo c > src/a-file
59 $ hg --cwd src push -B my-book --config hooks.prelock="hg commit -m cA1_"
60 pushing to ssh://user@dummy/dst
61 searching for changes
62 remote: adding changesets
63 remote: adding manifests
64 remote: adding file changes
65 remote: added 1 changesets with 1 changes to 1 files
66 $ hg --cwd src log -G
67 @ 2:08d837bbfe8d cA1_ my-book
68 |
69 o 1:e89d3a6ed79b cA0_
70 |
71 o 0:a64e49638499 root
72
73 $ hg --cwd dst log -G
74 o 1:e89d3a6ed79b cA0_
75 |
76 @ 0:a64e49638499 root my-book
77
78
79 create a side-moving bookmark
80 Race condition while pushing a side moving bookmarks
81 =======================================================
82
83 resynchronize the repo and setup test
84 -------------------------------------
85
86 $ hg --cwd src push -B my-book
87 pushing to ssh://user@dummy/dst
88 searching for changes
89 remote: adding changesets
90 remote: adding manifests
91 remote: adding file changes
92 remote: added 1 changesets with 1 changes to 1 files
93 updating bookmark my-book
94 $ hg --cwd dst log -G
95 o 2:08d837bbfe8d cA1_ my-book
96 |
97 o 1:e89d3a6ed79b cA0_
98 |
99 @ 0:a64e49638499 root
100
101
102 $ hg --cwd src up 'desc("root")'
103 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
104 (leaving bookmark my-book)
105 $ echo d > src/a-file
106 $ hg --cwd src commit -m cB0_
107 created new head
108 $ hg --cwd src bookmark --force my-book
109 $ echo e > src/a-file
110 $ hg --cwd src log -G
111 @ 3:726401661fe5 cB0_ my-book
112 |
113 | o 2:08d837bbfe8d cA1_
114 | |
115 | o 1:e89d3a6ed79b cA0_
116 |/
117 o 0:a64e49638499 root
118
119
120 Push the bookmark while a commit is being made
121 ----------------------------------------------
122
123 This is currently slightly broken as we eventually don't push the bookmark.
124 However at least we do not delete the remote one.
125
126 $ hg --cwd src push -f -r 'desc("cB0_")' -B my-book --config hooks.prelock="hg commit -m cB1_"
127 pushing to ssh://user@dummy/dst
128 searching for changes
129 remote: adding changesets
130 remote: adding manifests
131 remote: adding file changes
132 remote: added 1 changesets with 1 changes to 1 files (+1 heads)
133 $ hg --cwd src log -G
134 @ 4:a7f9cbf631a0 cB1_ my-book
135 |
136 o 3:726401661fe5 cB0_
137 |
138 | o 2:08d837bbfe8d cA1_
139 | |
140 | o 1:e89d3a6ed79b cA0_
141 |/
142 o 0:a64e49638499 root
143
144
145 $ hg --cwd dst log -G
146 o 3:726401661fe5 cB0_
147 |
148 | o 2:08d837bbfe8d cA1_ my-book
149 | |
150 | o 1:e89d3a6ed79b cA0_
151 |/
152 @ 0:a64e49638499 root
153
@@ -717,13 +717,19 b' def _processcompared(pushop, pushed, exp'
717 717 if bookmod.isdivergent(b):
718 718 pushop.ui.warn(_(b'cannot push divergent bookmark %s!\n') % b)
719 719 pushop.bkresult = 2
720 elif pushed and repo[scid].rev() not in pushed:
721 # in case of race or secret
722 msg = _(b'cannot push bookmark X without its revision: %s!\n')
723 pushop.ui.warn(msg % b)
724 pushop.bkresult = 2
720 725 else:
721 726 pushop.outbookmarks.append((b, b'', scid))
722 727 # search for overwritten bookmark
723 728 for b, scid, dcid in list(advdst) + list(diverge) + list(differ):
724 729 if b in explicit:
725 730 explicit.remove(b)
726 pushop.outbookmarks.append((b, dcid, scid))
731 if not pushed or repo[scid].rev() in pushed:
732 pushop.outbookmarks.append((b, dcid, scid))
727 733 # search for bookmark to delete
728 734 for b, scid, dcid in adddst:
729 735 if b in explicit:
General Comments 0
You need to be logged in to leave comments. Login now