Bläddra i källkod

Remove redundant "rebase" from Rebaser method names

- Renamed start_rebase() to start()
- Renamed continue_rebase() to continue_()
- Renamed abort_rebase() to abort()

Since these are methods on the Rebaser class, the "rebase" suffix
is redundant. This makes the API cleaner and more idiomatic:
  rebaser.start() instead of rebaser.start_rebase()
  rebaser.continue_() instead of rebaser.continue_rebase()
  rebaser.abort() instead of rebaser.abort_rebase()

Note: continue_ has a trailing underscore to avoid conflict with
the Python keyword "continue".
Jelmer Vernooij 1 månad sedan
förälder
incheckning
441f1f07d6
3 ändrade filer med 16 tillägg och 16 borttagningar
  1. 4 4
      dulwich/porcelain.py
  2. 6 6
      dulwich/rebase.py
  3. 6 6
      tests/test_rebase.py

+ 4 - 4
dulwich/porcelain.py

@@ -3045,14 +3045,14 @@ def rebase(
 
         if abort:
             try:
-                rebaser.abort_rebase()
+                rebaser.abort()
                 return []
             except RebaseError as e:
                 raise Error(str(e))
 
         if continue_rebase:
             try:
-                result = rebaser.continue_rebase()
+                result = rebaser.continue_()
                 if result is None:
                     # Rebase complete
                     return []
@@ -3074,10 +3074,10 @@ def rebase(
 
         try:
             # Start rebase
-            rebaser.start_rebase(upstream, onto, branch)
+            rebaser.start(upstream, onto, branch)
 
             # Continue rebase automatically
-            result = rebaser.continue_rebase()
+            result = rebaser.continue_()
             if result is not None:
                 # Conflicts
                 raise RebaseConflict(result[1])

+ 6 - 6
dulwich/rebase.py

@@ -370,7 +370,7 @@ class Rebaser:
 
         return new_commit.id, []
 
-    def start_rebase(
+    def start(
         self,
         upstream: bytes,
         onto: Optional[bytes] = None,
@@ -421,7 +421,7 @@ class Rebaser:
 
         return commits
 
-    def continue_rebase(self) -> Optional[tuple[bytes, list[bytes]]]:
+    def continue_(self) -> Optional[tuple[bytes, list[bytes]]]:
         """Continue an in-progress rebase.
 
         Returns:
@@ -449,7 +449,7 @@ class Rebaser:
 
             # Continue with next commit if any
             if self._todo:
-                return self.continue_rebase()
+                return self.continue_()
             else:
                 return self._finish_rebase()
         else:
@@ -461,7 +461,7 @@ class Rebaser:
         """Check if a rebase is currently in progress."""
         return self._state_manager.exists()
 
-    def abort_rebase(self) -> None:
+    def abort(self) -> None:
         """Abort an in-progress rebase and restore original state."""
         if not self.is_in_progress():
             raise RebaseError("No rebase in progress")
@@ -560,10 +560,10 @@ def rebase(
     rebaser = Rebaser(repo)
 
     # Start rebase
-    rebaser.start_rebase(upstream, onto, branch)
+    rebaser.start(upstream, onto, branch)
 
     # Continue rebase
-    result = rebaser.continue_rebase()
+    result = rebaser.continue_()
     if result is not None:
         # Conflicts
         raise RebaseConflict(result[1])

+ 6 - 6
tests/test_rebase.py

@@ -130,7 +130,7 @@ class RebaserTestCase(TestCase):
 
         # Perform rebase
         rebaser = Rebaser(self.repo)
-        commits = rebaser.start_rebase(
+        commits = rebaser.start(
             b"refs/heads/master", branch=b"refs/heads/feature"
         )
 
@@ -138,7 +138,7 @@ class RebaserTestCase(TestCase):
         self.assertEqual(commits[0].id, feature_commit.id)
 
         # Continue rebase
-        result = rebaser.continue_rebase()
+        result = rebaser.continue_()
         self.assertIsNone(result)  # Rebase complete
 
         # Check that feature branch was updated
@@ -235,10 +235,10 @@ class RebaserTestCase(TestCase):
 
         # Start rebase
         rebaser = Rebaser(self.repo)
-        rebaser.start_rebase(b"refs/heads/master")
+        rebaser.start(b"refs/heads/master")
 
         # Abort rebase
-        rebaser.abort_rebase()
+        rebaser.abort()
 
         # Check that HEAD is restored
         self.assertEqual(self.repo.refs.read_ref(b"HEAD"), b"ref: refs/heads/feature")
@@ -340,7 +340,7 @@ class RebaserTestCase(TestCase):
 
         # Rebase B and C onto initial commit (skipping A)
         rebaser = Rebaser(self.repo)
-        commits = rebaser.start_rebase(
+        commits = rebaser.start(
             upstream=commit_a.id,
             onto=self.initial_commit.id,
             branch=b"refs/heads/topic",
@@ -352,7 +352,7 @@ class RebaserTestCase(TestCase):
         self.assertEqual(commits[1].id, commit_c.id)
 
         # Continue rebase
-        result = rebaser.continue_rebase()
+        result = rebaser.continue_()
         self.assertIsNone(result)
 
         # Check result