[PATCH] commit: add --extra argument to set extra user fields

Angel Ezquerra angel.ezquerra at gmail.com
Thu Mar 6 01:59:37 CST 2014


On Thu, Mar 6, 2014 at 5:06 AM, Matt Mackall <mpm at selenic.com> wrote:
> On Wed, 2014-03-05 at 23:32 +0100, Angel Ezquerra wrote:
>> # HG changeset patch
>> # User Angel Ezquerra <angel.ezquerra at gmail.com>
>> # Date 1394000996 -3600
>> #      Wed Mar 05 07:29:56 2014 +0100
>> # Node ID 1658e55e8c9e2518236aeb8e7d1d89a1714b6f37
>> # Parent  779ceb84f4f782d32dfe47f6684107c08d2f6142
>> commit: add --extra argument to set extra user fields
>
> Perhaps the most positive thing I can say about this feature is that I
> can't stop you from doing this in a third-party extension. I'm
> definitely opposed to giving users access to putting arbitrary things in
> extra, or doing anything that's even suggestive of functionality like
> svn props. We already have enough problems managing our internal extra
> fields.

I have used subversion, but never used svn props. Could you give me a
bit more details explaining why you think this is such a bad idea? I'm
trying to create a mercurial-TFS bridge and this seemed a very
convenient way to "link" mercurial revisions with TFS changeset
numbers (for example it would let us look for a particular TFS
changest in the mercurial history). However, if you really think that
this is a terrible idea maybe I need to rethink my approach.

Assuming that this is not such a good idea, I could write an extension
as you say. However I think that I would basically need to rewrite
commands.commit, because there is no way to pass an 'extra' optional
argument to commands.commit (AFAIK). This is a bit inconvenient and a
bit risky since I would need to keep up with changes to
commands.commit if I want my extension to fully replicate the regular
behavior of the commit command. A solution would be to change
commands.commit as follows:

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1370,7 +1370,7 @@
     branch = repo[None].branch()
     bheads = repo.branchheads(branch)

-    extra = {}
+    extra = opts.get('extra', {})
     if opts.get('close_branch'):
         extra['close'] = 1

This would avoid advertising this capability to regular users, but
extension writers could still set the extra field if they needed to.

Would you be OK with a limited patch that did just that? I'm not
trying to push this if you are really against this. I'm just trying to
find the simplest solution to our problem.

Thanks,

Angel


More information about the Mercurial-devel mailing list