issue1420: hg diff -c <rev>

Stepan Koltsov yozh at mx1.ru
Fri Dec 12 19:19:41 CST 2008


On Sat, Dec 13, 2008 at 00:21, Matt Mackall <mpm at selenic.com> wrote:
> On Fri, 2008-12-12 at 03:42 +0300, Stepan Koltsov wrote:
>> some time ago I've created second version of patch for --change flag
>> for diff subcommand ( http://www.selenic.com/mercurial/bts/issue1420
>> ).
>>
>> Could someone, please, either apply patch, close issue as "won't fix",
>> or tell me what's wrong with current patch?
>>
>> ===
>> diff -r 6aafd75fb924 mercurial/commands.py
>> --- a/mercurial/commands.py   Tue Dec 02 13:06:18 2008 -0600
>> +++ b/mercurial/commands.py   Tue Dec 09 14:53:05 2008 +0000
>> @@ -1007,7 +1007,17 @@
>>      Use the --git option to generate diffs in the git extended diff
>>      format. Read the diffs help topic for more information.
>>      """
>> -    node1, node2 = cmdutil.revpair(repo, opts.get('rev'))
>> +    revopts = opts.get('rev')
>> +    changeopts = opts.get('change')
>> +    if revopts and changeopts:
>> +        raise util.Abort(_('cannot specify --rev and --change at the
>> same time'))
>> +    elif len(changeopts) > 1:
>> +        raise util.Abort(_('change can be specified no more then once'))
>> +    elif changeopts:
>> +        node2 = repo.lookup(changeopts[0])
>> +        node1 = repo[node2].parents()[0].node()
>> +    else:
>> +        node1, node2 = cmdutil.revpair(repo, revopts)
>>
>>      m = cmdutil.match(repo, pats, opts)
>>      it = patch.diff(repo, node1, node2, match=m, opts=patch.diffopts(ui, opts))
>> @@ -3158,7 +3168,8 @@
>>      "debugwalk": (debugwalk, walkopts, _('[OPTION]... [FILE]...')),
>>      "^diff":
>>          (diff,
>> -         [('r', 'rev', [], _('revision'))
>> +         [('r', 'rev', [], _('revision')),
>> +          ('c', 'change', [], _('change made by revision'))
>
> The '[]' indicates this option takes a list of values, which it doesn't.

I'll fix.

> What happens when the changeset in question is a merge?

Behavior is the same as hg log -p -r <rev>. It is compared with the
first parent. I'll add test case for this.

S.


More information about the Mercurial-devel mailing list