Commits

Anonymous committed eaa6503

commit: refactor code that reads and displays the current options

The code that reads the current repository options and displays it has been
refactored into its own functions. This is necessary to be able to reuse this
code from the commit panel of the merge dialog (which will be done on a
separate, future patch).

Comments (0)

Files changed (1)

tortoisehg/hgqt/commit.py

 else:
     _hasbugtraq = False
 
+def readrepoopts(repo):
+    opts = {}
+    opts['ciexclude'] = repo.ui.config('tortoisehg', 'ciexclude', '')
+    opts['pushafter'] = repo.ui.config('tortoisehg', 'cipushafter', '')
+    opts['autoinc'] = repo.ui.config('tortoisehg', 'autoinc', '')
+    opts['recurseinsubrepos'] = repo.ui.config('tortoisehg', 'recurseinsubrepos', None)
+    opts['bugtraqplugin'] = repo.ui.config('tortoisehg', 'issue.bugtraqplugin', None)
+    opts['bugtraqparameters'] = repo.ui.config('tortoisehg', 'issue.bugtraqparameters', None)
+    if opts['bugtraqparameters']:
+        opts['bugtraqparameters'] = os.path.expandvars(opts['bugtraqparameters'])
+    opts['bugtraqtrigger'] = repo.ui.config('tortoisehg', 'issue.bugtraqtrigger', None)
+
+    return opts
+
+def commitopts2str(opts, mode='commit'):
+    optslist = []
+    for opt, value in opts.iteritems():
+        if opt in ['user', 'date', 'pushafter', 'autoinc',
+                   'recurseinsubrepos']:
+            if mode == 'merge' and opt == 'autoinc':
+                # autoinc does not apply to merge commits
+                continue
+            if value is True:
+                optslist.append('--' + opt)
+            elif value:
+                optslist.append('--%s=%s' % (opt, value))
+    return ' '.join(optslist)
+
 # Technical Debt for CommitWidget
 #  disable commit button while no message is entered or no files are selected
 #  qtlib decode failure dialog (ask for retry locale, suggest HGENCODING)
         self.currentAction = None
         self.currentProgress = None
 
-        opts['ciexclude'] = repo.ui.config('tortoisehg', 'ciexclude', '')
-        opts['pushafter'] = repo.ui.config('tortoisehg', 'cipushafter', '')
-        opts['autoinc'] = repo.ui.config('tortoisehg', 'autoinc', '')
-        opts['recurseinsubrepos'] = repo.ui.config('tortoisehg', 'recurseinsubrepos', None)
-        opts['bugtraqplugin'] = repo.ui.config('tortoisehg', 'issue.bugtraqplugin', None)
-        opts['bugtraqparameters'] = repo.ui.config('tortoisehg', 'issue.bugtraqparameters', None)
-        if opts['bugtraqparameters']:
-            opts['bugtraqparameters'] = os.path.expandvars(opts['bugtraqparameters'])
-        opts['bugtraqtrigger'] = repo.ui.config('tortoisehg', 'issue.bugtraqtrigger', None)
-        self.opts = opts # user, date
+        self.opts = opts = readrepoopts(repo) # user, date
 
         self.stwidget = status.StatusWidget(repo, pats, opts, self)
         self.stwidget.showMessage.connect(self.showMessage)
         self.branchbutton.setText(title)
 
         # Update options label, showing only whitelisted options.
-        opts = []
-        for opt, value in self.opts.iteritems():
-            if opt in ['user', 'date', 'pushafter', 'autoinc',
-                       'recurseinsubrepos']:
-                if value is True:
-                    opts.append('--' + opt)
-                elif value:
-                    opts.append('--%s=%s' % (opt, value))
-
+        opts = commitopts2str(self.opts)
         self.optionslabelfmt = _('<b>Selected Options:</b> %s')
         self.optionslabel.setText(self.optionslabelfmt
-                                  % hglib.tounicode(' '.join(opts)))
+                                  % hglib.tounicode(opts))
         self.optionslabel.setVisible(bool(opts))
 
         # Update parent csinfo widget
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.