Changeset 4deed4173d6f…
Parent 4840023dafe9…
by
Changes to one file · Browse files at 4deed4173d6f Showing diff from parent 4840023dafe9 Diff from another changeset...
@@ -16,6 +16,9 @@ from mercurial import demandimport, revset
from mercurial import dispatch as hgdispatch
+from tortoisehg.hgqt import qtlib
+from tortoisehg.util import wconfig
+
demandimport.disable()
try:
# hg >= 1.9
@@ -719,3 +722,24 @@ else:
# hg <= 1.8
return hgdispatch._dispatch(ui, args)
+
+def setConfigValue(rcfilepath, cfgpath, value):
+ '''
+ rcpfilepath - absolute path to a configuration file
+ cfpath - full path of a configurable, ex 'web.name'
+ value - string value or None. if None, the configurable is removed
+ '''
+ fn, cfg = qtlib.loadIniFile([rcfilepath])
+ if not hasattr(cfg, 'write'):
+ return False
+ if fn is None:
+ return False
+ cfgpath = cfgpath.split('.')
+ if len(cfgpath) < 2:
+ return False
+ cfg.set(cfgpath[0], cfgpath[1], value)
+ try:
+ wconfig.writefile(cfg, fn)
+ except EnvironmentError, e:
+ return False
+ return True
|
Loading...