Details
Details
- Reviewers
pulkit - Group Reviewers
hg-reviewers - Commits
- rHG3a60416c4fd8: commitextras: no need to special case extras=[]
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
pulkit |
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | hgext/commitextras.py (37 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
Valentin Gatien-Baron | Aug 27 2018, 4:03 PM |
Status | Author | Revision | |
---|---|---|---|
Closed | valentin.gatienbaron | ||
Closed | valentin.gatienbaron |
_('set a changeset\'s extra values'), _("KEY=VALUE"))) | _('set a changeset\'s extra values'), _("KEY=VALUE"))) | ||||
def _commit(orig, ui, repo, *pats, **opts): | def _commit(orig, ui, repo, *pats, **opts): | ||||
if util.safehasattr(repo, 'unfiltered'): | if util.safehasattr(repo, 'unfiltered'): | ||||
repo = repo.unfiltered() | repo = repo.unfiltered() | ||||
class repoextra(repo.__class__): | class repoextra(repo.__class__): | ||||
def commit(self, *innerpats, **inneropts): | def commit(self, *innerpats, **inneropts): | ||||
extras = opts.get(r'extra') | extras = opts.get(r'extra') | ||||
if extras: | |||||
for raw in extras: | for raw in extras: | ||||
if '=' not in raw: | if '=' not in raw: | ||||
msg = _("unable to parse '%s', should follow " | msg = _("unable to parse '%s', should follow " | ||||
"KEY=VALUE format") | "KEY=VALUE format") | ||||
raise error.Abort(msg % raw) | raise error.Abort(msg % raw) | ||||
k, v = raw.split('=', 1) | k, v = raw.split('=', 1) | ||||
if not k: | if not k: | ||||
msg = _("unable to parse '%s', keys can't be empty") | msg = _("unable to parse '%s', keys can't be empty") | ||||
raise error.Abort(msg % raw) | raise error.Abort(msg % raw) | ||||
if re.search('[^\w-]', k): | if re.search('[^\w-]', k): | ||||
msg = _("keys can only contain ascii letters, digits," | msg = _("keys can only contain ascii letters, digits," | ||||
" '_' and '-'") | " '_' and '-'") | ||||
raise error.Abort(msg) | raise error.Abort(msg) | ||||
if k in usedinternally: | if k in usedinternally: | ||||
msg = _("key '%s' is used internally, can't be set " | msg = _("key '%s' is used internally, can't be set " | ||||
"manually") | "manually") | ||||
raise error.Abort(msg % k) | raise error.Abort(msg % k) | ||||
inneropts[r'extra'][k] = v | inneropts[r'extra'][k] = v | ||||
return super(repoextra, self).commit(*innerpats, **inneropts) | return super(repoextra, self).commit(*innerpats, **inneropts) | ||||
repo.__class__ = repoextra | repo.__class__ = repoextra | ||||
return orig(ui, repo, *pats, **opts) | return orig(ui, repo, *pats, **opts) |