Patchwork [12,of,18] configitems: register the 'automv.similarity' config

login
register
mail settings
Submitter Pierre-Yves David
Date July 2, 2017, 2:57 a.m.
Message ID <b7172c800c4179e71958.1498964260@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/21902/
State Accepted
Headers show

Comments

Pierre-Yves David - July 2, 2017, 2:57 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1498786044 -7200
#      Fri Jun 30 03:27:24 2017 +0200
# Node ID b7172c800c4179e7195870b232bc67a0690abbbe
# Parent  6d678ab1b10d0fddc73003d21aa3c7ec43194e2e
# EXP-Topic config.register.automv
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r b7172c800c41
configitems: register the 'automv.similarity' config

Default value has been ported.

Patch

diff --git a/hgext/automv.py b/hgext/automv.py
--- a/hgext/automv.py
+++ b/hgext/automv.py
@@ -32,10 +32,18 @@  from mercurial import (
     copies,
     error,
     extensions,
+    registrar,
     scmutil,
     similar
 )
 
+configtable = {}
+configitem = registrar.configitem(configtable)
+
+configitem('automv', 'similarity',
+    default=95,
+)
+
 def extsetup(ui):
     entry = extensions.wrapcommand(
         commands.table, 'commit', mvcheck)
@@ -48,7 +56,7 @@  def mvcheck(orig, ui, repo, *pats, **opt
     renames = None
     disabled = opts.pop('no_automv', False)
     if not disabled:
-        threshold = ui.configint('automv', 'similarity', 95)
+        threshold = ui.configint('automv', 'similarity')
         if not 0 <= threshold <= 100:
             raise error.Abort(_('automv.similarity must be between 0 and 100'))
         if threshold > 0: