You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by masaru tsuchiyama <m....@gmail.com> on 2009/10/18 09:18:31 UTC

[PATCH] command line options to use external command to compress

Hi.

I added the feature to use external command instead of
python bzip2 or gzip module.

[[[
   add two command line options, --bzip2-cmd and --gzip-cmd
   to svn-backup-dumps.py

   if --bzip2-cmd option is specified, the script use bzip2 command to
   compress the dump stream instead of python bzip2 module.

   if --gzip-cmd option is specified, the script use gzip command to
   compress the dump stream instead of python gzip module.

   * tools/server-side/svn-backup-dumps.py
     (SvnBackupOutputCommand): add new class to launch external command to
                               compress.
     (SvnBackup.__init__): add two member variables, __bzip2_path and
                           __gzip_path to hold command line parameters
     (SvnBackup.create_dump): create instance of SvnBackupOutputCommand
                              when __bzip2_path or __gzip_path is valid
   ]]]

Regards.

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2408637

Re: [PATCH] command line options to use external command to compress

Posted by masaru tsuchiyama <m....@gmail.com>.
I tested the script only on Windows XP.

Regards.
Masaru.

2009/10/18 masaru tsuchiyama <m....@gmail.com>:
> Hi.
>
> I added the feature to use external command instead of
> python bzip2 or gzip module.
>
> [[[
>   add two command line options, --bzip2-cmd and --gzip-cmd
>   to svn-backup-dumps.py
>
>   if --bzip2-cmd option is specified, the script use bzip2 command to
>   compress the dump stream instead of python bzip2 module.
>
>   if --gzip-cmd option is specified, the script use gzip command to
>   compress the dump stream instead of python gzip module.
>
>   * tools/server-side/svn-backup-dumps.py
>     (SvnBackupOutputCommand): add new class to launch external command to
>                               compress.
>     (SvnBackup.__init__): add two member variables, __bzip2_path and
>                           __gzip_path to hold command line parameters
>     (SvnBackup.create_dump): create instance of SvnBackupOutputCommand
>                              when __bzip2_path or __gzip_path is valid
>   ]]]
>
> Regards.
>

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2408639

Re: [PATCH] command line options to use external command to compress

Posted by masaru tsuchiyama <m....@gmail.com>.
Hi

2009/10/21 Senthil Kumaran S <se...@collab.net>:
> masaru tsuchiyama wrote:
>>
>> Oops. Fixed the bug.
[...]
>
> Committed in r40147, with minor formatting tweaks to wrap lines within 80
> columns and modified log message. Thanks for the patch.
>
> --
> Senthil Kumaran S
> http://www.stylesen.org/
>

Thanks.

Masaru.

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2409790

Re: [PATCH] command line options to use external command to compress

Posted by Senthil Kumaran S <se...@collab.net>.
masaru tsuchiyama wrote:
> 
> Oops. Fixed the bug.
> 
> [[[
>    add two command line options, --bzip2-cmd and --gzip-cmd
>    to svn-backup-dumps.py
> 
>    if --bzip2-cmd option is specified, the script uses bzip2 command to
>    compress the dump stream instead of python bzip2 module.
> 
>    if --gzip-cmd option is specified, the script uses gzip command to
>    compress the dump stream instead of python gzip module.
> 
>    * tools/server-side/svn-backup-dumps.py
>      (SvnBackupOutputCommand): add new class to launch external command to
>                                compress.
>      (SvnBackup.__init__): add two member variables, __bzip2_path and
>                            __gzip_path to hold command line parameters
>      (SvnBackup.__init__): add mutually exclusive checks for compress options.
>      (SvnBackup.create_dump): create instance of SvnBackupOutputCommand
>                               when __bzip2_path or __gzip_path is valid
>      (): fix command option help for "-b" and "-z" to distinguish from
>          --bzip2-cmd and --gzip-cmd option.
>      (): change parser.add_option parameters for -b and -z to
>          do mutually exclusive checks
>    ]]]

