[gentoo-portage-dev] [PATCH 1/4] egencache --update-changelogs: Support setting ChangeLog file name

2015-11-02 Thread Michał Górny
---
 bin/egencache | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/bin/egencache b/bin/egencache
index 6407a44..11f49c6 100755
--- a/bin/egencache
+++ b/bin/egencache
@@ -170,6 +170,12 @@ def parse_args(args):
help="output file for use.local.desc data (or '-' for stdout)",
dest="uld_output")
 
+   uc = parser.add_argument_group('--update-changelogs options')
+   uc.add_argument("--changelog-output",
+   help="output filename for change logs",
+   dest="changelog_output",
+   default="ChangeLog")
+
options, args = parser.parse_known_args(args)
 
if options.jobs:
@@ -739,7 +745,7 @@ class _special_filename(_filename_base):
return self.file_name < other.file_name
 
 class GenChangeLogs(object):
-   def __init__(self, portdb):
+   def __init__(self, portdb, changelog_output):
self.returncode = os.EX_OK
self._portdb = portdb
self._wrapper = textwrap.TextWrapper(
@@ -747,6 +753,7 @@ class GenChangeLogs(object):
initial_indent = '  ',
subsequent_indent = '  '
)
+   self._changelog_output = changelog_output
 
@staticmethod
def grab(cmd):
@@ -756,7 +763,7 @@ class GenChangeLogs(object):
 
def generate_changelog(self, cp):
try:
-   output = io.open('ChangeLog',
+   output = io.open(self._changelog_output,
mode='w', encoding=_encodings['repo.content'],
errors='backslashreplace')
except IOError as e:
@@ -1132,7 +1139,8 @@ def egencache_main(args):
ret.append(gen_desc.returncode)
 
if options.update_changelogs:
-   gen_clogs = GenChangeLogs(portdb)
+   gen_clogs = GenChangeLogs(portdb,
+   changelog_output=options.changelog_output)
gen_clogs.run()
ret.append(gen_clogs.returncode)
 
-- 
2.6.2




[gentoo-portage-dev] [PATCH 4/4] egencache --update-changelogs: Support reversing order

2015-11-02 Thread Michał Górny
---
 bin/egencache | 15 ---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/bin/egencache b/bin/egencache
index 984d9f2..51d115a 100755
--- a/bin/egencache
+++ b/bin/egencache
@@ -171,6 +171,9 @@ def parse_args(args):
dest="uld_output")
 
