~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commit.py

  • Committer: Martin Pool
  • Date: 2005-09-13 05:11:27 UTC
  • Revision ID: mbp@sourcefrog.net-20050913051127-47c500210200a219
- branch now tracks ancestry - all merged revisions

 - new Branch.get_ancestry() returns them as a list

 - basic test for this

 - commit appends to ancestry (only for non-merge commits)
 
 - clean up imports

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
                            rand_bytes, compact_date, user_email,
42
42
                            kind_marker, is_inside_any, quotefn,
43
43
                            sha_string, sha_file, isdir, isfile)
44
 
from bzrlib.branch import gen_file_id, INVENTORY_FILEID
 
44
from bzrlib.branch import gen_file_id, INVENTORY_FILEID, ANCESTRY_FILEID
45
45
from bzrlib.errors import BzrError, PointlessCommit
46
46
from bzrlib.revision import Revision, RevisionReference
47
47
from bzrlib.trace import mutter, note
191
191
            if self.rev_id is None:
192
192
                self.rev_id = _gen_revision_id(self.branch, time.time())
193
193
 
194
 
            # todo: update hashcache
 
194
            # TODO: update hashcache
195
195
            self.delta = compare_trees(self.basis_tree, self.work_tree,
196
196
                                       specific_files=self.specific_files)
197
197
 
209
209
 
210
210
            self.branch._write_inventory(self.work_inv)
211
211
            self._record_inventory()
 
212
            self._record_ancestry()
212
213
 
213
214
            self._make_revision()
214
215
            note('committted r%d {%s}', (self.branch.revno() + 1),
230
231
                                         inv_lines, self.parents)
231
232
 
232
233
 
 
234
    def _record_ancestry(self):
 
235
        """Append merged revision ancestry to the ancestry file."""
 
236
        if len(self.parents) > 1:
 
237
            raise NotImplementedError("sorry, can't commit merges yet")
 
238
        w = self.branch.weave_store.get_weave_or_empty(ANCESTRY_FILEID)
 
239
        if self.parents:
 
240
            lines = w.get(w.lookup(self.parents[0]))
 
241
        else:
 
242
            lines = []
 
243
        lines.append(self.rev_id + '\n')
 
244
        parent_idxs = map(w.lookup, self.parents)
 
245
        w.add(self.rev_id, parent_idxs, lines)
 
246
        self.branch.weave_store.put_weave(ANCESTRY_FILEID, w)
 
247
 
 
248
 
233
249
    def _gather_parents(self):
234
250
        pending_merges = self.branch.pending_merges()
235
251
        if pending_merges: