1191 return |
1192 return |
1192 msg += ("\n(compatibility will be dropped after Mercurial-%s," |
1193 msg += ("\n(compatibility will be dropped after Mercurial-%s," |
1193 " update your code.)") % version |
1194 " update your code.)") % version |
1194 self.develwarn(msg, stacklevel=2, config='deprec-warn') |
1195 self.develwarn(msg, stacklevel=2, config='deprec-warn') |
1195 |
1196 |
|
1197 @contextlib.contextmanager |
|
1198 def configoverride(self, overrides, source=""): |
|
1199 """Context manager for temporary config overrides |
|
1200 `overrides` must be a dict of the following structure: |
|
1201 {(section, name) : value}""" |
|
1202 backups = {} |
|
1203 for (section, name), value in overrides.items(): |
|
1204 backups[(section, name)] = self.backupconfig(section, name) |
|
1205 self.setconfig(section, name, value, source) |
|
1206 yield |
|
1207 for __, backup in backups.items(): |
|
1208 self.restoreconfig(backup) |
|
1209 # just restoring ui.quiet config to the previous value is not enough |
|
1210 # as it does not update ui.quiet class member |
|
1211 if ('ui', 'quiet') in overrides: |
|
1212 self.fixconfig(section='ui') |
|
1213 |
1196 class paths(dict): |
1214 class paths(dict): |
1197 """Represents a collection of paths and their configs. |
1215 """Represents a collection of paths and their configs. |
1198 |
1216 |
1199 Data is initially derived from ui instances and the config files they have |
1217 Data is initially derived from ui instances and the config files they have |
1200 loaded. |
1218 loaded. |