Patchwork [V2] purge: avoid duplicate output for --print (issue4092)

login
register
mail settings
Submitter Anurag Goel
Date Feb. 25, 2014, 1:03 a.m.
Message ID <6f3220a878ae0610ac44.1393290216@ubuntu.ubuntu-domain>
Download mbox | patch
Permalink /patch/3756/
State Accepted
Commit f1c3ba167b0c73207c726b5a68c59c9b14560d2e
Headers show

Comments

Anurag Goel - Feb. 25, 2014, 1:03 a.m.
# HG changeset patch
# User anuraggoel <anurag.dsps@gmail.com>
# Date 1393290021 -19800
#      Tue Feb 25 06:30:21 2014 +0530
# Node ID 6f3220a878ae0610ac44728bbbd3e3617eb3c0bf
# Parent  aa021ece4506f5e962c8d87ab58ab594a0105ced
purge: avoid duplicate output for --print (issue4092)

Now "hg purge -p" commands avoids printiing duplication of filenames.

Second patch is the test coverage of first patch which tells that '-p'
does not depend on whether ui.verbose is configured or not,that means it
is independent of '-v'.
Matt Mackall - Feb. 25, 2014, 5:09 p.m.
On Tue, 2014-02-25 at 06:33 +0530, Anurag Goel wrote:
> # HG changeset patch
> # User anuraggoel <anurag.dsps@gmail.com>
> # Date 1393290021 -19800
> #      Tue Feb 25 06:30:21 2014 +0530
> # Node ID 6f3220a878ae0610ac44728bbbd3e3617eb3c0bf
> # Parent  aa021ece4506f5e962c8d87ab58ab594a0105ced
> purge: avoid duplicate output for --print (issue4092)
> 
> Now "hg purge -p" commands avoids printiing duplication of filenames.
> 
> Second patch is the test coverage of first patch which tells that '-p'
> does not depend on whether ui.verbose is configured or not,that means it
> is independent of '-v'.

Queued for stable, thanks, but see below.

Here is the test I was hoping to see:

> diff -r aa021ece4506 -r 6f3220a878ae tests/test-purge.t
> --- a/tests/test-purge.t	Thu Feb 20 00:46:13 2014 -0600
> +++ b/tests/test-purge.t	Tue Feb 25 06:30:21 2014 +0530
> @@ -21,7 +21,7 @@
>  delete an empty directory
>  
>    $ mkdir empty_dir
> -  $ hg purge -p
> +  $ hg purge -p -v
>    empty_dir
>    $ hg purge -v
>    removing directory empty_dir

(It can in fact be reduced to the single character change I hinted at by
writing it as 'hg purge -pv')

But I have no idea why you're testing the same behavior 16 more times?
Not only is that pointless, it's actually bad, because it means we're
now _not_ testing -p without -v. Dropping the rest of this patch.

