[SCM] Git repository for devscripts branch, master, updated. v2.12.4-177-gcbd1589
Benjamin Drung
bdrung at debian.org
Wed Mar 20 11:35:05 UTC 2013
The following commit has been merged in the master branch:
commit cbd15890e3ddf7dc6c5f135d3bd4e60903797bb6
Author: Benjamin Drung <bdrung at debian.org>
Date: Wed Mar 20 12:34:55 2013 +0100
wrap-and-sort: Add trailing comma option (Closes: #703323).
diff --git a/debian/changelog b/debian/changelog
index 5688248..e523126 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -14,6 +14,9 @@ devscripts (2.13.1) UNRELEASED; urgency=low
* debdiff: Handle control files with odd permissions. Thanks to Julian
Gilbey for the patch. (Closes: #702610)
+ [ Dmitrijs Ledkovs ]
+ * wrap-and-sort: Add trailing comma option (Closes: #703323).
+
-- Benjamin Drung <bdrung at debian.org> Tue, 19 Feb 2013 17:22:32 +0100
devscripts (2.13.0) experimental; urgency=low
diff --git a/doc/wrap-and-sort.1 b/doc/wrap-and-sort.1
index f277ff0..1eb4cea 100644
--- a/doc/wrap-and-sort.1
+++ b/doc/wrap-and-sort.1
@@ -55,6 +55,11 @@ configuration files are applied to the first package.
\fB\-n\fR, \fB\-\-no\-cleanup\fR
Do not remove trailing whitespaces.
.TP
+\fB\-t\fR, \fB\-\-trailing-comma\fR
+Add a trailing comma at the end of the sorted fields. This minimizes
+future differences in the VCS commits when additional dependencies are
+appended or removed.
+.TP
\fB\-d \fIpath\fR, \fB\-\-debian\-directory=\fIpath\fR
Location of the \fIdebian\fR directory (default: \fI./debian\fR).
.TP
diff --git a/scripts/wrap-and-sort b/scripts/wrap-and-sort
index fdff65f..444df74 100755
--- a/scripts/wrap-and-sort
+++ b/scripts/wrap-and-sort
@@ -50,15 +50,15 @@ SUPPORTED_FILES = (
class WrapAndSortControl(Control):
def wrap_and_sort(self, wrap_always, short_indent, sort_paragraphs,
- keep_first):
+ keep_first, trailing_comma):
for paragraph in self.paragraphs:
for field in CONTROL_LIST_FIELDS:
if field in paragraph:
self._wrap_field(paragraph, field, wrap_always,
- short_indent)
+ short_indent, trailing_comma)
if "Uploaders" in paragraph:
self._wrap_field(paragraph, "Uploaders", wrap_always,
- short_indent, False)
+ short_indent, trailing_comma, False)
if "Architecture" in paragraph:
archs = set(paragraph["Architecture"].split())
# Sort, with wildcard entries (such as linux-any) first:
@@ -71,7 +71,8 @@ class WrapAndSortControl(Control):
key = lambda x: x.get("Package")
self.paragraphs = first + sorted(sortable, key=key)
- def _wrap_field(self, control, entry, wrap_always, short_indent, sort=True):
+ def _wrap_field(self, control, entry, wrap_always, short_indent,
+ trailing_comma, sort=True):
packages = [x.strip() for x in control[entry].split(",")]
if sort:
# Remove duplicate entries
@@ -88,6 +89,8 @@ class WrapAndSortControl(Control):
indentation *= len(entry) + 2
packages_with_indention = [indentation + x for x in packages]
packages_with_indention = ",\n".join(packages_with_indention)
+ if trailing_comma:
+ packages_with_indention += ','
if short_indent:
control[entry] = "\n" + packages_with_indention
else:
@@ -142,7 +145,8 @@ def wrap_and_sort(options):
if options.cleanup:
control.strip_trailing_spaces()
control.wrap_and_sort(options.wrap_always, options.short_indent,
- options.sort_binary_packages, options.keep_first)
+ options.sort_binary_packages, options.keep_first,
+ options.trailing_comma)
control.save()
copyright_files = [f for f in options.files
@@ -194,6 +198,9 @@ def main():
dest="keep_first", action="store_true", default=False)
parser.add_option("-n", "--no-cleanup", help="don't cleanup whitespaces",
dest="cleanup", action="store_false", default=True)
+ parser.add_option("-t", "--trailing-comma", help="add trailing comma",
+ dest="trailing_comma", action="store_true",
+ default=False)
parser.add_option("-d", "--debian-directory", dest="debian_directory",
help="location of the 'debian' directory (default: "
"./debian)", metavar="PATH", default="debian")
--
Git repository for devscripts
More information about the devscripts-devel
mailing list