Skip to content

Commit 2a45173

Browse files
committed
Fix revert/reset
1 parent ba31ca7 commit 2a45173

File tree

2 files changed

+27
-12
lines changed

2 files changed

+27
-12
lines changed

qgitc/gitutils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,8 @@ def generatePatch(sha1, filePath, repoDir=None):
426426
return True
427427

428428
@staticmethod
429-
def revertCommit(branch, sha1):
430-
branchDir = Git.branchDir(branch)
429+
def revertCommit(branch, sha1, repoDir=None):
430+
branchDir = Git.branchDir(branch, repoDir)
431431

432432
args = ["revert", "--no-edit", sha1]
433433
process = GitProcess(branchDir, args)

qgitc/logview.py

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,10 @@ def showContextMenu(self, pos):
825825
enabled = not not branchDir
826826

827827
self.acRevert.setEnabled(enabled)
828+
829+
# to avoid bad reset on each repo
830+
if enabled and qApp.settings().isCompositeMode():
831+
enabled = False
828832
self.resetMenu.setEnabled(enabled)
829833

830834
hasMark = self.marker.hasMark()
@@ -980,16 +984,27 @@ def __onRevertCommit(self):
980984
if not commit:
981985
return
982986

983-
ret, error = Git.revertCommit(self.curBranch, commit.sha1)
984-
# ret == 1 with no error can happened but still reverted
985-
if ret != 0 and error:
986-
QMessageBox.critical(
987-
self, self.window().windowTitle(),
988-
error)
989-
else:
990-
# FIXME: fetch the new one only?
991-
self.clear()
992-
self.showLogs(self.curBranch, self.args)
987+
def _doRevert(sha1, repoDir):
988+
ret, error = Git.revertCommit(self.curBranch, sha1, repoDir)
989+
# ret == 1 with no error can happened but still reverted
990+
if ret != 0 and error:
991+
QMessageBox.critical(
992+
self, self.window().windowTitle(),
993+
error)
994+
return False
995+
return True
996+
997+
repoDir = commitRepoDir(commit)
998+
if not _doRevert(commit.sha1, repoDir):
999+
return
1000+
1001+
for subCommit in commit.subCommits:
1002+
repoDir = commitRepoDir(subCommit)
1003+
_doRevert(subCommit.sha1, repoDir)
1004+
1005+
# FIXME: fetch the new one only?
1006+
self.clear()
1007+
self.showLogs(self.curBranch, self.args)
9931008

9941009
def __resetToCurCommit(self, method):
9951010
if self.curIdx == -1:

0 commit comments

Comments
 (0)