##// END OF EJS Templates
windows: add win32com.shell to demandimport ignore list...
windows: add win32com.shell to demandimport ignore list Module 'appdirs' tries to import win32com.shell (and catch ImportError as an indication of failure) to check whether some further functionality should be implemented one or another way [1]. Of course, demandimport lets it down, so if we want appdirs to work we have to add it to demandimport's ignore list. The reason we want appdirs to work is becuase it is used by setuptools [2] to determine egg cache location. Only fairly recent versions of setuptools depend on this so people don't see this often. [1] https://github.com/ActiveState/appdirs/blob/master/appdirs.py#L560 [2] https://github.com/pypa/setuptools/blob/aae0a928119d2a178882c32bded02270e30d0273/pkg_resources/__init__.py#L1369

File last commit:

r31342:1470b0f7 default
r31990:3e03a4b9 default
Show More
phases.py
491 lines | 17.2 KiB | text/x-python | PythonLexer
Pierre-Yves David
phases: change publish behavior to only alter behavior when server....
r15659 """ Mercurial phases support code
---
Copyright 2011 Pierre-Yves David <pierre-yves.david@ens-lyon.org>
Logilab SA <contact@logilab.fr>
Augie Fackler <durin42@gmail.com>
Martin Geisler
phases: wrap docstrings at 70 characters
r16725 This software may be used and distributed according to the terms
of the GNU General Public License version 2 or any later version.
Pierre-Yves David
phases: change publish behavior to only alter behavior when server....
r15659
---
This module implements most phase logic in mercurial.
Basic Concept
=============
Martin Geisler
phases: fix typos in docstrings
r16724 A 'changeset phase' is an indicator that tells us how a changeset is
Martin Geisler
phases: wrap docstrings at 70 characters
r16725 manipulated and communicated. The details of each phase is described
below, here we describe the properties they have in common.
Pierre-Yves David
phases: change publish behavior to only alter behavior when server....
r15659
Martin Geisler
phases: wrap docstrings at 70 characters
r16725 Like bookmarks, phases are not stored in history and thus are not
permanent and leave no audit trail.
Pierre-Yves David
phases: change publish behavior to only alter behavior when server....
r15659
Martin Geisler
phases: wrap docstrings at 70 characters
r16725 First, no changeset can be in two phases at once. Phases are ordered,
so they can be considered from lowest to highest. The default, lowest
phase is 'public' - this is the normal phase of existing changesets. A
child changeset can not be in a lower phase than its parents.
Pierre-Yves David
phases: change publish behavior to only alter behavior when server....
r15659
These phases share a hierarchy of traits:
immutable shared
public: X X
draft: X
Pierre-Yves David
phases: update doc to mention secret phase
r15705 secret:
Pierre-Yves David
phases: change publish behavior to only alter behavior when server....
r15659
Martin Geisler
phases: fix typos in docstrings
r16724 Local commits are draft by default.
Pierre-Yves David
phases: change publish behavior to only alter behavior when server....
r15659
Martin Geisler
phases: fix typos in docstrings
r16724 Phase Movement and Exchange
===========================
Pierre-Yves David
phases: change publish behavior to only alter behavior when server....
r15659
Martin Geisler
phases: wrap docstrings at 70 characters
r16725 Phase data is exchanged by pushkey on pull and push. Some servers have
a publish option set, we call such a server a "publishing server".
Pushing a draft changeset to a publishing server changes the phase to
public.
Pierre-Yves David
phases: change publish behavior to only alter behavior when server....
r15659
A small list of fact/rules define the exchange of phase:
* old client never changes server states
* pull never changes server states
Martin Geisler
phases: fix typos in docstrings
r16724 * publish and old server changesets are seen as public by client
Martin Geisler
phases: wrap docstrings at 70 characters
r16725 * any secret changeset seen in another repository is lowered to at
least draft
Pierre-Yves David
phases: change publish behavior to only alter behavior when server....
r15659
Martin Geisler
phases: wrap docstrings at 70 characters
r16725 Here is the final table summing up the 49 possible use cases of phase
exchange:
Pierre-Yves David
phases: change publish behavior to only alter behavior when server....
r15659
server
old publish non-publish
N X N D P N D P
old client
pull
N - X/X - X/D X/P - X/D X/P
X - X/X - X/D X/P - X/D X/P
push
X X/X X/X X/P X/P X/P X/D X/D X/P
new client
pull
N - P/X - P/D P/P - D/D P/P
D - P/X - P/D P/P - D/D P/P
P - P/X - P/D P/P - P/D P/P
push
D P/X P/X P/P P/P P/P D/D D/D P/P
P P/X P/X P/P P/P P/P P/P P/P P/P
Legend:
A/B = final state on client / state on server
* N = new/not present,
* P = public,
* D = draft,
Martin Geisler
phases: wrap docstrings at 70 characters
r16725 * X = not tracked (i.e., the old client or server has no internal
way of recording the phase.)
Pierre-Yves David
phases: change publish behavior to only alter behavior when server....
r15659
passive = only pushes
A cell here can be read like this:
Martin Geisler
phases: wrap docstrings at 70 characters
r16725 "When a new client pushes a draft changeset (D) to a publishing
server where it's not present (N), it's marked public on both
sides (P/P)."
Pierre-Yves David
phases: change publish behavior to only alter behavior when server....
r15659
Martin Geisler
phases: fix typos in docstrings
r16724 Note: old client behave as a publishing server with draft only content
Pierre-Yves David
phases: change publish behavior to only alter behavior when server....
r15659 - other people see it as public
- content is pushed as draft
"""
Pierre-Yves David
phases: Minimal first add.
r15417
Gregory Szorc
phases: use absolute_import
r25966 from __future__ import absolute_import
Matt Mackall
phases: handle errors other than ENOENT appropriately
r15419 import errno
Gregory Szorc
phases: use absolute_import
r25966
from .i18n import _
from .node import (
bin,
hex,
nullid,
nullrev,
short,
)
from . import (
error,
Jun Wu
phases: add a getrevset method to phasecache...
r31016 smartset,
FUJIWARA Katsunori
phases: check HG_PENDING strictly...
r31053 txnutil,
Gregory Szorc
phases: use absolute_import
r25966 )
Pierre-Yves David
phases: basic I/O logic...
r15418
Pierre-Yves David
phases: store phase values in constant instead of using raw integer...
r15818 allphases = public, draft, secret = range(3)
Pierre-Yves David
phases: Minimal first add.
r15417 trackedphases = allphases[1:]
Pierre-Yves David
phases: add list of string to access phase name
r15821 phasenames = ['public', 'draft', 'secret']
Pierre-Yves David
phases: basic I/O logic...
r15418
Patrick Mezard
phases: introduce phasecache...
r16657 def _readroots(repo, phasedefaults=None):
Patrick Mezard
phases: stop modifying localrepo in readroots()...
r16625 """Read phase roots from disk
phasedefaults is a list of fn(repo, roots) callable, which are
executed if the phase roots file does not exist. When phases are
being initialized on an existing repository, this could be used to
set selected changesets phase to something else than public.
Return (roots, dirty) where dirty is true if roots differ from
what is being stored.
"""
Pierre-Yves David
clfilter: phases logic should be unfiltered...
r18002 repo = repo.unfiltered()
Patrick Mezard
phases: stop modifying localrepo in readroots()...
r16625 dirty = False
Pierre-Yves David
phases: basic I/O logic...
r15418 roots = [set() for i in allphases]
try:
FUJIWARA Katsunori
phases: check HG_PENDING strictly...
r31053 f, pending = txnutil.trypending(repo.root, repo.svfs, 'phaseroots')
Pierre-Yves David
phases: basic I/O logic...
r15418 try:
for line in f:
Martin Geisler
phases: line.strip().split() == line.split()
r16588 phase, nh = line.split()
Pierre-Yves David
phases: basic I/O logic...
r15418 roots[int(phase)].add(bin(nh))
finally:
f.close()
Gregory Szorc
global: mass rewrite to use modern exception syntax...
r25660 except IOError as inst:
Matt Mackall
phases: handle errors other than ENOENT appropriately
r15419 if inst.errno != errno.ENOENT:
raise
Patrick Mezard
phases: stop modifying localrepo in readroots()...
r16625 if phasedefaults:
for f in phasedefaults:
roots = f(repo, roots)
dirty = True
return roots, dirty
Pierre-Yves David
phases: basic I/O logic...
r15418
Patrick Mezard
phases: introduce phasecache...
r16657 class phasecache(object):
Patrick Mezard
phases: make advance/retractboundary() atomic...
r16658 def __init__(self, repo, phasedefaults, _load=True):
if _load:
# Cheap trick to allow shallow-copy without copy module
self.phaseroots, self.dirty = _readroots(repo, phasedefaults)
Idan Kamara
phases: make _filterunknown a member function of phasecache...
r18220 self._phaserevs = None
Laurent Charignon
phases: add set per phase in C phase computation...
r25190 self._phasesets = None
Idan Kamara
phases: make _filterunknown a member function of phasecache...
r18220 self.filterunknown(repo)
Angel Ezquerra
localrepo: remove all external users of localrepo.sopener...
r23878 self.opener = repo.svfs
Patrick Mezard
phases: make advance/retractboundary() atomic...
r16658
Jun Wu
phases: add a getrevset method to phasecache...
r31016 def getrevset(self, repo, phases):
"""return a smartset for the given phases"""
self.loadphaserevs(repo) # ensure phase's sets are loaded
if self._phasesets and all(self._phasesets[p] is not None
for p in phases):
# fast path - use _phasesets
revs = self._phasesets[phases[0]]
if len(phases) > 1:
revs = revs.copy() # only copy when needed
for p in phases[1:]:
revs.update(self._phasesets[p])
if repo.changelog.filteredrevs:
revs = revs - repo.changelog.filteredrevs
return smartset.baseset(revs)
else:
# slow path - enumerate all revisions
phase = self.phase
revs = (r for r in repo if phase(repo, r) in phases)
return smartset.generatorset(revs, iterasc=True)
Patrick Mezard
phases: make advance/retractboundary() atomic...
r16658 def copy(self):
# Shallow copy meant to ensure isolation in
# advance/retractboundary(), nothing more.
Eric Sumner
bundlerepo: implement safe phasecache...
r23631 ph = self.__class__(None, None, _load=False)
Patrick Mezard
phases: make advance/retractboundary() atomic...
r16658 ph.phaseroots = self.phaseroots[:]
ph.dirty = self.dirty
ph.opener = self.opener
ph._phaserevs = self._phaserevs
Pierre-Yves David
phase: also copy phase's sets when copying phase cache...
r25592 ph._phasesets = self._phasesets
Patrick Mezard
phases: make advance/retractboundary() atomic...
r16658 return ph
def replace(self, phcache):
Pierre-Yves David
phase: document the replace method...
r25613 """replace all values in 'self' with content of phcache"""
Pierre-Yves David
phase: remove a 'for x in "foo bar".split()' idiom in phasecache.replace...
r25614 for a in ('phaseroots', 'dirty', 'opener', '_phaserevs', '_phasesets'):
Patrick Mezard
phases: make advance/retractboundary() atomic...
r16658 setattr(self, a, getattr(phcache, a))
Patrick Mezard
phases: introduce phasecache...
r16657
Laurent Charignon
phases: make two functions private for phase computation
r24599 def _getphaserevsnative(self, repo):
Laurent Charignon
phase: default to C implementation for phase computation
r24444 repo = repo.unfiltered()
nativeroots = []
for phase in trackedphases:
nativeroots.append(map(repo.changelog.rev, self.phaseroots[phase]))
Pierre-Yves David
phases: really fix native phase computation...
r25527 return repo.changelog.computephases(nativeroots)
Laurent Charignon
phase: default to C implementation for phase computation
r24444
Laurent Charignon
phases: make two functions private for phase computation
r24599 def _computephaserevspure(self, repo):
Laurent Charignon
phases: move pure phase computation in a function
r24519 repo = repo.unfiltered()
revs = [public] * len(repo.changelog)
self._phaserevs = revs
self._populatephaseroots(repo)
for phase in trackedphases:
Augie Fackler
phases: explicitly evaluate list returned by map...
r31342 roots = list(map(repo.changelog.rev, self.phaseroots[phase]))
Laurent Charignon
phases: move pure phase computation in a function
r24519 if roots:
for rev in roots:
revs[rev] = phase
for rev in repo.changelog.descendants(roots):
revs[rev] = phase
Pierre-Yves David
phase: rename getphaserevs to loadphaserevs...
r25611 def loadphaserevs(self, repo):
"""ensure phase information is loaded in the object"""
Durham Goode
phases: add invalidate function...
r22893 if self._phaserevs is None:
Laurent Charignon
phase: default to C implementation for phase computation
r24444 try:
Jun Wu
phases: remove experimental.nativephaseskillswitch...
r31152 res = self._getphaserevsnative(repo)
self._phaserevs, self._phasesets = res
Laurent Charignon
phase: default to C implementation for phase computation
r24444 except AttributeError:
Laurent Charignon
phases: make two functions private for phase computation
r24599 self._computephaserevspure(repo)
Durham Goode
phases: move root phase assignment to it's own function...
r22894
Durham Goode
phases: add invalidate function...
r22893 def invalidate(self):
self._phaserevs = None
Pierre-Yves David
phase: invalidate the phase's set cache alongside the revs...
r25593 self._phasesets = None
Patrick Mezard
phases: introduce phasecache...
r16657
Durham Goode
phases: move root phase assignment to it's own function...
r22894 def _populatephaseroots(self, repo):
"""Fills the _phaserevs cache with phases for the roots.
"""
cl = repo.changelog
phaserevs = self._phaserevs
for phase in trackedphases:
roots = map(cl.rev, self.phaseroots[phase])
for root in roots:
phaserevs[root] = phase
Patrick Mezard
phases: introduce phasecache...
r16657 def phase(self, repo, rev):
Mads Kiilerich
fix trivial spelling errors
r17424 # We need a repo argument here to be able to build _phaserevs
Patrick Mezard
phases: introduce phasecache...
r16657 # if necessary. The repository instance is not stored in
# phasecache to avoid reference cycles. The changelog instance
# is not stored because it is a filecache() property and can
# be replaced without us being notified.
if rev == nullrev:
return public
Durham Goode
rebase: fix rebase aborts when 'tip-1' is public (issue4082)...
r19984 if rev < nullrev:
raise ValueError(_('cannot lookup negative revision'))
Patrick Mezard
phases: introduce phasecache...
r16657 if self._phaserevs is None or rev >= len(self._phaserevs):
Durham Goode
phases: add invalidate function...
r22893 self.invalidate()
Pierre-Yves David
phase: rename getphaserevs to loadphaserevs...
r25611 self.loadphaserevs(repo)
Patrick Mezard
phases: introduce phasecache...
r16657 return self._phaserevs[rev]
def write(self):
if not self.dirty:
return
FUJIWARA Katsunori
phases: make writing phaseroots file out avoid ambiguity of file stat...
r29303 f = self.opener('phaseroots', 'w', atomictemp=True, checkambig=True)
Patrick Mezard
phases: introduce phasecache...
r16657 try:
Pierre-Yves David
phase: extract the phaseroots serialization in a dedicated method...
r22079 self._write(f)
Patrick Mezard
phases: introduce phasecache...
r16657 finally:
f.close()
Pierre-Yves David
phase: extract the phaseroots serialization in a dedicated method...
r22079
def _write(self, fp):
for phase, roots in enumerate(self.phaseroots):
for h in roots:
fp.write('%i %s\n' % (phase, hex(h)))
Patrick Mezard
phases: introduce phasecache...
r16657 self.dirty = False
Pierre-Yves David
phases: add a moveboundary function to move phases boundaries...
r15454
Pierre-Yves David
phase: attach phase to the transaction instead of the lock...
r22080 def _updateroots(self, phase, newroots, tr):
Patrick Mezard
phases: make advance/retractboundary() atomic...
r16658 self.phaseroots[phase] = newroots
Durham Goode
phases: add invalidate function...
r22893 self.invalidate()
Patrick Mezard
phases: make advance/retractboundary() atomic...
r16658 self.dirty = True
Pierre-Yves David
phase: attach phase to the transaction instead of the lock...
r22080 tr.addfilegenerator('phase', ('phaseroots',), self._write)
Pierre-Yves David
phases: inform transaction-related hooks that a phase was moved...
r22940 tr.hookargs['phases_moved'] = '1'
Pierre-Yves David
phase: attach phase to the transaction instead of the lock...
r22080
Pierre-Yves David
phase: add a transaction argument to advanceboundary...
r22069 def advanceboundary(self, repo, tr, targetphase, nodes):
Patrick Mezard
phases: make advance/retractboundary() atomic...
r16658 # Be careful to preserve shallow-copied values: do not update
# phaseroots values, replace them.
Pierre-Yves David
clfilter: phases logic should be unfiltered...
r18002 repo = repo.unfiltered()
Patrick Mezard
phases: make advance/retractboundary() atomic...
r16658 delroots = [] # set of root deleted by this path
for phase in xrange(targetphase + 1, len(allphases)):
# filter nodes that are not in a compatible phase already
nodes = [n for n in nodes
if self.phase(repo, repo[n].rev()) >= phase]
if not nodes:
break # no roots to move anymore
olds = self.phaseroots[phase]
roots = set(ctx.node() for ctx in repo.set(
'roots((%ln::) - (%ln::%ln))', olds, olds, nodes))
if olds != roots:
Pierre-Yves David
phase: attach phase to the transaction instead of the lock...
r22080 self._updateroots(phase, roots, tr)
Patrick Mezard
phases: make advance/retractboundary() atomic...
r16658 # some roots may need to be declared for lower phases
delroots.extend(olds - roots)
# declare deleted root in the target phase
if targetphase != 0:
Pierre-Yves David
phase: add a transaction argument to retractboundary...
r22070 self.retractboundary(repo, tr, targetphase, delroots)
Pierre-Yves David
cache: group obscache and revsfiltercache invalidation in a single function...
r18105 repo.invalidatevolatilesets()
Patrick Mezard
phases: make advance/retractboundary() atomic...
r16658
Pierre-Yves David
phase: add a transaction argument to retractboundary...
r22070 def retractboundary(self, repo, tr, targetphase, nodes):
Patrick Mezard
phases: make advance/retractboundary() atomic...
r16658 # Be careful to preserve shallow-copied values: do not update
# phaseroots values, replace them.
Pierre-Yves David
clfilter: phases logic should be unfiltered...
r18002 repo = repo.unfiltered()
Patrick Mezard
phases: make advance/retractboundary() atomic...
r16658 currentroots = self.phaseroots[targetphase]
newroots = [n for n in nodes
if self.phase(repo, repo[n].rev()) < targetphase]
if newroots:
Patrick Mezard
phase: make if abort on nullid for the good reason...
r16659 if nullid in newroots:
Pierre-Yves David
error: get Abort from 'error' instead of 'util'...
r26587 raise error.Abort(_('cannot change null revision phase'))
Patrick Mezard
phases: make advance/retractboundary() atomic...
r16658 currentroots = currentroots.copy()
currentroots.update(newroots)
Durham Goode
phase: improve retractboundary perf...
r26909
# Only compute new roots for revs above the roots that are being
# retracted.
minnewroot = min(repo[n].rev() for n in newroots)
aboveroots = [n for n in currentroots
if repo[n].rev() >= minnewroot]
updatedroots = repo.set('roots(%ln::)', aboveroots)
finalroots = set(n for n in currentroots if repo[n].rev() <
minnewroot)
finalroots.update(ctx.node() for ctx in updatedroots)
self._updateroots(targetphase, finalroots, tr)
Pierre-Yves David
cache: group obscache and revsfiltercache invalidation in a single function...
r18105 repo.invalidatevolatilesets()
Patrick Mezard
phases: make advance/retractboundary() atomic...
r16658
Idan Kamara
phases: make _filterunknown a member function of phasecache...
r18220 def filterunknown(self, repo):
"""remove unknown nodes from the phase boundary
Nothing is lost as unknown nodes only hold data for their descendants.
"""
filtered = False
nodemap = repo.changelog.nodemap # to filter unknown nodes
for phase, nodes in enumerate(self.phaseroots):
Mads Kiilerich
phases: make order of debug output 'removing unknown node' deterministic
r20550 missing = sorted(node for node in nodes if node not in nodemap)
Idan Kamara
phases: make _filterunknown a member function of phasecache...
r18220 if missing:
for mnode in missing:
repo.ui.debug(
'removing unknown node %s from %i-phase boundary\n'
% (short(mnode), phase))
nodes.symmetric_difference_update(missing)
filtered = True
if filtered:
self.dirty = True
Pierre-Yves David
destroyed: invalidate phraserevs cache in all case (issue3858)...
r18983 # filterunknown is called by repo.destroyed, we may have no changes in
Mads Kiilerich
spelling: random spell checker fixes
r19951 # root but phaserevs contents is certainly invalid (or at least we
# have not proper way to check that). related to issue 3858.
Pierre-Yves David
destroyed: invalidate phraserevs cache in all case (issue3858)...
r18983 #
# The other caller is __init__ that have no _phaserevs initialized
# anyway. If this change we should consider adding a dedicated
Mads Kiilerich
spelling: random spell checker fixes
r19951 # "destroyed" function to phasecache or a proper cache key mechanism
Pierre-Yves David
destroyed: invalidate phraserevs cache in all case (issue3858)...
r18983 # (see branchmap one)
Durham Goode
phases: add invalidate function...
r22893 self.invalidate()
Idan Kamara
phases: make _filterunknown a member function of phasecache...
r18220
Pierre-Yves David
phase: add a transaction argument to advanceboundary...
r22069 def advanceboundary(repo, tr, targetphase, nodes):
Pierre-Yves David
phases: add a moveboundary function to move phases boundaries...
r15454 """Add nodes to a phase changing other nodes phases if necessary.
Martin Geisler
phases: wrap docstrings at 70 characters
r16725 This function move boundary *forward* this means that all nodes
are set in the target phase or kept in a *lower* phase.
Pierre-Yves David
phases: add a moveboundary function to move phases boundaries...
r15454
Pierre-Yves David
phases: add retractboundary function to move boundary backward...
r15482 Simplify boundary to contains phase roots only."""
Patrick Mezard
phases: make advance/retractboundary() atomic...
r16658 phcache = repo._phasecache.copy()
Pierre-Yves David
phase: add a transaction argument to advanceboundary...
r22069 phcache.advanceboundary(repo, tr, targetphase, nodes)
Patrick Mezard
phases: make advance/retractboundary() atomic...
r16658 repo._phasecache.replace(phcache)
Pierre-Yves David
phases: add retractboundary function to move boundary backward...
r15482
Pierre-Yves David
phase: add a transaction argument to retractboundary...
r22070 def retractboundary(repo, tr, targetphase, nodes):
Martin Geisler
phases: wrap docstrings at 70 characters
r16725 """Set nodes back to a phase changing other nodes phases if
necessary.
Pierre-Yves David
phases: add retractboundary function to move boundary backward...
r15482
Martin Geisler
phases: wrap docstrings at 70 characters
r16725 This function move boundary *backward* this means that all nodes
are set in the target phase or kept in a *higher* phase.
Pierre-Yves David
phases: add retractboundary function to move boundary backward...
r15482
Simplify boundary to contains phase roots only."""
Patrick Mezard
phases: make advance/retractboundary() atomic...
r16658 phcache = repo._phasecache.copy()
Pierre-Yves David
phase: add a transaction argument to retractboundary...
r22070 phcache.retractboundary(repo, tr, targetphase, nodes)
Patrick Mezard
phases: make advance/retractboundary() atomic...
r16658 repo._phasecache.replace(phcache)
Pierre-Yves David
phases: add basic pushkey support
r15648
def listphases(repo):
Martin Geisler
phases: fix typos in docstrings
r16724 """List phases root for serialization over pushkey"""
Pierre-Yves David
phases: add basic pushkey support
r15648 keys = {}
Pierre-Yves David
phases: simplify phase exchange and movement over pushkey...
r15892 value = '%i' % draft
Patrick Mezard
phases: introduce phasecache...
r16657 for root in repo._phasecache.phaseroots[draft]:
Pierre-Yves David
phases: simplify phase exchange and movement over pushkey...
r15892 keys[hex(root)] = value
Matt Mackall
publishing: use new helper method
r25624 if repo.publishing():
Martin Geisler
phases: wrap docstrings at 70 characters
r16725 # Add an extra data to let remote know we are a publishing
# repo. Publishing repo can't just pretend they are old repo.
# When pushing to a publishing repo, the client still need to
# push phase boundary
Pierre-Yves David
phases: add basic pushkey support
r15648 #
Martin Geisler
phases: wrap docstrings at 70 characters
r16725 # Push do not only push changeset. It also push phase data.
# New phase data may apply to common changeset which won't be
# push (as they are common). Here is a very simple example:
Pierre-Yves David
phases: add basic pushkey support
r15648 #
# 1) repo A push changeset X as draft to repo B
# 2) repo B make changeset X public
Martin Geisler
phases: wrap docstrings at 70 characters
r16725 # 3) repo B push to repo A. X is not pushed but the data that
# X as now public should
Pierre-Yves David
phases: add basic pushkey support
r15648 #
Martin Geisler
phases: wrap docstrings at 70 characters
r16725 # The server can't handle it on it's own as it has no idea of
# client phase data.
Pierre-Yves David
phases: add basic pushkey support
r15648 keys['publishing'] = 'True'
return keys
def pushphase(repo, nhex, oldphasestr, newphasestr):
timeless@mozdev.org
en-us: serialization
r17535 """List phases root for serialization over pushkey"""
Pierre-Yves David
clfilter: phases logic should be unfiltered...
r18002 repo = repo.unfiltered()
Bryan O'Sullivan
with: use context manager for lock in pushphase
r27861 with repo.lock():
Pierre-Yves David
phases: add basic pushkey support
r15648 currentphase = repo[nhex].phase()
newphase = abs(int(newphasestr)) # let's avoid negative index surprise
oldphase = abs(int(oldphasestr)) # let's avoid negative index surprise
if currentphase == oldphase and newphase < oldphase:
Bryan O'Sullivan
with: use context manager for transaction in pushphase
r27874 with repo.transaction('pushkey-phase') as tr:
Bryan O'Sullivan
with: use context manager for lock in pushphase
r27861 advanceboundary(repo, tr, newphase, [bin(nhex)])
Pierre-Yves David
phases: add basic pushkey support
r15648 return 1
Matt Mackall
phases: don't complain if cset is already public on pushkey (issue3230)
r16051 elif currentphase == newphase:
# raced, but got correct result
return 1
Pierre-Yves David
phases: add basic pushkey support
r15648 else:
return 0
Pierre-Yves David
phases: add a function to compute heads from root
r15649
def analyzeremotephases(repo, subset, roots):
"""Compute phases heads and root in a subset of node from root dict
* subset is heads of the subset
* roots is {<nodeid> => phase} mapping. key and value are string.
Accept unknown element input
"""
Pierre-Yves David
clfilter: phases logic should be unfiltered...
r18002 repo = repo.unfiltered()
Pierre-Yves David
phases: add a function to compute heads from root
r15649 # build list from dictionary
Pierre-Yves David
phases: simplify phase exchange and movement over pushkey...
r15892 draftroots = []
Sune Foldager
phases: use nodemap to check for missing nodes
r15902 nodemap = repo.changelog.nodemap # to filter unknown nodes
Pierre-Yves David
phases: add a function to compute heads from root
r15649 for nhex, phase in roots.iteritems():
if nhex == 'publishing': # ignore data related to publish option
continue
node = bin(nhex)
phase = int(phase)
Gregory Szorc
phases: use constants for phase values...
r28174 if phase == public:
Pierre-Yves David
phases: simplify phase exchange and movement over pushkey...
r15892 if node != nullid:
Pierre-Yves David
phase: fix warning text from invalid remote phase...
r15953 repo.ui.warn(_('ignoring inconsistent public root'
' from remote: %s\n') % nhex)
Gregory Szorc
phases: use constants for phase values...
r28174 elif phase == draft:
Sune Foldager
phases: use nodemap to check for missing nodes
r15902 if node in nodemap:
Pierre-Yves David
phases: simplify phase exchange and movement over pushkey...
r15892 draftroots.append(node)
else:
Pierre-Yves David
phase: fix warning text from invalid remote phase...
r15953 repo.ui.warn(_('ignoring unexpected root from remote: %i %s\n')
% (phase, nhex))
Pierre-Yves David
phases: add a function to compute heads from root
r15649 # compute heads
Pierre-Yves David
phase: extracts heads computation logics from analyzeremotephases
r15954 publicheads = newheads(repo, subset, draftroots)
Pierre-Yves David
phases: simplify phase exchange and movement over pushkey...
r15892 return publicheads, draftroots
Pierre-Yves David
phases: add a function to compute heads from root
r15649
Pierre-Yves David
phase: extracts heads computation logics from analyzeremotephases
r15954 def newheads(repo, heads, roots):
"""compute new head of a subset minus another
* `heads`: define the first subset
Mads Kiilerich
fix wording and not-completely-trivial spelling errors and bad docstrings
r17425 * `roots`: define the second we subtract from the first"""
Pierre-Yves David
clfilter: phases logic should be unfiltered...
r18002 repo = repo.unfiltered()
Pierre-Yves David
phase: extracts heads computation logics from analyzeremotephases
r15954 revset = repo.set('heads((%ln + parents(%ln)) - (%ln::%ln))',
heads, roots, roots, heads)
return [c.node() for c in revset]
Pierre-Yves David
phases: allow phase name in phases.new-commit settings...
r16030
def newcommitphase(ui):
"""helper to get the target phase of new commit
Handle all possible values for the phases.new-commit options.
"""
v = ui.config('phases', 'new-commit', draft)
try:
return phasenames.index(v)
except ValueError:
try:
return int(v)
except ValueError:
msg = _("phases.new-commit: not a valid phase name ('%s')")
raise error.ConfigError(msg % v)
Pierre-Yves David
clfilter: introduce a `hassecret` function...
r17671 def hassecret(repo):
"""utility function that check if a repo have any secret changeset."""
return bool(repo._phasecache.phaseroots[2])