> @@ -34,7 +34,7 @@
>    $ mkdir untracked_dir
>    $ touch untracked_dir/untracked_file1
>    $ touch untracked_dir/untracked_file2
> -  $ hg purge -p
> +  $ hg purge -p -v
>    untracked_dir/untracked_file1
>    untracked_dir/untracked_file2
>    $ hg purge -v
> @@ -54,7 +54,7 @@
>    > f= 'untracked_file_readonly'
>    > os.chmod(f, stat.S_IMODE(os.stat(f).st_mode) & ~stat.S_IWRITE)
>    > EOF
> -  $ hg purge -p
> +  $ hg purge -p -v
>    untracked_file
>    untracked_file_readonly
>    $ hg purge -v
> @@ -67,7 +67,7 @@
>  delete an untracked file in a tracked directory
>  
>    $ touch directory/untracked_file
> -  $ hg purge -p
> +  $ hg purge -p -v
>    directory/untracked_file
>    $ hg purge -v
>    removing file directory/untracked_file
> @@ -78,7 +78,7 @@
>  delete nested directories
>  
>    $ mkdir -p untracked_directory/nested_directory
> -  $ hg purge -p
> +  $ hg purge -p -v
>    untracked_directory/nested_directory
>    $ hg purge -v
>    removing directory untracked_directory/nested_directory
> @@ -91,7 +91,7 @@
>  
>    $ mkdir -p untracked_directory/nested_directory
>    $ cd directory
> -  $ hg purge -p
> +  $ hg purge -p -v
>    untracked_directory/nested_directory
>    $ hg purge -v
>    removing directory untracked_directory/nested_directory
> @@ -106,7 +106,7 @@
>    $ mkdir -p untracked_directory/nested_directory
>    $ touch directory/untracked_file
>    $ cd directory
> -  $ hg purge -p ../untracked_directory
> +  $ hg purge -p -v ../untracked_directory
>    untracked_directory/nested_directory
>    $ hg purge -v ../untracked_directory
>    removing directory untracked_directory/nested_directory
> @@ -122,13 +122,13 @@
>  skip ignored files if --all not specified
>  
>    $ touch ignored
> -  $ hg purge -p
> +  $ hg purge -p -v
>    $ hg purge -v
>    $ ls
>    directory
>    ignored
>    r1
> -  $ hg purge -p --all
> +  $ hg purge -p -v --all
>    ignored
>    $ hg purge -v --all
>    removing file ignored
> @@ -143,13 +143,13 @@
>  
>  hide error messages to avoid changing the output when the text changes
>  
> -  $ hg purge -p 2> /dev/null
> +  $ hg purge -p -v 2> /dev/null
>    untracked_file
>    $ hg st
>    ! r1
>    ? untracked_file
>  
> -  $ hg purge -p
> +  $ hg purge -p -v
>    untracked_file
>    $ hg purge -v 2> /dev/null
>    removing file untracked_file
> @@ -165,7 +165,7 @@
>    $ echo directory >> .hgignore
>    $ hg ci -m 'ignore directory'
>    $ touch untracked_file
> -  $ hg purge -p
> +  $ hg purge -p -v
>    untracked_file
>    $ hg purge -v
>    removing file untracked_file
> @@ -173,7 +173,7 @@
>  skip excluded files
>  
>    $ touch excluded_file
> -  $ hg purge -p -X excluded_file
> +  $ hg purge -p -v -X excluded_file
>    $ hg purge -v -X excluded_file
>    $ ls
>    directory
> @@ -185,7 +185,7 @@
>  
>    $ mkdir excluded_dir
>    $ touch excluded_dir/file
> -  $ hg purge -p -X excluded_dir
> +  $ hg purge -p -v -X excluded_dir
>    $ hg purge -v -X excluded_dir
>    $ ls
>    directory
> @@ -198,7 +198,7 @@
>  skip excluded empty dirs
>  
>    $ mkdir excluded_dir
> -  $ hg purge -p -X excluded_dir
> +  $ hg purge -p -v -X excluded_dir
>    $ hg purge -v -X excluded_dir
>    $ ls
>    directory
> @@ -212,7 +212,7 @@
>    $ touch .svn/foo
>    $ mkdir directory/.svn
>    $ touch directory/.svn/foo
> -  $ hg purge -p -X .svn -X '*/.svn'
> -  $ hg purge -p -X re:.*.svn
> +  $ hg purge -p -v -X .svn -X '*/.svn'
> +  $ hg purge -p -v -X re:.*.svn
>  
>    $ cd ..
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff -r aa021ece4506 -r 6f3220a878ae hgext/purge.py
--- a/hgext/purge.py	Thu Feb 20 00:46:13 2014 -0600
+++ b/hgext/purge.py	Tue Feb 25 06:30:21 2014 +0530
@@ -101,10 +101,12 @@ 
     status = repo.status(match=match, ignored=opts['all'], unknown=True)
 
     for f in sorted(status[4] + status[5]):
-        ui.note(_('removing file %s\n') % f)
+        if act:
+            ui.note(_('removing file %s\n') % f)
         remove(removefile, f)
 
     for f in sorted(directories, reverse=True):
         if match(f) and not os.listdir(repo.wjoin(f)):
-            ui.note(_('removing directory %s\n') % f)
+            if act:
+                ui.note(_('removing directory %s\n') % f)
             remove(os.rmdir, f)
diff -r aa021ece4506 -r 6f3220a878ae tests/test-purge.t
--- a/tests/test-purge.t	Thu Feb 20 00:46:13 2014 -0600
+++ b/tests/test-purge.t	Tue Feb 25 06:30:21 2014 +0530
@@ -21,7 +21,7 @@ 
 delete an empty directory
 
   $ mkdir empty_dir
-  $ hg purge -p
+  $ hg purge -p -v
   empty_dir
   $ hg purge -v
   removing directory empty_dir
