コード例 #1
0
 def record_iter_changes(self, workingtree, basis_revid, iter_changes):
     seen_root = False
     for (file_id, path, changed_content, versioned, parent, name, kind,
          executable) in iter_changes:
         if kind[1] in ("directory", ):
             if kind[0] in ("file", "symlink"):
                 self.record_delete(path[0])
             if path[1] == u"":
                 seen_root = True
             continue
         if path[1] is None:
             self.record_delete(path[0])
             continue
         utf8_path = path[1].encode("utf-8")
         fparents = tuple([
             m.get(utf8_path, mercurial.node.nullid)
             for m in self._parent_manifests
         ])
         flog = self._hgrepo.file(utf8_path)
         # FIXME: Support copies
         if (changed_content or executable[0] != executable[1]
                 or kind[0] != kind[1]):
             self._changelist.append(utf8_path)
         if changed_content:
             if kind[1] == "file":
                 text = workingtree.get_file_text(path[1])
             elif kind[1] == "symlink":
                 text = workingtree.get_symlink_target(
                     path[1]).encode("utf-8")
             else:
                 raise AssertionError
             meta = {}  # for now
             node = flog.add(text, meta, self._transaction, self._linkrev,
                             fparents[0], fparents[1])
             self._manifest[utf8_path] = node
         else:
             self._manifest[utf8_path] = fparents[0]
         self._changed.append(utf8_path)
         if executable[1]:
             self._manifest.setflag(utf8_path, 'x')
         if kind[1] == "symlink":
             self._manifest.setflag(utf8_path, 'l')
         f, st = workingtree.get_file_with_stat(path[1])
         yield file_id, path[1], (osutils.sha_file(f), st)
     if not seen_root and len(self.parents) == 0:
         raise RootMissing()
     self.new_inventory = None
コード例 #2
0
ファイル: memorytree.py プロジェクト: hroncok/breezy
 def get_file_sha1(self, path, stat_value=None):
     """See Tree.get_file_sha1()."""
     stream = self._file_transport.get(path)
     return osutils.sha_file(stream)