Show More
@@ -0,0 +1,45 b'' | |||||
|
1 | # commitextras.py | |||
|
2 | # | |||
|
3 | # Copyright 2013 Facebook, Inc. | |||
|
4 | # | |||
|
5 | # This software may be used and distributed according to the terms of the | |||
|
6 | # GNU General Public License version 2 or any later version. | |||
|
7 | ||||
|
8 | '''adds a new flag extras to commit''' | |||
|
9 | ||||
|
10 | from __future__ import absolute_import | |||
|
11 | ||||
|
12 | from mercurial.i18n import _ | |||
|
13 | from mercurial import ( | |||
|
14 | commands, | |||
|
15 | extensions, | |||
|
16 | registrar, | |||
|
17 | ) | |||
|
18 | ||||
|
19 | cmdtable = {} | |||
|
20 | command = registrar.command(cmdtable) | |||
|
21 | testedwith = 'ships-with-hg-core' | |||
|
22 | ||||
|
23 | def extsetup(ui): | |||
|
24 | entry = extensions.wrapcommand(commands.table, 'commit', _commit) | |||
|
25 | options = entry[1] | |||
|
26 | options.append(('', 'extra', [], | |||
|
27 | _('set a changeset\'s extra values'), _("KEY=VALUE"))) | |||
|
28 | ||||
|
29 | def _commit(orig, ui, repo, *pats, **opts): | |||
|
30 | origcommit = repo.commit | |||
|
31 | try: | |||
|
32 | def _wrappedcommit(*innerpats, **inneropts): | |||
|
33 | extras = opts.get('extra') | |||
|
34 | if extras: | |||
|
35 | for raw in extras: | |||
|
36 | k, v = raw.split('=', 1) | |||
|
37 | inneropts['extra'][k] = v | |||
|
38 | return origcommit(*innerpats, **inneropts) | |||
|
39 | ||||
|
40 | # This __dict__ logic is needed because the normal | |||
|
41 | # extension.wrapfunction doesn't seem to work. | |||
|
42 | repo.__dict__['commit'] = _wrappedcommit | |||
|
43 | return orig(ui, repo, *pats, **opts) | |||
|
44 | finally: | |||
|
45 | del repo.__dict__['commit'] |
@@ -254,6 +254,7 b' Test extension help:' | |||||
254 | censor erase file content at a given revision |
|
254 | censor erase file content at a given revision | |
255 | churn command to display statistics about repository history |
|
255 | churn command to display statistics about repository history | |
256 | clonebundles advertise pre-generated bundles to seed clones |
|
256 | clonebundles advertise pre-generated bundles to seed clones | |
|
257 | commitextras adds a new flag extras to commit | |||
257 | convert import revisions from foreign VCS repositories into |
|
258 | convert import revisions from foreign VCS repositories into | |
258 | Mercurial |
|
259 | Mercurial | |
259 | eol automatically manage newlines in repository files |
|
260 | eol automatically manage newlines in repository files |
General Comments 0
You need to be logged in to leave comments.
Login now