@@ -34,7 +34,7 @@ 
   $ mkdir untracked_dir
   $ touch untracked_dir/untracked_file1
   $ touch untracked_dir/untracked_file2
-  $ hg purge -p
+  $ hg purge -p -v
   untracked_dir/untracked_file1
   untracked_dir/untracked_file2
   $ hg purge -v
@@ -54,7 +54,7 @@ 
   > f= 'untracked_file_readonly'
   > os.chmod(f, stat.S_IMODE(os.stat(f).st_mode) & ~stat.S_IWRITE)
   > EOF
-  $ hg purge -p
+  $ hg purge -p -v
   untracked_file
   untracked_file_readonly
   $ hg purge -v
@@ -67,7 +67,7 @@ 
 delete an untracked file in a tracked directory
 
   $ touch directory/untracked_file
-  $ hg purge -p
+  $ hg purge -p -v
   directory/untracked_file
   $ hg purge -v
   removing file directory/untracked_file
@@ -78,7 +78,7 @@ 
 delete nested directories
 
   $ mkdir -p untracked_directory/nested_directory
-  $ hg purge -p
+  $ hg purge -p -v
   untracked_directory/nested_directory
   $ hg purge -v
   removing directory untracked_directory/nested_directory
@@ -91,7 +91,7 @@ 
 
   $ mkdir -p untracked_directory/nested_directory
   $ cd directory
-  $ hg purge -p
+  $ hg purge -p -v
   untracked_directory/nested_directory
   $ hg purge -v
   removing directory untracked_directory/nested_directory
@@ -106,7 +106,7 @@ 
   $ mkdir -p untracked_directory/nested_directory
   $ touch directory/untracked_file
   $ cd directory
-  $ hg purge -p ../untracked_directory
+  $ hg purge -p -v ../untracked_directory
   untracked_directory/nested_directory
   $ hg purge -v ../untracked_directory
   removing directory untracked_directory/nested_directory
@@ -122,13 +122,13 @@ 
 skip ignored files if --all not specified
 
   $ touch ignored
-  $ hg purge -p
+  $ hg purge -p -v
   $ hg purge -v
   $ ls
   directory
   ignored
   r1
-  $ hg purge -p --all
+  $ hg purge -p -v --all
   ignored
   $ hg purge -v --all
   removing file ignored
@@ -143,13 +143,13 @@ 
 
 hide error messages to avoid changing the output when the text changes
 
-  $ hg purge -p 2> /dev/null
+  $ hg purge -p -v 2> /dev/null
   untracked_file
   $ hg st
   ! r1
   ? untracked_file
 
-  $ hg purge -p
+  $ hg purge -p -v
   untracked_file
   $ hg purge -v 2> /dev/null
   removing file untracked_file
@@ -165,7 +165,7 @@ 
   $ echo directory >> .hgignore
   $ hg ci -m 'ignore directory'
   $ touch untracked_file
-  $ hg purge -p
+  $ hg purge -p -v
   untracked_file
   $ hg purge -v
   removing file untracked_file
@@ -173,7 +173,7 @@ 
 skip excluded files
 
   $ touch excluded_file
-  $ hg purge -p -X excluded_file
+  $ hg purge -p -v -X excluded_file
   $ hg purge -v -X excluded_file
   $ ls
   directory
@@ -185,7 +185,7 @@ 
 
   $ mkdir excluded_dir
   $ touch excluded_dir/file
-  $ hg purge -p -X excluded_dir
+  $ hg purge -p -v -X excluded_dir
   $ hg purge -v -X excluded_dir
   $ ls
   directory
@@ -198,7 +198,7 @@ 
 skip excluded empty dirs
 
   $ mkdir excluded_dir
-  $ hg purge -p -X excluded_dir
+  $ hg purge -p -v -X excluded_dir
   $ hg purge -v -X excluded_dir
   $ ls
   directory
@@ -212,7 +212,7 @@ 
   $ touch .svn/foo
   $ mkdir directory/.svn
   $ touch directory/.svn/foo
-  $ hg purge -p -X .svn -X '*/.svn'
-  $ hg purge -p -X re:.*.svn
+  $ hg purge -p -v -X .svn -X '*/.svn'
+  $ hg purge -p -v -X re:.*.svn
 
   $ cd ..