Example #1
0
 def test_full_tree(self):
     c = self.make_commit(commit_time=30)
     t = Tree()
     t.add(b'data-x', 0o644, Blob().id)
     c.tree = t
     c1 = Commit()
     c1.set_raw_string(c.as_raw_string())
     self.assertEqual(t.id, c1.tree)
     self.assertEqual(c.as_raw_string(), c1.as_raw_string())
Example #2
0
 def test_full_tree(self):
     c = self.make_commit(commit_time=30)
     t = Tree()
     t.add(b'data-x', 0o644, Blob().id)
     c.tree = t
     c1 = Commit()
     c1.set_raw_string(c.as_raw_string())
     self.assertEqual(t.id, c1.tree)
     self.assertEqual(c.as_raw_string(), c1.as_raw_string())
Example #3
0
 def commit(self, message):
     self._validate_unicode_text(message, 'commit message')
     c = Commit()
     c.parents = [
         self.repository.lookup_bzr_revision_id(revid)[0]
         for revid in self.parents
     ]
     c.tree = commit_tree(self.store, self._iterblobs())
     encoding = self._revprops.pop(u'git-explicit-encoding', 'utf-8')
     c.encoding = encoding.encode('ascii')
     c.committer = fix_person_identifier(self._committer.encode(encoding))
     try:
         author = self._revprops.pop('author')
     except KeyError:
         try:
             authors = self._revprops.pop('authors').splitlines()
         except KeyError:
             author = self._committer
         else:
             if len(authors) > 1:
                 raise Exception("Unable to convert multiple authors")
             elif len(authors) == 0:
                 author = self._committer
             else:
                 author = authors[0]
     c.author = fix_person_identifier(author.encode(encoding))
     bugstext = self._revprops.pop('bugs', None)
     if bugstext is not None:
         message += "\n"
         for url, status in bugtracker.decode_bug_urls(bugstext):
             if status == bugtracker.FIXED:
                 message += "Fixes: %s\n" % url
             elif status == bugtracker.RELATED:
                 message += "Bug: %s\n" % url
             else:
                 raise bugtracker.InvalidBugStatus(status)
     if self._revprops:
         raise NotImplementedError(self._revprops)
     c.commit_time = int(self._timestamp)
     c.author_time = int(self._timestamp)
     c.commit_timezone = self._timezone
     c.author_timezone = self._timezone
     c.message = message.encode(encoding)
     if (self._config_stack.get('create_signatures') ==
             _mod_config.SIGN_ALWAYS):
         strategy = gpg.GPGStrategy(self._config_stack)
         c.gpgsig = strategy.sign(c.as_raw_string(), gpg.MODE_DETACH)
     self.store.add_object(c)
     self.repository.commit_write_group()
     self._new_revision_id = self._mapping.revision_id_foreign_to_bzr(c.id)
     return self._new_revision_id