Patchwork patch: remove unused fsbackend._join()

login
register
mail settings
Submitter via Mercurial-devel
Date June 30, 2017, 3:47 p.m.
Message ID <dd379552c909738a96fa.1498837679@martinvonz.svl.corp.google.com>
Download mbox | patch
Permalink /patch/21851/
State Accepted
Headers show

Comments

via Mercurial-devel - June 30, 2017, 3:47 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1498802687 25200
#      Thu Jun 29 23:04:47 2017 -0700
# Node ID dd379552c909738a96fae181e8a6f132034f2b60
# Parent  40ee74bfa11122a0a3ab74186f5056243b84af89
patch: remove unused fsbackend._join()

The function lost its last caller in 2a095d3442e0 (patch: replace
functions in fsbackend to use vfs, 2014-06-05) when the callers
started relying on the opener to do the join.
Jun Wu - June 30, 2017, 3:54 p.m.
Looks good to me. I wonder if we can have some test-check automation to
detect dead code. A quick google shows "vulture" is a tool and it seems
working:

    % vulture patch.py                                                                                 ~/hg-committed/mercurial
    patch.py:148: Unused function 'next'
    patch.py:189: Unused function 'extract'
    patch.py:456: Unused function '_join'
    patch.py:993: Unused function 'filterpatch'
    patch.py:1467: Unused function 'reversehunks'
    patch.py:2109: Unused function 'patchrepo'
    patch.py:2114: Unused function 'patch'
    patch.py:2136: Unused function 'changedfiles'
    patch.py:2448: Unused function 'diffui'
    patch.py:2729: Unused function 'diffstatui'

I'll send patches to integrate it.

Excerpts from Martin von Zweigbergk's message of 2017-06-30 08:47:59 -0700:
> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz@google.com>
> # Date 1498802687 25200
> #      Thu Jun 29 23:04:47 2017 -0700
> # Node ID dd379552c909738a96fae181e8a6f132034f2b60
> # Parent  40ee74bfa11122a0a3ab74186f5056243b84af89
> patch: remove unused fsbackend._join()
> 
> The function lost its last caller in 2a095d3442e0 (patch: replace
> functions in fsbackend to use vfs, 2014-06-05) when the callers
> started relying on the opener to do the join.
> 
> diff --git a/mercurial/patch.py b/mercurial/patch.py
> --- a/mercurial/patch.py
> +++ b/mercurial/patch.py
> @@ -453,9 +453,6 @@
>          super(fsbackend, self).__init__(ui)
>          self.opener = vfsmod.vfs(basedir)
>  
> -    def _join(self, f):
> -        return os.path.join(self.opener.base, f)
> -
>      def getfile(self, fname):
>          if self.opener.islink(fname):
>              return (self.opener.readlink(fname), (True, False))
via Mercurial-devel - June 30, 2017, 4:04 p.m.
On Fri, Jun 30, 2017 at 8:54 AM, Jun Wu <quark@fb.com> wrote:
> Looks good to me. I wonder if we can have some test-check automation to
> detect dead code. A quick google shows "vulture" is a tool and it seems
> working:

Lots of false positives, though (expected from a dynamically typed language).

>
>     % vulture patch.py                                                                                 ~/hg-committed/mercurial
>     patch.py:148: Unused function 'next'

This seems to be used by using it as an iterator later (i.e. iter()
will call it, I think).

>     patch.py:189: Unused function 'extract'

Used from cmdutil.

>     patch.py:456: Unused function '_join'
>     patch.py:993: Unused function 'filterpatch'
>     patch.py:1467: Unused function 'reversehunks'
>     patch.py:2109: Unused function 'patchrepo'
>     patch.py:2114: Unused function 'patch'
>     patch.py:2136: Unused function 'changedfiles'
>     patch.py:2448: Unused function 'diffui'
>     patch.py:2729: Unused function 'diffstatui'

I didn't check any other functions in the list.

>
> I'll send patches to integrate it.

I'm skeptical it will find much without a lot of effort from us to
filter out false positives, but sure, we can at least try it.

>
> Excerpts from Martin von Zweigbergk's message of 2017-06-30 08:47:59 -0700:
>> # HG changeset patch
>> # User Martin von Zweigbergk <martinvonz@google.com>
>> # Date 1498802687 25200
>> #      Thu Jun 29 23:04:47 2017 -0700
>> # Node ID dd379552c909738a96fae181e8a6f132034f2b60
>> # Parent  40ee74bfa11122a0a3ab74186f5056243b84af89
>> patch: remove unused fsbackend._join()
>>
>> The function lost its last caller in 2a095d3442e0 (patch: replace
>> functions in fsbackend to use vfs, 2014-06-05) when the callers
>> started relying on the opener to do the join.
>>
>> diff --git a/mercurial/patch.py b/mercurial/patch.py
>> --- a/mercurial/patch.py
>> +++ b/mercurial/patch.py
>> @@ -453,9 +453,6 @@
>>          super(fsbackend, self).__init__(ui)
>>          self.opener = vfsmod.vfs(basedir)
>>
>> -    def _join(self, f):
>> -        return os.path.join(self.opener.base, f)
>> -
>>      def getfile(self, fname):
>>          if self.opener.islink(fname):
>>              return (self.opener.readlink(fname), (True, False))
Yuya Nishihara - July 1, 2017, 1:36 a.m.
On Fri, 30 Jun 2017 08:47:59 -0700, Martin von Zweigbergk via Mercurial-devel wrote:
> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz@google.com>
> # Date 1498802687 25200
> #      Thu Jun 29 23:04:47 2017 -0700
> # Node ID dd379552c909738a96fae181e8a6f132034f2b60
> # Parent  40ee74bfa11122a0a3ab74186f5056243b84af89
> patch: remove unused fsbackend._join()

Queued, thanks.

Patch

diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -453,9 +453,6 @@ 
         super(fsbackend, self).__init__(ui)
         self.opener = vfsmod.vfs(basedir)
 
-    def _join(self, f):
-        return os.path.join(self.opener.base, f)
-
     def getfile(self, fname):
         if self.opener.islink(fname):
             return (self.opener.readlink(fname), (True, False))