Patchwork crecord: add dictionary to default return value of filterpatch

login
register
mail settings
Submitter Christian Delahousse
Date Dec. 10, 2015, 1:10 a.m.
Message ID <9a1a06e8de4b19baa012.1449709813@dev4253.prn1.facebook.com>
Download mbox | patch
Permalink /patch/11957/
State Accepted
Delegated to: Pierre-Yves David
Headers show

Comments

Christian Delahousse - Dec. 10, 2015, 1:10 a.m.
# HG changeset patch
# User Laurent Charignon <lcharignon@fb.com>
# Date 1449709287 28800
#      Wed Dec 09 17:01:27 2015 -0800
# Node ID 9a1a06e8de4b19baa01277db2ae6d46fa74b91b0
# Parent  42aa0e570eaa364a622bc4443b0bcb79b1100a58
crecord: add dictionary to default return value of filterpatch

When committing interactively without changes, the user would get a ValueError
exception. This patch adds a dictionary to the return value of filterpatch
when there are no files to change.
Sean Farley - Dec. 10, 2015, 4:29 a.m.
cdelahousse@fb.com writes:

> # HG changeset patch
> # User Laurent Charignon <lcharignon@fb.com>
> # Date 1449709287 28800
> #      Wed Dec 09 17:01:27 2015 -0800
> # Node ID 9a1a06e8de4b19baa01277db2ae6d46fa74b91b0
> # Parent  42aa0e570eaa364a622bc4443b0bcb79b1100a58
> crecord: add dictionary to default return value of filterpatch
>
> When committing interactively without changes, the user would get a ValueError
> exception. This patch adds a dictionary to the return value of filterpatch
> when there are no files to change.

Looks good to me.
Pierre-Yves David - Dec. 10, 2015, 8:22 p.m.
On 12/10/2015 04:29 AM, Sean Farley wrote:
>
> cdelahousse@fb.com writes:
>
>> # HG changeset patch
>> # User Laurent Charignon <lcharignon@fb.com>
>> # Date 1449709287 28800
>> #      Wed Dec 09 17:01:27 2015 -0800
>> # Node ID 9a1a06e8de4b19baa01277db2ae6d46fa74b91b0
>> # Parent  42aa0e570eaa364a622bc4443b0bcb79b1100a58
>> crecord: add dictionary to default return value of filterpatch
>>
>> When committing interactively without changes, the user would get a ValueError
>> exception. This patch adds a dictionary to the return value of filterpatch
>> when there are no files to change.
>
> Looks good to me.


Pushed to the clowncopter, thanks

Patch

diff --git a/mercurial/crecord.py b/mercurial/crecord.py
--- a/mercurial/crecord.py
+++ b/mercurial/crecord.py
@@ -451,7 +451,7 @@ 
 
     # if there are no changed files
     if len(headers) == 0:
-        return []
+        return [], {}
     uiheaders = [uiheader(h) for h in headers]
     # let user choose headers/hunks/lines, and mark their applied flags
     # accordingly
diff --git a/tests/test-commit-interactive-curses.t b/tests/test-commit-interactive-curses.t
--- a/tests/test-commit-interactive-curses.t
+++ b/tests/test-commit-interactive-curses.t
@@ -41,6 +41,10 @@ 
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     a
   
+Check that commit -i works with no changes
+  $ hg commit -i
+  no changes to record
+
 Committing only one file
 
   $ echo "a" >> a