~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commit.py

  • Committer: Martin Pool
  • Date: 2005-09-16 05:16:21 UTC
  • Revision ID: mbp@sourcefrog.net-20050916051621-cce671c80eb57be2
- fix recording of merged ancestry lines

Show diffs side-by-side

added added

removed removed

Lines of Context:
225
225
 
226
226
 
227
227
    def _record_ancestry(self):
228
 
        """Append merged revision ancestry to the ancestry file."""
 
228
        """Append merged revision ancestry to the ancestry file.
 
229
 
 
230
        This should be the merged ancestry of all parents, plus the
 
231
        new revision id."""
229
232
        w = self.weave_store.get_weave_or_empty(ANCESTRY_FILEID)
230
 
        if self.parents:
231
 
            lines = w.get(self.parents[0])
232
 
        else:
233
 
            lines = []
234
 
        lines.append(self.rev_id + '\n')
 
233
        lines = self._merge_ancestry_lines(w)
235
234
        w.add(self.rev_id, self.parents, lines)
236
235
        self.weave_store.put_weave(ANCESTRY_FILEID, w)
237
236
 
238
237
 
 
238
    def _merge_ancestry_lines(self, ancestry_weave):
 
239
        """Return merged ancestry lines.
 
240
 
 
241
        The lines are revision-ids followed by newlines."""
 
242
        seen = set()
 
243
        ancs = []
 
244
        for parent_id in self.parents:
 
245
            for line in ancestry_weave.get(parent_id):
 
246
                assert line[-1] == '\n'
 
247
                if line not in seen:
 
248
                    ancs.append(line)
 
249
                    seen.add(line)
 
250
        r = self.rev_id + '\n'
 
251
        assert r not in ancs
 
252
        ancs.append(r)
 
253
        mutter('merged ancestry of {%s}:\n%s', self.rev_id, ''.join(ancs))
 
254
        return ancs
 
255
 
 
256
 
239
257
    def _gather_parents(self):
240
258
        pending_merges = self.branch.pending_merges()
241
259
        self.parents = []
244
262
            self.parents.append(precursor_id)
245
263
        self.parents += pending_merges
246
264
        for parent_id in self.parents:
 
265
            mutter('commit parent revision {%s}', parent_id)
247
266
            if not self.branch.has_revision(parent_id):
248
267
                warning("can't commit a merge from an absent parent")
249
268
                raise HistoryMissing(self.branch, 'revision', parent_id)