Committed in r40147, with minor formatting tweaks to wrap lines within 80
columns and modified log message. Thanks for the patch.

-- 
Senthil Kumaran S
http://www.stylesen.org/

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2409699

Re: [PATCH] command line options to use external command to compress

Posted by masaru tsuchiyama <m....@gmail.com>.
Hi.

> The patch looks good now, but there is another problem introduced as given
> below, please correct it and send your patch,
>
>> @@ -288,7 +315,25 @@
>>          self.__quiet = options.quiet
>>          self.__deltas = options.deltas
>>          self.__relative_incremental = options.relative_incremental
>> -        self.__zip = options.zip
>> +
>> +        # check compress option
>> +        self.__gzip_path  = options.gzip_path
>> +        self.__bzip2_path = options.bzip2_path
>> +        self.__zip        = None
>> +        compress_options  = 0
>> +        if options.gzip_path  != None:
>> +            compress_options = compress_options + 1
>> +        if options.bzip2_path != None:
>> +            compress_options = compress_options + 1
>> +        if options.bzip2:
>> +            compress_options = compress_options + 1
>> +            self.__zip = "gzip"
>> +        if options.gzip:
>> +            compress_options = compress_options + 1
>> +            self.__zip = "bzip2"

Oops. Fixed the bug.

[[[
   add two command line options, --bzip2-cmd and --gzip-cmd
   to svn-backup-dumps.py

   if --bzip2-cmd option is specified, the script uses bzip2 command to
   compress the dump stream instead of python bzip2 module.

   if --gzip-cmd option is specified, the script uses gzip command to
   compress the dump stream instead of python gzip module.

   * tools/server-side/svn-backup-dumps.py
     (SvnBackupOutputCommand): add new class to launch external command to
                               compress.
     (SvnBackup.__init__): add two member variables, __bzip2_path and
                           __gzip_path to hold command line parameters
     (SvnBackup.__init__): add mutually exclusive checks for compress options.
     (SvnBackup.create_dump): create instance of SvnBackupOutputCommand
                              when __bzip2_path or __gzip_path is valid
     (): fix command option help for "-b" and "-z" to distinguish from
         --bzip2-cmd and --gzip-cmd option.
     (): change parser.add_option parameters for -b and -z to
         do mutually exclusive checks
   ]]]


Regards.
Masaru.

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2409408

Re: [PATCH] command line options to use external command to compress

Posted by Senthil Kumaran S <se...@collab.net>.
Hi Masaru,

masaru tsuchiyama wrote:
> Hi.
> 
> Thank you for your feedback
> I fixed the patch.

The patch looks good now, but there is another problem introduced as given
below, please correct it and send your patch,

> @@ -288,7 +315,25 @@
>          self.__quiet = options.quiet
>          self.__deltas = options.deltas
>          self.__relative_incremental = options.relative_incremental
> -        self.__zip = options.zip
> +
> +        # check compress option
> +        self.__gzip_path  = options.gzip_path
> +        self.__bzip2_path = options.bzip2_path
> +        self.__zip        = None
> +        compress_options  = 0
> +        if options.gzip_path  != None:
> +            compress_options = compress_options + 1
> +        if options.bzip2_path != None:
> +            compress_options = compress_options + 1
> +        if options.bzip2:
> +            compress_options = compress_options + 1
> +            self.__zip = "gzip"
> +        if options.gzip:
> +            compress_options = compress_options + 1
> +            self.__zip = "bzip2"

In the above two if conditions, you assign 'self.__zip' exactly opposite
values, which results in the following kind of behaviour,

<snip>
$ ./tools/server-side/svn-backup-dumps.py -b /tmp/repos /tmp
writing /tmp/repos.000000-000000.svndmp.gz
* Dumped revision 0.

Everything OK.
$ ./tools/server-side/svn-backup-dumps.py -z /tmp/repos /tmp
writing /tmp/repos.000000-000000.svndmp.bz2
* Dumped revision 0.

