Show More
@@ -7,6 +7,7 b'' | |||||
7 |
|
7 | |||
8 | from node import nullid, nullrev, hex, bin |
|
8 | from node import nullid, nullrev, hex, bin | |
9 | from i18n import _ |
|
9 | from i18n import _ | |
|
10 | from mercurial import obsolete | |||
10 | import error, util, filemerge, copies, subrepo, worker, dicthelpers |
|
11 | import error, util, filemerge, copies, subrepo, worker, dicthelpers | |
11 | import errno, os, shutil |
|
12 | import errno, os, shutil | |
12 |
|
13 | |||
@@ -697,17 +698,26 b' def update(repo, node, branchmerge, forc' | |||||
697 | "subrepository '%s'") % s) |
|
698 | "subrepository '%s'") % s) | |
698 |
|
699 | |||
699 | elif not overwrite: |
|
700 | elif not overwrite: | |
700 |
if pa |
|
701 | if pa not in (p1, p2): # nolinear | |
701 | pass # all good |
|
702 | dirty = wc.dirty(missing=True) | |
702 |
|
|
703 | if dirty or onode is None: | |
703 | raise util.Abort(_("crosses branches (merge branches or use" |
|
704 | # Branching is a bit strange to ensure we do the minimal | |
704 | " --clean to discard changes)")) |
|
705 | # amount of call to obsolete.background. | |
705 | elif onode is None: |
|
706 | foreground = obsolete.foreground(repo, [p1.node()]) | |
706 | raise util.Abort(_("crosses branches (merge branches or update" |
|
707 | # note: the <node> variable contains a random identifier | |
707 | " --check to force update)")) |
|
708 | if repo[node].node() in foreground: | |
708 | else: |
|
709 | pa = p1 # allow updating to successors | |
709 | # Allow jumping branches if clean and specific rev given |
|
710 | elif dirty: | |
710 | pa = p1 |
|
711 | msg = _("crosses branches (merge branches or use" | |
|
712 | " --clean to discard changes)") | |||
|
713 | raise util.Abort(msg) | |||
|
714 | else: # node is none | |||
|
715 | msg = _("crosses branches (merge branches or update" | |||
|
716 | " --check to force update)") | |||
|
717 | raise util.Abort(msg) | |||
|
718 | else: | |||
|
719 | # Allow jumping branches if clean and specific rev given | |||
|
720 | pa = p1 | |||
711 |
|
721 | |||
712 | ### calculate phase |
|
722 | ### calculate phase | |
713 | actions = calculateupdates(repo, wc, p2, pa, |
|
723 | actions = calculateupdates(repo, wc, p2, pa, |
@@ -164,3 +164,63 b' Cases are run as shown in that table, ro' | |||||
164 | parent=1 |
|
164 | parent=1 | |
165 | M foo |
|
165 | M foo | |
166 |
|
166 | |||
|
167 | Test obsolescence behavior | |||
|
168 | --------------------------------------------------------------------- | |||
|
169 | ||||
|
170 | successors should be taken in account when checking head destination | |||
|
171 | ||||
|
172 | $ cat << EOF >> $HGRCPATH | |||
|
173 | > [extensions] | |||
|
174 | > obs=$TESTTMP/obs.py | |||
|
175 | > [ui] | |||
|
176 | > logtemplate={rev}:{node|short} {desc|firstline} | |||
|
177 | > EOF | |||
|
178 | $ cat > $TESTTMP/obs.py << EOF | |||
|
179 | > import mercurial.obsolete | |||
|
180 | > mercurial.obsolete._enabled = True | |||
|
181 | > EOF | |||
|
182 | ||||
|
183 | Test no-argument update to a successor of an obsoleted changeset | |||
|
184 | ||||
|
185 | $ hg log -G | |||
|
186 | o 5:ff252e8273df 5 | |||
|
187 | | | |||
|
188 | o 4:d047485b3896 4 | |||
|
189 | | | |||
|
190 | | o 3:6efa171f091b 3 | |||
|
191 | | | | |||
|
192 | | | o 2:bd10386d478c 2 | |||
|
193 | | |/ | |||
|
194 | | @ 1:0786582aa4b1 1 | |||
|
195 | |/ | |||
|
196 | o 0:60829823a42a 0 | |||
|
197 | ||||
|
198 | $ hg status | |||
|
199 | M foo | |||
|
200 | ||||
|
201 | We add simple obsolescence marker between 3 and 4 (indirect successors) | |||
|
202 | ||||
|
203 | $ hg id --debug -i -r 3 | |||
|
204 | 6efa171f091b00a3c35edc15d48c52a498929953 | |||
|
205 | $ hg id --debug -i -r 4 | |||
|
206 | d047485b3896813b2a624e86201983520f003206 | |||
|
207 | $ hg debugobsolete 6efa171f091b00a3c35edc15d48c52a498929953 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | |||
|
208 | $ hg debugobsolete aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa d047485b3896813b2a624e86201983520f003206 | |||
|
209 | ||||
|
210 | Test that 5 is detected as a valid destination from 3 | |||
|
211 | $ hg up --quiet --hidden 3 | |||
|
212 | $ hg up 5 | |||
|
213 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
214 | ||||
|
215 | Test that 5 is detected as a valid destination from 1 | |||
|
216 | $ hg up --quiet 0 # we should be able to update to 3 directly | |||
|
217 | $ hg up --quiet --hidden 3 # but not implemented yet. | |||
|
218 | $ hg up 5 | |||
|
219 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
220 | ||||
|
221 | Test that 5 is not detected as a valid destination from 2 | |||
|
222 | $ hg up --quiet 0 | |||
|
223 | $ hg up --quiet 2 | |||
|
224 | $ hg up 5 | |||
|
225 | abort: crosses branches (merge branches or use --clean to discard changes) | |||
|
226 | [255] |
General Comments 0
You need to be logged in to leave comments.
Login now