Mercurial > public > mercurial-scm > hg
comparison mercurial/bundle2.py @ 34820:a95067b1dca6
phase: introduce a new 'check:phases' part
This part checks if revisions are still in the same phase as when the
bundle was generated. This is similar to what 'check:heads' or
'check:updated-heads' bundle2 part achieves for changesets.
We needs seems before we can move away from pushkey usage from phase since
pushkey has it own built-in push-race detection.
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Wed, 11 Oct 2017 07:13:02 +0200 |
parents | 5f79f5f8487a |
children | 241d9caca11e |
comparison
equal
deleted
inserted
replaced
34819:eb6375651974 | 34820:a95067b1dca6 |
---|---|
155 | 155 |
156 from .i18n import _ | 156 from .i18n import _ |
157 from . import ( | 157 from . import ( |
158 changegroup, | 158 changegroup, |
159 error, | 159 error, |
160 node as nodemod, | |
160 obsolete, | 161 obsolete, |
161 phases, | 162 phases, |
162 pushkey, | 163 pushkey, |
163 pycompat, | 164 pycompat, |
164 tags, | 165 tags, |
1747 for h in heads: | 1748 for h in heads: |
1748 if h not in currentheads: | 1749 if h not in currentheads: |
1749 raise error.PushRaced('repository changed while pushing - ' | 1750 raise error.PushRaced('repository changed while pushing - ' |
1750 'please try again') | 1751 'please try again') |
1751 | 1752 |
1753 @parthandler('check:phases') | |
1754 def handlecheckphases(op, inpart): | |
1755 """check that phase boundaries of the repository did not change | |
1756 | |
1757 This is used to detect a push race. | |
1758 """ | |
1759 phasetonodes = phases.binarydecode(inpart) | |
1760 unfi = op.repo.unfiltered() | |
1761 cl = unfi.changelog | |
1762 phasecache = unfi._phasecache | |
1763 msg = ('repository changed while pushing - please try again ' | |
1764 '(%s is %s expected %s)') | |
1765 for expectedphase, nodes in enumerate(phasetonodes): | |
1766 for n in nodes: | |
1767 actualphase = phasecache.phase(unfi, cl.rev(n)) | |
1768 if actualphase != expectedphase: | |
1769 finalmsg = msg % (nodemod.short(n), | |
1770 phases.phasenames[actualphase], | |
1771 phases.phasenames[expectedphase]) | |
1772 raise error.PushRaced(finalmsg) | |
1773 | |
1752 @parthandler('output') | 1774 @parthandler('output') |
1753 def handleoutput(op, inpart): | 1775 def handleoutput(op, inpart): |
1754 """forward output captured on the server to the client""" | 1776 """forward output captured on the server to the client""" |
1755 for line in inpart.read().splitlines(): | 1777 for line in inpart.read().splitlines(): |
1756 op.ui.status(_('remote: %s\n') % line) | 1778 op.ui.status(_('remote: %s\n') % line) |