##// END OF EJS Templates
commitextras: work nicely with other extensions...
Valentin Gatien-Baron -
r39330:1cb7c977 default
parent child Browse files
Show More
@@ -17,6 +17,7 b' from mercurial import ('
17 error,
17 error,
18 extensions,
18 extensions,
19 registrar,
19 registrar,
20 util,
20 )
21 )
21
22
22 cmdtable = {}
23 cmdtable = {}
@@ -43,9 +44,10 b' def extsetup(ui):'
43 _('set a changeset\'s extra values'), _("KEY=VALUE")))
44 _('set a changeset\'s extra values'), _("KEY=VALUE")))
44
45
45 def _commit(orig, ui, repo, *pats, **opts):
46 def _commit(orig, ui, repo, *pats, **opts):
46 origcommit = repo.commit
47 if util.safehasattr(repo, 'unfiltered'):
47 try:
48 repo = repo.unfiltered()
48 def _wrappedcommit(*innerpats, **inneropts):
49 class repoextra(repo.__class__):
50 def commit(self, *innerpats, **inneropts):
49 extras = opts.get(r'extra')
51 extras = opts.get(r'extra')
50 if extras:
52 if extras:
51 for raw in extras:
53 for raw in extras:
@@ -66,11 +68,6 b' def _commit(orig, ui, repo, *pats, **opt'
66 "manually")
68 "manually")
67 raise error.Abort(msg % k)
69 raise error.Abort(msg % k)
68 inneropts[r'extra'][k] = v
70 inneropts[r'extra'][k] = v
69 return origcommit(*innerpats, **inneropts)
71 return super(repoextra, self).commit(*innerpats, **inneropts)
70
72 repo.__class__ = repoextra
71 # This __dict__ logic is needed because the normal
73 return orig(ui, repo, *pats, **opts)
72 # extension.wrapfunction doesn't seem to work.
73 repo.__dict__[r'commit'] = _wrappedcommit
74 return orig(ui, repo, *pats, **opts)
75 finally:
76 del repo.__dict__[r'commit']
General Comments 0
You need to be logged in to leave comments. Login now