~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/versionedfile.py

  • Committer: Robert Collins
  • Date: 2006-04-24 09:11:32 UTC
  • mto: (1686.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 1687.
  • Revision ID: robertc@robertcollins.net-20060424091132-5252fbb8a99e4c91
Fix versioned file joins with empty targets.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
# along with this program; if not, write to the Free Software
18
18
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
19
 
20
 
# Remaing to do is to figure out if get_graph should return a simple
21
 
# map, or a graph object of some kind.
22
 
 
23
 
 
24
20
"""Versioned text file storage api."""
25
21
 
26
22
 
286
282
        """
287
283
        raise NotImplementedError(self.get_ancestry_with_ghosts)
288
284
        
289
 
    def get_graph(self):
290
 
        """Return a graph for the entire versioned file.
 
285
    def get_graph(self, version_ids=None):
 
286
        """Return a graph from the versioned file. 
291
287
        
292
288
        Ghosts are not listed or referenced in the graph.
 
289
        :param version_ids: Versions to select.
 
290
                            None means retreive all versions.
293
291
        """
294
292
        result = {}
295
 
        for version in self.versions():
296
 
            result[version] = self.get_parents(version)
 
293
        if version_ids is None:
 
294
            for version in self.versions():
 
295
                result[version] = self.get_parents(version)
 
296
        else:
 
297
            pending = set(version_ids)
 
298
            while pending:
 
299
                version = pending.pop()
 
300
                if version in result:
 
301
                    continue
 
302
                parents = self.get_parents(version)
 
303
                for parent in parents:
 
304
                    if parent in result:
 
305
                        continue
 
306
                    pending.add(parent)
 
307
                result[version] = parents
297
308
        return result
298
309
 
299
310
    def get_graph_with_ghosts(self):
550
561
            # Make a new target-format versioned file. 
551
562
            temp_source = self.target.create_empty("temp", MemoryTransport())
552
563
            target = temp_source
553
 
        graph = self.source.get_graph()
 
564
        if version_ids is not None:
 
565
            new_version_ids = []
 
566
            for version in version_ids:
 
567
                if not self.source.has_version(version):
 
568
                    if not ignore_missing:
 
569
                        raise errors.RevisionNotPresent(version, str(self.source))
 
570
                else:
 
571
                    new_version_ids.append(version)
 
572
            version_ids = new_version_ids
 
573
        graph = self.source.get_graph(version_ids)
554
574
        order = topo_sort(graph.items())
555
575
        pb = ui.ui_factory.nested_progress_bar()
556
576
        parent_texts = {}