##// END OF EJS Templates
phases: add a moveboundary function to move phases boundaries...
Pierre-Yves David -
r15454:5a7dde5a default
parent child Browse files
Show More
@@ -36,6 +36,7 class localrepository(repo.repository):
36 self.wopener = scmutil.opener(self.root)
36 self.wopener = scmutil.opener(self.root)
37 self.baseui = baseui
37 self.baseui = baseui
38 self.ui = baseui.copy()
38 self.ui = baseui.copy()
39 self._dirtyphases = False
39
40
40 try:
41 try:
41 self.ui.readconfig(self.join("hgrc"), self.root)
42 self.ui.readconfig(self.join("hgrc"), self.root)
@@ -172,6 +173,7 class localrepository(repo.repository):
172
173
173 @filecache('phaseroots')
174 @filecache('phaseroots')
174 def _phaseroots(self):
175 def _phaseroots(self):
176 self._dirtyphases = False
175 return phases.readroots(self)
177 return phases.readroots(self)
176
178
177 @propertycache
179 @propertycache
@@ -910,6 +912,8 class localrepository(repo.repository):
910
912
911 def unlock():
913 def unlock():
912 self.store.write()
914 self.store.write()
915 if self._dirtyphases:
916 phases.writeroots(self)
913 for k, ce in self._filecache.items():
917 for k, ce in self._filecache.items():
914 if k == 'dirstate':
918 if k == 'dirstate':
915 continue
919 continue
@@ -37,5 +37,30 def writeroots(repo):
37 for phase, roots in enumerate(repo._phaseroots):
37 for phase, roots in enumerate(repo._phaseroots):
38 for h in roots:
38 for h in roots:
39 f.write('%i %s\n' % (phase, hex(h)))
39 f.write('%i %s\n' % (phase, hex(h)))
40 repo._dirtyphases = False
40 finally:
41 finally:
41 f.close()
42 f.close()
43
44 def moveboundary(repo, target_phase, nodes):
45 """Add nodes to a phase changing other nodes phases if necessary.
46
47 Simplify boundary to contains phase roots only."""
48
49 # move roots of lower states
50 for phase in xrange(target_phase + 1, len(allphases)):
51 # filter nodes that are not in a compatible phase already
52 # XXX rev phase cache might have been invalidated by a previous loop
53 # XXX we need to be smarter here
54 nodes = [n for n in nodes if repo[n].phase() >= phase]
55 if not nodes:
56 break # no roots to move anymore
57 roots = repo._phaseroots[phase]
58 olds = roots.copy()
59 ctxs = list(repo.set('roots((%ln::) - (%ln::%ln))', olds, olds, nodes))
60 roots.clear()
61 roots.update(ctx.node() for ctx in ctxs)
62 if olds != roots:
63 # invalidate cache (we probably could be smarter here
64 if '_phaserev' in vars(repo):
65 del repo._phaserev
66 repo._dirtyphases = True
General Comments 0
You need to be logged in to leave comments. Login now