[PATCH] record: use patch.diffopts to account for user diffopts

Mads Kiilerich mads at kiilerich.com
Tue Jan 8 13:42:01 CST 2013


On 01/08/2013 10:08 AM, Denis Laxalde wrote:
> # HG changeset patch
> # User Denis Laxalde <denis at laxalde.org>
> # Date 1354715053 -3600
> # Node ID 83e8f22da9c2895f8cb0c7a8662e064477d63538
> # Parent  2c1276825e938872ebc099c191eb202f0dbadfcc
> record: use patch.diffopts to account for user diffopts
>
> This allows user defined diff options (e.g. showfunc) to be accounted for
> when using record. A test has been updated accordingly.
>
> diff --git a/hgext/record.py b/hgext/record.py
> --- a/hgext/record.py
> +++ b/hgext/record.py
> @@ -520,11 +520,10 @@ def dorecord(ui, repo, commitfunc, cmdsu
>                                  '(use "hg commit" instead)'))
>   
>           changes = repo.status(match=match)[:3]
> -        diffopts = mdiff.diffopts(
> -            git=True, nodates=True,
> -            ignorews=opts.get('ignore_all_space'),
> -            ignorewsamount=opts.get('ignore_space_change'),
> -            ignoreblanklines=opts.get('ignore_blank_lines'))
> +        diffopts = patch.diffopts(ui, opts=dict(git=True, nodates=True,
> +                                                ignorews=opts.get('ignore_all_space'),
> +                                                ignorewsamount=opts.get('ignore_space_change'),
> +                                                ignoreblanklines=opts.get('ignore_blank_lines')))

It is non-obvious was changed here other than whitespace. The increased 
indentation also made the lines more than 80 characters which would have 
caused test-check-code-hg.t to fail if it had been run.

Please just keep the indentation the way it was.

>           chunks = patch.diff(repo, changes=changes, opts=diffopts)
>           fp = cStringIO.StringIO()
>           fp.write(''.join(chunks))
> diff --git a/tests/test-record.t b/tests/test-record.t
> --- a/tests/test-record.t
> +++ b/tests/test-record.t
> @@ -255,18 +255,18 @@ Modify end of plain file with username u
>     [255]
>   
>   
> -Modify end of plain file
> +Modify end of plain file, also test that diffopts are accounted for
>   
>     $ HGUSER="test"
>     $ export HGUSER
> -  $ hg record -d '8 0' -m end plain <<EOF
> +  $ hg record --config diff.showfunc=true -d '8 0' -m end plain <<EOF
>     > y
>     > y
>     > EOF
>     diff --git a/plain b/plain
>     1 hunks, 1 lines changed
>     examine changes to 'plain'? [Ynesfdaq?]
> -  @@ -8,3 +8,4 @@
> +  @@ -8,3 +8,4 @@ 7

Not the best example of why this would be useful, but fine for a test ;-)

/Mads

>      8
>      9
>      10
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel



More information about the Mercurial-devel mailing list