Patchwork [4,of,4] largefiles: simplify check for lack of path arguments

login
register
mail settings
Submitter Martin von Zweigbergk
Date Nov. 2, 2014, 9:43 p.m.
Message ID <3df2c5d179ddcd2ff0a1.1414964596@handduk2.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/6537/
State Accepted
Headers show

Comments

Martin von Zweigbergk - Nov. 2, 2014, 9:43 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1414963088 28800
#      Sun Nov 02 13:18:08 2014 -0800
# Branch stable
# Node ID 3df2c5d179ddcd2ff0a1edca410ff2139725e210
# Parent  b89ddc59955d4ffc106c8566af52111f7d52f718
largefiles: simplify check for lack of path arguments

Instead of checking for a partial merge by checking that the matches
has no files and no patterns, check that it's not an
always-matcher. Except for being shorter, it also catches the rare
case of an exact-matcher with no files.
Mads Kiilerich - Nov. 3, 2014, 1:18 a.m.
On 11/02/2014 10:43 PM, Martin von Zweigbergk wrote:
> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz@google.com>
> # Date 1414963088 28800
> #      Sun Nov 02 13:18:08 2014 -0800
> # Branch stable
> # Node ID 3df2c5d179ddcd2ff0a1edca410ff2139725e210
> # Parent  b89ddc59955d4ffc106c8566af52111f7d52f718
> largefiles: simplify check for lack of path arguments
>
> Instead of checking for a partial merge by checking that the matches
> has no files and no patterns, check that it's not an
> always-matcher. Except for being shorter, it also catches the rare
> case of an exact-matcher with no files.

Please add a test case for that.

/Mads

> diff --git a/hgext/largefiles/reposetup.py b/hgext/largefiles/reposetup.py
> --- a/hgext/largefiles/reposetup.py
> +++ b/hgext/largefiles/reposetup.py
> @@ -284,8 +284,7 @@
>                   # Case 1: user calls commit with no specific files or
>                   # include/exclude patterns: refresh and commit all files that
>                   # are "dirty".
> -                if ((match is None) or
> -                    (not match.anypats() and not match.files())):
> +                if match is None or match.always():
>                       # Spend a bit of time here to get a list of files we know
>                       # are modified so we can compare only against those.
>                       # It can cost a lot of time (several seconds)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
Martin von Zweigbergk - Nov. 3, 2014, 6:19 a.m.
On Sun Nov 02 2014 at 5:18:46 PM Mads Kiilerich <mads@kiilerich.com> wrote:

> On 11/02/2014 10:43 PM, Martin von Zweigbergk wrote:
> > # HG changeset patch
> > # User Martin von Zweigbergk <martinvonz@google.com>
> > # Date 1414963088 28800
> > #      Sun Nov 02 13:18:08 2014 -0800
> > # Branch stable
> > # Node ID 3df2c5d179ddcd2ff0a1edca410ff2139725e210
> > # Parent  b89ddc59955d4ffc106c8566af52111f7d52f718
> > largefiles: simplify check for lack of path arguments
> >
> > Instead of checking for a partial merge by checking that the matches
> > has no files and no patterns, check that it's not an
> > always-matcher. Except for being shorter, it also catches the rare
> > case of an exact-matcher with no files.
>
> Please add a test case for that.
>

I'm afraid that should have been s/rare/hypothetical/. Such matchers are
sometimes created (mostly by mq, but also in import and revert), but it
seems like the matcher that's passed into localrepo.commit() (the method I
modified in this patch) can not be an exact matcher with no files.

I still think the patch is the right thing to do. Should I resend this and
the previous patch with these small changes to the commit messages?
Mads Kiilerich - Nov. 3, 2014, 4:15 p.m.
On 11/03/2014 07:19 AM, Martin von Zweigbergk wrote:
> I still think the patch is the right thing to do. Should I resend this 
> and the previous patch with these small changes to the commit messages? 

I agree that patches are ok and could be taken as they are. A very small 
+0 for resending with only commit message changes.

/Mads
Matt Mackall - Nov. 3, 2014, 9:54 p.m.
On Sun, 2014-11-02 at 13:43 -0800, Martin von Zweigbergk wrote:
> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz@google.com>
> # Date 1414963088 28800
> #      Sun Nov 02 13:18:08 2014 -0800
> # Branch stable
> # Node ID 3df2c5d179ddcd2ff0a1edca410ff2139725e210
> # Parent  b89ddc59955d4ffc106c8566af52111f7d52f718
> largefiles: simplify check for lack of path arguments

These are queued for default, thanks. Mads, thanks for the review.

Patch

diff --git a/hgext/largefiles/reposetup.py b/hgext/largefiles/reposetup.py
--- a/hgext/largefiles/reposetup.py
+++ b/hgext/largefiles/reposetup.py
@@ -284,8 +284,7 @@ 
                 # Case 1: user calls commit with no specific files or
                 # include/exclude patterns: refresh and commit all files that
                 # are "dirty".
-                if ((match is None) or
-                    (not match.anypats() and not match.files())):
+                if match is None or match.always():
                     # Spend a bit of time here to get a list of files we know
                     # are modified so we can compare only against those.
                     # It can cost a lot of time (several seconds)