public inbox for gentoo-portage-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-portage-dev@lists.gentoo.org
Cc: robbat2@gentoo.org, "Michał Górny" <mgorny@gentoo.org>
Subject: [gentoo-portage-dev] [PATCH 2/2] egencache --update-changelogs: Support reversing order
Date: Mon,  2 Nov 2015 22:46:26 +0100	[thread overview]
Message-ID: <1446500786-23199-2-git-send-email-mgorny@gentoo.org> (raw)
In-Reply-To: <1446500786-23199-1-git-send-email-mgorny@gentoo.org>

---
 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



  reply	other threads:[~2015-11-02 21:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-02 18:18 [gentoo-portage-dev] [PATCHES] egencache --update-changelogs: fixes for infra rsync Michał Górny
2015-11-02 18:18 ` [gentoo-portage-dev] [PATCH 1/4] egencache --update-changelogs: Support setting ChangeLog file name Michał Górny
2015-11-02 18:18 ` [gentoo-portage-dev] [PATCH 2/4] egencache --update-changelogs: Ignore all ChangeLog* files Michał Górny
2015-11-02 18:18 ` [gentoo-portage-dev] [PATCH 3/4] egencache --update-changelogs: Replace $Header$ with autogen note Michał Górny
2015-11-02 18:18 ` [gentoo-portage-dev] [PATCH 4/4] egencache --update-changelogs: Support reversing order Michał Górny
2015-11-02 19:18 ` [gentoo-portage-dev] [PATCHES] egencache --update-changelogs: fixes for infra rsync Zac Medico
2015-11-02 21:46   ` [gentoo-portage-dev] [PATCH 1/2] egencache --update-changelogs: Support setting ChangeLog file name Michał Górny
2015-11-02 21:46     ` Michał Górny [this message]
2015-11-02 23:05   ` [gentoo-portage-dev] [PATCHES] egencache --update-changelogs: fixes for infra rsync Alexander Berntsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1446500786-23199-2-git-send-email-mgorny@gentoo.org \
    --to=mgorny@gentoo.org \
    --cc=gentoo-portage-dev@lists.gentoo.org \
    --cc=robbat2@gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox