Mercurial > hg
view hgext/commitextras.py @ 47272:a671832a8e41
urlutil: move url "fixing" at the time of `ui.paths` initialization
Doing such fixing at the time is simpler and will be necessary to deal with
urls list in a sane manner. It also reduce the size of fix-config which is
always better.
I wish we could get ride of the hackish way to pass the root around, I suspect
that the `root` variable could be stored as part of the config value, along side
the source. However getting to the end of this `root` business is a far too
large detours to make now.
The test change to `tests/test-hgrc.t` and `test-config.t` are expectied since
we are not longer altering the config itself, but the way it is interpreted when
building path. This seems more correct.
I also added a couple of test call to `test-config.t` and `test-globalopts.t` to
clarify that the expanding process is properly happening a the right time.
Differential Revision: https://phab.mercurial-scm.org/D10451
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 15 Apr 2021 20:13:29 +0200 |
parents | 9f70512ae2cf |
children | 45a073af50a2 |
line wrap: on
line source
# commitextras.py # # Copyright 2013 Facebook, Inc. # # This software may be used and distributed according to the terms of the # GNU General Public License version 2 or any later version. '''adds a new flag extras to commit (ADVANCED)''' from __future__ import absolute_import import re from mercurial.i18n import _ from mercurial import ( commands, error, extensions, registrar, util, ) cmdtable = {} command = registrar.command(cmdtable) testedwith = b'ships-with-hg-core' usedinternally = { b'amend_source', b'branch', b'close', b'histedit_source', b'topic', b'rebase_source', b'intermediate-source', b'__touch-noise__', b'source', b'transplant_source', } def extsetup(ui): entry = extensions.wrapcommand(commands.table, b'commit', _commit) options = entry[1] options.append( ( b'', b'extra', [], _(b'set a changeset\'s extra values'), _(b"KEY=VALUE"), ) ) def _commit(orig, ui, repo, *pats, **opts): if util.safehasattr(repo, 'unfiltered'): repo = repo.unfiltered() class repoextra(repo.__class__): def commit(self, *innerpats, **inneropts): extras = opts.get('extra') for raw in extras: if b'=' not in raw: msg = _( b"unable to parse '%s', should follow " b"KEY=VALUE format" ) raise error.Abort(msg % raw) k, v = raw.split(b'=', 1) if not k: msg = _(b"unable to parse '%s', keys can't be empty") raise error.Abort(msg % raw) if re.search(br'[^\w-]', k): msg = _( b"keys can only contain ascii letters, digits," b" '_' and '-'" ) raise error.Abort(msg) if k in usedinternally: msg = _( b"key '%s' is used internally, can't be set " b"manually" ) raise error.Abort(msg % k) inneropts['extra'][k] = v return super(repoextra, self).commit(*innerpats, **inneropts) repo.__class__ = repoextra return orig(ui, repo, *pats, **opts)