phases: move pure phase computation in a function
authorLaurent Charignon <lcharignon@fb.com>
Mon, 30 Mar 2015 12:48:15 -0700
changeset 24519 de3acfabaddc
parent 24518 dd5e56f08d13
child 24520 34e8bfc21f94
phases: move pure phase computation in a function
mercurial/phases.py
--- a/mercurial/phases.py	Tue Mar 24 14:24:55 2015 -0700
+++ b/mercurial/phases.py	Mon Mar 30 12:48:15 2015 -0700
@@ -179,22 +179,25 @@
             nativeroots.append(map(repo.changelog.rev, self.phaseroots[phase]))
         return repo.changelog.computephases(nativeroots)
 
+    def computephaserevspure(self, repo):
+        repo = repo.unfiltered()
+        revs = [public] * len(repo.changelog)
+        self._phaserevs = revs
+        self._populatephaseroots(repo)
+        for phase in trackedphases:
+            roots = map(repo.changelog.rev, self.phaseroots[phase])
+            if roots:
+                for rev in roots:
+                    revs[rev] = phase
+                for rev in repo.changelog.descendants(roots):
+                    revs[rev] = phase
+
     def getphaserevs(self, repo):
         if self._phaserevs is None:
             try:
                 self._phaserevs = self.getphaserevsnative(repo)
             except AttributeError:
-                repo = repo.unfiltered()
-                revs = [public] * len(repo.changelog)
-                self._phaserevs = revs
-                self._populatephaseroots(repo)
-                for phase in trackedphases:
-                    roots = map(repo.changelog.rev, self.phaseroots[phase])
-                    if roots:
-                        for rev in roots:
-                            revs[rev] = phase
-                        for rev in repo.changelog.descendants(roots):
-                            revs[rev] = phase
+                self.computephaserevspure(repo)
         return self._phaserevs
 
     def invalidate(self):