Просмотр исходного кода

Fix reset handling in fastexport module.

Jelmer Vernooij 11 лет назад
Родитель
Сommit
650843d9bb
3 измененных файлов с 15 добавлено и 1 удалено
  1. 3 0
      NEWS
  2. 1 1
      dulwich/fastexport.py
  3. 11 0
      dulwich/tests/test_fastexport.py

+ 3 - 0
NEWS

@@ -20,6 +20,9 @@
    to Repo.__getitem__.
    (Jonas Haag)
 
+ * Fix handling of `reset` command in dulwich.fastexport.
+   (Jelmer Vernooij)
+
  API CHANGES
 
   * Drop support for Python 2.6. (Jelmer Vernooij)

+ 1 - 1
dulwich/fastexport.py

@@ -204,7 +204,7 @@ class GitImportProcessor(processor.ImportProcessor):
     def reset_handler(self, cmd):
         """Process a ResetCommand."""
         self._reset_base(cmd.from_)
-        self.rep.refs[cmd.from_] = cmd.id
+        self.repo.refs[cmd.ref] = cmd.from_
 
     def tag_handler(self, cmd):
         """Process a TagCommand."""

+ 11 - 0
dulwich/tests/test_fastexport.py

@@ -20,6 +20,7 @@
 from cStringIO import StringIO
 import stat
 
+
 from dulwich.object_store import (
     MemoryObjectStore,
     )
@@ -35,6 +36,9 @@ from dulwich.tests import (
     SkipTest,
     TestCase,
     )
+from dulwich.tests.utils import (
+    build_commit_graph,
+    )
 
 
 class GitFastExporterTests(TestCase):
@@ -96,6 +100,13 @@ class GitImportProcessorTests(TestCase):
             raise SkipTest("python-fastimport not available")
         self.processor = GitImportProcessor(self.repo)
 
+    def test_reset_handler(self):
+        from fastimport import commands
+        [c1] = build_commit_graph(self.repo.object_store, [[1]])
+        cmd = commands.ResetCommand("refs/heads/foo", c1.id)
+        self.processor.reset_handler(cmd)
+        self.assertEquals(c1.id, self.repo.get_refs()["refs/heads/foo"])
+
     def test_commit_handler(self):
         from fastimport import commands
         cmd = commands.CommitCommand("refs/heads/foo", "mrkr",