1. TortoiseHg
  2. TortoiseHg
  3. thg

Commits

Yuya Nishihara  committed 2f256ee

quickop: extract helper method to run dirstate operation

  • Participants
  • Parent commits 9be881c
  • Branches default

Comments (0)

Files changed (1)

File tortoisehg/hgqt/quickop.py

View file
  • Ignore whitespace
     def repo(self):
         return self._repoagent.rawRepo()
 
+    def _runCommand(self, files, lfiles, opts):
+        cmdlines = []
+        if files:
+            cmdlines.append(hglib.buildcmdargs(self.command, *files, **opts))
+        if lfiles:
+            assert self.command == 'add'
+            lopts = opts.copy()
+            lopts['large'] = True
+            cmdlines.append(hglib.buildcmdargs(self.command, *lfiles, **lopts))
+        self.files = files + lfiles
+        self.cmd.run(*cmdlines)
+
     def commandStarted(self):
         self.bb.button(QDialogButtonBox.Ok).setEnabled(False)
 
                 self.addWithPrompt(files)
                 return
         if files:
-            cmdline = hglib.buildcmdargs(self.command, *files, **cmdopts)
-            self.files = files
-            self.cmd.run(cmdline)
+            self._runCommand(files, [], cmdopts)
         else:
             self.reject()
 
             QDialog.reject(self)
 
     def addLfiles(self):
-        cmdline = ['add', '--large']
         files = self.stwidget.getChecked()
         if not files:
             qtlib.WarningMsgBox(_('No files selected'),
                                 _('No operation to perform'),
                                 parent=self)
             return
-        cmdline.extend(files)
-        self.files = files
-        self.cmd.run(cmdline)
+        self._runCommand([], files, {})
 
     def addWithPrompt(self, files):
         result = lfprompt.promptForLfiles(self, self.repo.ui, self.repo, files)
         if not result:
             return
         files, lfiles = result
-        cmdlines = []
-        if files:
-            cmdlines.append(['add'] + files)
-        if lfiles:
-            cmdlines.append(['add', '--large'] + lfiles)
-        self.files = files + lfiles
-        self.cmd.run(*cmdlines)
+        self._runCommand(files, lfiles, {})
 
 class HeadlessQuickop(QObject):
     def __init__(self, repoagent, cmdline):