Everything OK.
</snip>

Here for option '-b' a '.gz' and for '-z' a '.bz2' gets produced which should
be the other way.

Thank You.
-- 
Senthil Kumaran S
http://www.stylesen.org/

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2409254

Re: [PATCH] command line options to use external command to compress

Posted by masaru tsuchiyama <m....@gmail.com>.
Hi.

Thank you for your feedback
I fixed the patch.

[[[
   add two command line options, --bzip2-cmd and --gzip-cmd
   to svn-backup-dumps.py

   if --bzip2-cmd option is specified, the script uses bzip2 command to
   compress the dump stream instead of python bzip2 module.

   if --gzip-cmd option is specified, the script uses gzip command to
   compress the dump stream instead of python gzip module.

   * tools/server-side/svn-backup-dumps.py
     (SvnBackupOutputCommand): add new class to launch external command to
                               compress.
     (SvnBackup.__init__): add two member variables, __bzip2_path and
                           __gzip_path to hold command line parameters
     (SvnBackup.__init__): add mutually exclusive checks for compress options.
     (SvnBackup.create_dump): create instance of SvnBackupOutputCommand
                              when __bzip2_path or __gzip_path is valid
     (): fix command option help for "-b" and "-z" to distinguish from
         --bzip2-cmd and --gzip-cmd option.
     (): change parser.add_option parameters for -b and -z to
         do mutually exclusive checks
   ]]]

> I reviewed your patch which looks good. But before committing I want to have
> some changes,
>
> 1) In the usage message we have
>     -b                    compress the dump using bzip2.
>     --bzip2-path=BZIP2_PATH
>                           compress the dump using bzip2 command
>
> which is confusing. May be we can say 'compress the dump using python bzip2
>     library' for the former and 'compress the dump using bzip2 custom command'
> for the later?
> 2) Same thing applies for gzip command too.
>

added comments.

> 3) May be we can detect usage of -b and --bzip2-path together and say they are
> mutually exclusive? This is because, with the current patch if we give both,
> only --bzip2-path works and -b is silently ignored, which may confuse users.

added mutually exclusive check for compress options.

Regards.
Masaru.

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2408997

Re: [PATCH] command line options to use external command to compress

Posted by Senthil Kumaran S <se...@collab.net>.
Hi,

masaru tsuchiyama wrote:
> Hi.
> 
> I added the feature to use external command instead of
> python bzip2 or gzip module.
> 
> [[[
>    add two command line options, --bzip2-cmd and --gzip-cmd
>    to svn-backup-dumps.py
> 
>    if --bzip2-cmd option is specified, the script use bzip2 command to
>    compress the dump stream instead of python bzip2 module.
> 
>    if --gzip-cmd option is specified, the script use gzip command to
>    compress the dump stream instead of python gzip module.
> 
>    * tools/server-side/svn-backup-dumps.py
>      (SvnBackupOutputCommand): add new class to launch external command to
>                                compress.
>      (SvnBackup.__init__): add two member variables, __bzip2_path and
>                            __gzip_path to hold command line parameters
>      (SvnBackup.create_dump): create instance of SvnBackupOutputCommand
>                               when __bzip2_path or __gzip_path is valid
>    ]]]

I reviewed your patch which looks good. But before committing I want to have
some changes,

1) In the usage message we have
     -b                    compress the dump using bzip2.
     --bzip2-path=BZIP2_PATH
                           compress the dump using bzip2 command

which is confusing. May be we can say 'compress the dump using python bzip2
     library' for the former and 'compress the dump using bzip2 custom command'
for the later?

2) Same thing applies for gzip command too.

3) May be we can detect usage of -b and --bzip2-path together and say they are
mutually exclusive? This is because, with the current patch if we give both,
only --bzip2-path works and -b is silently ignored, which may confuse users.

Thank You.
-- 
Senthil Kumaran S
http://www.stylesen.org/

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2408921