uc = parser.add_argument_group('--update-changelogs options')
+   uc.add_argument("--changelog-reversed",
+   action="store_true",
+   help="log commits in reverse order (oldest first)")
uc.add_argument("--changelog-output",
help="output filename for change logs",
dest="changelog_output",
@@ -745,7 +748,7 @@ class _special_filename(_filename_base):
return self.file_name < other.file_name
 
 class GenChangeLogs(object):
-   def __init__(self, portdb, changelog_output):
+   def __init__(self, portdb, changelog_output, changelog_reversed):
self.returncode = os.EX_OK
self._portdb = portdb
self._wrapper = textwrap.TextWrapper(
@@ -754,6 +757,7 @@ class GenChangeLogs(object):
subsequent_indent = '  '
)
self._changelog_output = changelog_output
+   self._changelog_reversed = changelog_reversed
 
@staticmethod
def grab(cmd):
@@ -781,7 +785,11 @@ class GenChangeLogs(object):
''' % (cp, time.strftime('%Y'
 
# now grab all the commits
-   commits = self.grab(['git', 'rev-list', 'HEAD', '--', 
'.']).split()
+   revlist_cmd = ['git', 'rev-list']
+   if self._changelog_reversed:
+   revlist_cmd.append('--reverse')
+   revlist_cmd.extend(['HEAD', '--', '.'])
+   commits = self.grab(revlist_cmd).split()
 
for c in commits:
# Explaining the arguments:
@@ -1140,7 +1148,8 @@ def egencache_main(args):
 
if options.update_changelogs:
gen_clogs = GenChangeLogs(portdb,
-   changelog_output=options.changelog_output)
+   changelog_output=options.changelog_output,
+   changelog_reversed=options.changelog_reversed)
gen_clogs.run()
ret.append(gen_clogs.returncode)
 
-- 
2.6.2




[gentoo-portage-dev] [PATCHES] egencache --update-changelogs: fixes for infra rsync

2015-11-02 Thread Michał Górny
Hi,

A quick batch of patches fulfilling Infra requests needed for ChangeLog
generation on rsync mirrors and fixing some minor issues.

--
Best regards,
Michał Górny




[gentoo-portage-dev] [PATCH 2/4] egencache --update-changelogs: Ignore all ChangeLog* files

2015-11-02 Thread Michał Górny
---
 bin/egencache | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bin/egencache b/bin/egencache
index 11f49c6..f3eaa5c 100755
--- a/bin/egencache
+++ b/bin/egencache
@@ -816,7 +816,7 @@ class GenChangeLogs(object):
f = l.split()
if f[1] == 'Manifest':
pass # XXX: remanifest commits?
-   elif f[1] == 'ChangeLog':
+   elif f[1].startswith('ChangeLog'):
pass
elif f[0].startswith('A'):

changed.append(_special_filename("+", f[1]))
-- 
2.6.2




[gentoo-portage-dev] [PATCH 3/4] egencache --update-changelogs: Replace $Header$ with autogen note

2015-11-02 Thread Michał Górny
---
 bin/egencache | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bin/egencache b/bin/egencache
index f3eaa5c..984d9f2 100755
--- a/bin/egencache
+++ b/bin/egencache
@@ -776,7 +776,7 @@ class GenChangeLogs(object):
output.write(textwrap.dedent('''\
# ChangeLog for %s
# Copyright 1999-%s Gentoo Foundation; Distributed 
under the GPL v2
-   # $Header: $
+   # (auto-generated from git log)
 
''' % (cp, time.strftime('%Y'
 
-- 
2.6.2




Re: [gentoo-portage-dev] [PATCHES] egencache --update-changelogs: fixes for infra rsync

2015-11-02 Thread Zac Medico
On 11/02/2015 10:18 AM, Michał Górny wrote:
> Hi,
> 
> A quick batch of patches fulfilling Infra requests needed for ChangeLog
> generation on rsync mirrors and fixing some minor issues.
> 
> --
> Best regards,
> Michał Górny
> 
> 

The whole series looks good, except it's missing updates to man/egencache.1.
-- 
Thanks,
Zac



Re: [gentoo-portage-dev] [PATCH] xpak-helper: rewrite to rely more on argparse

2015-11-02 Thread Zac Medico
On 11/02/2015 09:06 AM, Zac Medico wrote:
> On 11/02/2015 08:52 AM, Mike Frysinger wrote:
>> On 01 Nov 2015 09:36, Zac Medico wrote:
>>> In order to handle python3 with arguments containing UTF-8 characters
>>> (in ${PKGDIR}) and a mis-matched sys.getfilesystemencoding() value, it's
>>> safest to decode the arguments like chmod-lite.py does.
>>
>> it seems wrong that we have incomplete coverage here.
>> some tools do it and some do not.
> 
> Yeah, complete coverage would be nice. Most if not all of the python
> helpers that are called from the ebuild environment already use this
> method to decode filename arguments (dohtml.py was only fixed recently,
> for bug 561846).
> 
>>> We should create
>>> a function for this code which is also duplicated in install.py:
>>
>> you mean portage._decode_argv ?
> 
> Yes, I forgot about that function.
> 
>> what if we create a new module like "commandline" that provides an
>> ArgumentParser interface that takes care of this for us ?
>> -mike
> 
> That sounds good. After it decodes the arguments, it should decode them
> as UTF-8 with errors='strict', and exit the program immediately if it
> triggers a UnicodeDecodeError.
> 

I mean, after it _encodes_ them with surrogateescape, it should
immediately decode them as UTF-8 with errors='strict'. That way, we'll
have unicode strings to pass to argparse (we don't want to pass raw
bytes to argparse).
-- 
Thanks,
Zac



Re: [gentoo-portage-dev] [PATCH] xpak-helper: rewrite to rely more on argparse

2015-11-02 Thread Mike Frysinger
On 01 Nov 2015 09:36, Zac Medico wrote:
> On 10/31/2015 10:23 PM, Mike Frysinger wrote:
> > The current code implements a lot of ad-hoc argument parsing when it
> > could simply let the argparse module do it all for it.  This makes the
> > code easier to understand and extend in the process.
> > ---
> >  bin/xpak-helper.py | 68 
> > --
> >  1 file changed, 25 insertions(+), 43 deletions(-)
> > 
> > diff --git a/bin/xpak-helper.py b/bin/xpak-helper.py
> > index 8c965ec..1b2883d 100755
> > --- a/bin/xpak-helper.py
> > +++ b/bin/xpak-helper.py
> [snip]
> > -def main(argv):
> >  
> > -   if argv and isinstance(argv[0], bytes):
> > -   for i, x in enumerate(argv):
> > -   argv[i] = portage._unicode_decode(x, errors='strict')
> 
> You've dropped the _unicode_decode call.

i did on purpose.  i should have mentioned that.

> In order to handle python3 with arguments containing UTF-8 characters
> (in ${PKGDIR}) and a mis-matched sys.getfilesystemencoding() value, it's
> safest to decode the arguments like chmod-lite.py does.

it seems wrong that we have incomplete coverage here.
some tools do it and some do not.

> We should create
> a function for this code which is also duplicated in install.py:

you mean portage._decode_argv ?

what if we create a new module like "commandline" that provides an
ArgumentParser interface that takes care of this for us ?
-mike


signature.asc
Description: Digital signature


Re: [gentoo-portage-dev] [PATCH] xpak-helper: rewrite to rely more on argparse

2015-11-02 Thread Zac Medico
On 11/02/2015 08:52 AM, Mike Frysinger wrote:
> On 01 Nov 2015 09:36, Zac Medico wrote:
>> In order to handle python3 with arguments containing UTF-8 characters
>> (in ${PKGDIR}) and a mis-matched sys.getfilesystemencoding() value, it's
>> safest to decode the arguments like chmod-lite.py does.
> 
> it seems wrong that we have incomplete coverage here.
> some tools do it and some do not.

Yeah, complete coverage would be nice. Most if not all of the python
helpers that are called from the ebuild environment already use this
method to decode filename arguments (dohtml.py was only fixed recently,
for bug 561846).

>> We should create
>> a function for this code which is also duplicated in install.py:
> 
> you mean portage._decode_argv ?

Yes, I forgot about that function.

> what if we create a new module like "commandline" that provides an
> ArgumentParser interface that takes care of this for us ?
> -mike

That sounds good. After it decodes the arguments, it should decode them
as UTF-8 with errors='strict', and exit the program immediately if it
triggers a UnicodeDecodeError.
-- 
Thanks,
Zac



[gentoo-portage-dev] [PATCH 2/2] egencache --update-changelogs: Support reversing order

2015-11-02 Thread Michał Górny
---
 bin/egencache   | 15 ---
 man/egencache.1 |  4 
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/bin/egencache b/bin/egencache
index 984d9f2..51d115a 100755
--- a/bin/egencache
+++ b/bin/egencache
@@ -171,6 +171,9 @@ def parse_args(args):
dest="uld_output")
 
uc = parser.add_argument_group('--update-changelogs options')
+   uc.add_argument("--changelog-reversed",
+   action="store_true",
+   help="log commits in reverse order (oldest first)")
uc.add_argument("--changelog-output",
help="output filename for change logs",
dest="changelog_output",
@@ -745,7 +748,7 @@ class _special_filename(_filename_base):
return self.file_name < other.file_name
 
 class GenChangeLogs(object):
-   def __init__(self, portdb, changelog_output):
+   def __init__(self, portdb, changelog_output, changelog_reversed):
self.returncode = os.EX_OK
self._portdb = portdb
self._wrapper = textwrap.TextWrapper(
@@ -754,6 +757,7 @@ class GenChangeLogs(object):
subsequent_indent = '  '
)
self._changelog_output = changelog_output
+   self._changelog_reversed = changelog_reversed
 
@staticmethod
def grab(cmd):
@@ -781,7 +785,11 @@ class GenChangeLogs(object):
''' % (cp, time.strftime('%Y'
 
# now grab all the commits
-   commits = self.grab(['git', 'rev-list', 'HEAD', '--', 
'.']).split()
+   revlist_cmd = ['git', 'rev-list']
+   if self._changelog_reversed:
+   revlist_cmd.append('--reverse')
+   revlist_cmd.extend(['HEAD', '--', '.'])
+   commits = self.grab(revlist_cmd).split()
 
for c in commits:
# Explaining the arguments:
@@ -1140,7 +1148,8 @@ def egencache_main(args):
 
if options.update_changelogs:
gen_clogs = GenChangeLogs(portdb,
-   changelog_output=options.changelog_output)
+   changelog_output=options.changelog_output,
+   changelog_reversed=options.changelog_reversed)
gen_clogs.run()
ret.append(gen_clogs.returncode)
 
diff --git a/man/egencache.1 b/man/egencache.1
index b4a95b3..2465ddf 100644
--- a/man/egencache.1
+++ b/man/egencache.1
@@ -46,6 +46,10 @@ the package directories.
 .br
 Defaults to ChangeLog.
 .TP
+.BR "\-\-changelog\-reversed"
+Reverses the commit order in ChangeLogs. The oldest commits are output
+first, the newest last.
+.TP
 .BR "\-\-config\-root=PORTAGE_CONFIGROOT"
 Location of portage config files.
 .br
-- 
2.6.2




Re: [gentoo-portage-dev] [PATCHES] egencache --update-changelogs: fixes for infra rsync

2015-11-02 Thread Alexander Berntsen
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA512

On 02/11/15 20:18, Zac Medico wrote:
> The whole series looks good, except it's missing updates to 
> man/egencache.1.
This was my main feedback as well. LGTM now.

- -- 
Alexander
berna...@gentoo.org
https://secure.plaimi.net/~alexander
-BEGIN PGP SIGNATURE-
Version: GnuPG v2

iQIcBAEBCgAGBQJWN+xHAAoJENQqWdRUGk8BsiEQAItn7kXGuNGi3gFF1eEYcDcO
w8l5kQwU964T7xgwzKSdUJpTwli36AmcCDXL+yL/zsCysSi9tUwSHiKCieKpRbnf
+IN2jZ0us79QJ8uJXB+R/bxG2kNkAu/e0Gv9xrcAdQe92+IjZymWN6EfDVOjm/A/
Un/lvscXfTsb2D9WAKIEM1QeSCmuUtKAuMecOTCxBJ7YBohZoeFNVVz5WDpw9AzY
vZMfZXK/pyZKKyYxuaNip/qi7ve7BEtSTrfNqXngY3Xpy/QLTYTETo2JgCbHflC/
gLu6IjPGYMW98oMEBDV9hVcyaYV2ppnB2QhJpvPgfHGlf0w0dqyr/rZKShaO597v
zBzVsaXsxtBSn+ITxHlkl90v7zEv68lM4MdGkqWEqXFVvFHQvQlsqRnaMlXkFgPv
t98q+C6wB8Q7RghOKdN3wjvmziMVApdiQ1H7vKI7PokG9ICiWPZcf9ZlM7X7VI2N
xWvFL0VAkbTebWJX2lP6pckSNJKKB7n9ahPXz5ph3J9ycNOYcnEOyOqvhxO2M2GD
lFkAi/0u7PnqFqdjB+0SNHbsv+KJpIf1aLbzKumfcIHrpSngemRFqL89Yzfht48D
YN3D9WKAn4gZ8uFJR2rveDZeZrQqyUmnF4PXKW2NdjR1zpWfj+Sd3/hOApQpPlms
NVOzT1Y8Cl8z0rWO03xV
=bTSu
-END PGP SIGNATURE-