From 02c770b4e416e81429e9809b16d2656141a3e61c Mon Sep 17 00:00:00 2001 From: AKASHI Takahiro Date: Mon, 27 Apr 2020 13:22:17 +0900 Subject: sandbox: drop CONFIG_SYS_RELOC_GD_ENV_ADDR As we discussed in [1], this option is not needed for sandbox build. [1] https://lists.denx.de/pipermail/u-boot/2020-February/400182.html Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass --- configs/sandbox64_defconfig | 1 - configs/sandbox_defconfig | 1 - configs/sandbox_flattree_defconfig | 1 - configs/sandbox_spl_defconfig | 1 - 4 files changed, 4 deletions(-) diff --git a/configs/sandbox64_defconfig b/configs/sandbox64_defconfig index c1237ea296..a3f049e124 100644 --- a/configs/sandbox64_defconfig +++ b/configs/sandbox64_defconfig @@ -80,7 +80,6 @@ CONFIG_OF_CONTROL=y CONFIG_OF_LIVE=y CONFIG_OF_HOSTFILE=y CONFIG_DEFAULT_DEVICE_TREE="sandbox64" -CONFIG_SYS_RELOC_GD_ENV_ADDR=y CONFIG_NETCONSOLE=y CONFIG_IP_DEFRAG=y CONFIG_REGMAP=y diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig index 9445d78118..c09bf33493 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -89,7 +89,6 @@ CONFIG_OF_CONTROL=y CONFIG_OF_LIVE=y CONFIG_OF_HOSTFILE=y CONFIG_DEFAULT_DEVICE_TREE="sandbox" -CONFIG_SYS_RELOC_GD_ENV_ADDR=y CONFIG_NETCONSOLE=y CONFIG_IP_DEFRAG=y CONFIG_REGMAP=y diff --git a/configs/sandbox_flattree_defconfig b/configs/sandbox_flattree_defconfig index a4a7ae8379..21f9047046 100644 --- a/configs/sandbox_flattree_defconfig +++ b/configs/sandbox_flattree_defconfig @@ -63,7 +63,6 @@ CONFIG_AMIGA_PARTITION=y CONFIG_OF_CONTROL=y CONFIG_OF_HOSTFILE=y CONFIG_DEFAULT_DEVICE_TREE="sandbox" -CONFIG_SYS_RELOC_GD_ENV_ADDR=y CONFIG_NETCONSOLE=y CONFIG_IP_DEFRAG=y CONFIG_REGMAP=y diff --git a/configs/sandbox_spl_defconfig b/configs/sandbox_spl_defconfig index 945fe54d20..fc8b26e88c 100644 --- a/configs/sandbox_spl_defconfig +++ b/configs/sandbox_spl_defconfig @@ -79,7 +79,6 @@ CONFIG_SPL_OF_CONTROL=y CONFIG_OF_HOSTFILE=y CONFIG_DEFAULT_DEVICE_TREE="sandbox" CONFIG_SPL_OF_PLATDATA=y -CONFIG_SYS_RELOC_GD_ENV_ADDR=y CONFIG_NETCONSOLE=y CONFIG_IP_DEFRAG=y CONFIG_SPL_DM=y -- cgit From 5e61c4e89d252e7d909d0129682ea48516912e6c Mon Sep 17 00:00:00 2001 From: AKASHI Takahiro Date: Mon, 27 Apr 2020 15:46:45 +0900 Subject: sandbox: update documents regarding spi_sf Since the commit 1289e96797bf ("sandbox: spi: Drop command-line SPI option"), "--spi_sf" command line option is no longer supported. So update the following documents to sync them up with the change. doc/arch/sandbox.rst doc/SPI/README.sandbox-spi Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass --- doc/SPI/README.sandbox-spi | 58 ++++++++++++++-------------------------------- doc/arch/sandbox.rst | 52 ++++++++++++++++++----------------------- 2 files changed, 41 insertions(+), 69 deletions(-) diff --git a/doc/SPI/README.sandbox-spi b/doc/SPI/README.sandbox-spi index dfa845cc82..f6a55fe780 100644 --- a/doc/SPI/README.sandbox-spi +++ b/doc/SPI/README.sandbox-spi @@ -2,59 +2,37 @@ Sandbox SPI/SPI Flash Implementation ==================================== U-Boot supports SPI and SPI flash emulation in sandbox. This must be enabled -using the --spi_sf paramter when starting U-Boot. +via a device tree. For example: -$ make O=sandbox sandbox_config -$ make O=sandbox -$ ./sandbox/u-boot --spi_sf 0:0:W25Q128:b/chromeos_peach/out/image.bin - -The four parameters to spi_sf are: - - SPI bus number (typically 0) - SPI chip select number (typically 0) - SPI chip to emulate - File containing emulated data + spi@0 { + #address-cells = <1>; + #size-cells = <0>; + reg = <0 1>; + compatible = "sandbox,spi"; + cs-gpios = <0>, <&gpio_a 0>; + spi.bin@0 { + reg = <0>; + compatible = "spansion,m25p16", "jedec,spi-nor"; + spi-max-frequency = <40000000>; + sandbox,filename = "spi.bin"; + }; + }; Supported chips are W25Q16 (2MB), W25Q32 (4MB) and W25Q128 (16MB). Once U-Boot it started you can use 'sf' commands as normal. For example: -$ ./b/sandbox/u-boot --spi_sf 0:0:W25Q128:b/chromeos_peach/out/image.bin \ - -c "sf probe; sf test 0 100000; sf read 0 1000 1000; \ - sf erase 1000 1000; sf write 0 1000 1000" - - -U-Boot 2013.10-00237-gd4e0fdb (Nov 07 2013 - 20:08:15) - -DRAM: 128 MiB -Using default environment - -In: serial -Out: serial -Err: serial -SF: Detected W25Q128BV with page size 256 Bytes, erase size 4 KiB, total 16 MiB -SPI flash test: -0 erase: 1 ticks, 1024000 KiB/s 8192.000 Mbps -1 check: 2 ticks, 512000 KiB/s 4096.000 Mbps -2 write: 6 ticks, 170666 KiB/s 1365.328 Mbps -3 read: 0 ticks, 1048576000 KiB/s -201326.-592 Mbps -Test passed -0 erase: 1 ticks, 1024000 KiB/s 8192.000 Mbps -1 check: 2 ticks, 512000 KiB/s 4096.000 Mbps -2 write: 6 ticks, 170666 KiB/s 1365.328 Mbps -3 read: 0 ticks, 1048576000 KiB/s -201326.-592 Mbps -SF: 4096 bytes @ 0x1000 Read: OK -SF: 4096 bytes @ 0x1000 Erased: OK -SF: 4096 bytes @ 0x1000 Written: OK - +$ dd if=/dev/zero of=spi.bin bs=1M count=2 +$ u-boot -T Since the SPI bus is fully implemented as well as the SPI flash connected to it, you can also use low-level SPI commands to access the flash. For example this reads the device ID from the emulated chip: => sspi 0 32 9f -FFEF4018 +SF: Detected m25p16 with page size 256 Bytes, erase size 64 KiB, total 2 MiB +FF202015 Simon Glass diff --git a/doc/arch/sandbox.rst b/doc/arch/sandbox.rst index 6a1c6fc552..360f22461a 100644 --- a/doc/arch/sandbox.rst +++ b/doc/arch/sandbox.rst @@ -316,19 +316,29 @@ SPI Emulation Sandbox supports SPI and SPI flash emulation. -This is controlled by the spi_sf argument, the format of which is:: - - bus:cs:device:file - - bus - SPI bus number - cs - SPI chip select number - device - SPI device emulation name - file - File on disk containing the data - -For example:: - - dd if=/dev/zero of=spi.bin bs=1M count=4 - ./u-boot --spi_sf 0:0:M25P16:spi.bin +The device can be enabled via a device tree, for example:: + + spi@0 { + #address-cells = <1>; + #size-cells = <0>; + reg = <0 1>; + compatible = "sandbox,spi"; + cs-gpios = <0>, <&gpio_a 0>; + spi.bin@0 { + reg = <0>; + compatible = "spansion,m25p16", "jedec,spi-nor"; + spi-max-frequency = <40000000>; + sandbox,filename = "spi.bin"; + }; + }; + +The file must be created in advance:: + + $ dd if=/dev/zero of=spi.bin bs=1M count=2 + $ u-boot -T + +Here, you can use "-T" or "-D" option to specify test.dtb or u-boot.dtb, +respectively, or "-d " for your own dtb. With this setup you can issue SPI flash commands as normal:: @@ -346,22 +356,6 @@ also use low-level SPI commands:: This is issuing a READ_ID command and getting back 20 (ST Micro) part 0x2015 (the M25P16). -Drivers are connected to a particular bus/cs using sandbox's state -structure (see the 'spi' member). A set of operations must be provided -for each driver. - - -Configuration settings for the curious are: - -CONFIG_SANDBOX_SPI_MAX_BUS: - The maximum number of SPI buses supported by the driver (default 1). - -CONFIG_SANDBOX_SPI_MAX_CS: - The maximum number of chip selects supported by the driver (default 10). - -CONFIG_SPI_IDLE_VAL: - The idle value on the SPI bus - Block Device Emulation ---------------------- -- cgit From 979afd14c3e29dedcc020a49f59d6cb28124f038 Mon Sep 17 00:00:00 2001 From: Stefan Roese Date: Wed, 29 Apr 2020 09:08:44 +0200 Subject: dm: core: Reorder include files in read.c Including the assembler headers before including common.h etc leads to compilation errors upon MIPS64 based platforms using OF_LIVE. This patch reorders the include files to the "correct" oder. Signed-off-by: Stefan Roese Cc: Simon Glass Reviewed-by: Simon Glass --- drivers/core/read.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/core/read.c b/drivers/core/read.c index 3d421f7a69..047089c886 100644 --- a/drivers/core/read.c +++ b/drivers/core/read.c @@ -4,12 +4,12 @@ * Written by Simon Glass */ -#include -#include #include #include -#include #include +#include +#include +#include int dev_read_u32(const struct udevice *dev, const char *propname, u32 *outp) { -- cgit From 0fc01bf826036698a8d0eb8405e832a6a759472e Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Mon, 4 May 2020 00:52:43 -0700 Subject: patman: Sort the command line options Sort the existing command line options by: - help comes first - option starts with '-' - option starts with '--' Lower case followed by upper case letters, in alphabetical order. Signed-off-by: Bin Meng Reviewed-by: Simon Glass --- tools/patman/main.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/patman/main.py b/tools/patman/main.py index f3d9c0c434..72c67b8bbd 100755 --- a/tools/patman/main.py +++ b/tools/patman/main.py @@ -36,11 +36,11 @@ parser.add_option('-c', '--count', dest='count', type='int', parser.add_option('-i', '--ignore-errors', action='store_true', dest='ignore_errors', default=False, help='Send patches email even if patch errors are found') +parser.add_option('-l', '--limit-cc', dest='limit', type='int', + default=None, help='Limit the cc list to LIMIT entries [default: %default]') parser.add_option('-m', '--no-maintainers', action='store_false', dest='add_maintainers', default=True, help="Don't cc the file maintainers automatically") -parser.add_option('-l', '--limit-cc', dest='limit', type='int', - default=None, help='Limit the cc list to LIMIT entries [default: %default]') parser.add_option('-n', '--dry-run', action='store_true', dest='dry_run', default=False, help="Do a dry run (create but don't email patches)") parser.add_option('-p', '--project', default=project.DetectProject(), @@ -52,10 +52,10 @@ parser.add_option('-s', '--start', dest='start', type='int', default=0, help='Commit to start creating patches from (0 = HEAD)') parser.add_option('-t', '--ignore-bad-tags', action='store_true', default=False, help='Ignore bad tags / aliases') -parser.add_option('--test', action='store_true', dest='test', - default=False, help='run tests') parser.add_option('-v', '--verbose', action='store_true', dest='verbose', default=False, help='Verbose output of errors and warnings') +parser.add_option('-T', '--thread', action='store_true', dest='thread', + default=False, help='Create patches as a single thread') parser.add_option('--cc-cmd', dest='cc_cmd', type='string', action='store', default=None, help='Output cc list for patch file (used by git)') parser.add_option('--no-check', action='store_false', dest='check_patch', @@ -65,8 +65,8 @@ parser.add_option('--no-tags', action='store_false', dest='process_tags', default=True, help="Don't process subject tags as aliaes") parser.add_option('--smtp-server', type='str', help="Specify the SMTP server to 'git send-email'") -parser.add_option('-T', '--thread', action='store_true', dest='thread', - default=False, help='Create patches as a single thread') +parser.add_option('--test', action='store_true', dest='test', + default=False, help='run tests') parser.usage += """ -- cgit From 14aa35ad551b3d35a5c7ba8871eb67bd05f1f9b0 Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Mon, 4 May 2020 00:52:44 -0700 Subject: patman: Add an option to create patches without binary contents Some mailing lists have size limits and when we add binary contents to our patches it's easy to exceed the size limits. Git supports a command line option "--no-binary" to generate patches without any binary contents. Add an option in patman to handle this. Note with this option patches cannot be applied properly, but they are still useful for code review. Signed-off-by: Bin Meng Reviewed-by: Simon Glass --- tools/patman/README | 5 +++++ tools/patman/gitutil.py | 4 +++- tools/patman/main.py | 5 ++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/tools/patman/README b/tools/patman/README index 02d5829744..f40defb5ba 100644 --- a/tools/patman/README +++ b/tools/patman/README @@ -474,6 +474,11 @@ print out the command line patman would have used. not later when you can't remember which patch you changed. You can always go back and change or remove logs from commits. +7. Some mailing lists have size limits and when we add binary contents to +our patches it's easy to exceed the size limits. Use "--no-binary" to +generate patches without any binary contents. You are supposed to include +a link to a git repository in your "Commit-notes", "Series-notes" or +"Cover-letter" for maintainers to fetch the original commit. Other thoughts ============== diff --git a/tools/patman/gitutil.py b/tools/patman/gitutil.py index 770a051014..72fc95d558 100644 --- a/tools/patman/gitutil.py +++ b/tools/patman/gitutil.py @@ -254,7 +254,7 @@ def Fetch(git_dir=None, work_tree=None): if result.return_code != 0: raise OSError('git fetch: %s' % result.stderr) -def CreatePatches(start, count, series): +def CreatePatches(start, count, ignore_binary, series): """Create a series of patches from the top of the current branch. The patch files are written to the current directory using @@ -270,6 +270,8 @@ def CreatePatches(start, count, series): if series.get('version'): version = '%s ' % series['version'] cmd = ['git', 'format-patch', '-M', '--signoff'] + if ignore_binary: + cmd.append('--no-binary') if series.get('cover'): cmd.append('--cover-letter') prefix = series.GetPatchPrefix() diff --git a/tools/patman/main.py b/tools/patman/main.py index 72c67b8bbd..29518361e5 100755 --- a/tools/patman/main.py +++ b/tools/patman/main.py @@ -58,6 +58,9 @@ parser.add_option('-T', '--thread', action='store_true', dest='thread', default=False, help='Create patches as a single thread') parser.add_option('--cc-cmd', dest='cc_cmd', type='string', action='store', default=None, help='Output cc list for patch file (used by git)') +parser.add_option('--no-binary', action='store_true', dest='ignore_binary', + default=False, + help="Do not output contents of changes in binary files") parser.add_option('--no-check', action='store_false', dest='check_patch', default=True, help="Don't check for patch compliance") @@ -144,7 +147,7 @@ else: if options.count: series = patchstream.GetMetaData(options.start, options.count) cover_fname, args = gitutil.CreatePatches(options.start, options.count, - series) + options.ignore_binary, series) # Fix up the patch files to our liking, and insert the cover letter patchstream.FixPatches(series, args) -- cgit From b0436b94047caf4c2ec67b599581198317f395b1 Mon Sep 17 00:00:00 2001 From: Sean Anderson Date: Mon, 4 May 2020 16:28:33 -0400 Subject: patman: Suppress empty changelog entries Patman outputs a line for every edition of the series in every patch, regardless of whether any changes were made. This can result in many redundant lines in patch changelogs, especially when a patch did not exist before a certain revision. For example, the existing behaviour could result in a changelog of Changes in v7: None Changes in v6: None Changes in v5: - Make a change Changes in v4: None Changes in v3: - New Changes in v2: None With this patch applied and with --no-empty-changes, the same patch would look like (no changes since v5) Changes in v5: - Make a change Changes in v3: - New This is entirely aesthetic, but I think it reduces clutter, especially for patches added later on in a series. Signed-off-by: Sean Anderson Reviewed-by: Simon Glass --- tools/patman/README | 22 ++++++++++++++++++++++ tools/patman/series.py | 43 +++++++++++++++++++++++++++++++------------ 2 files changed, 53 insertions(+), 12 deletions(-) diff --git a/tools/patman/README b/tools/patman/README index f40defb5ba..092122f3db 100644 --- a/tools/patman/README +++ b/tools/patman/README @@ -480,6 +480,28 @@ generate patches without any binary contents. You are supposed to include a link to a git repository in your "Commit-notes", "Series-notes" or "Cover-letter" for maintainers to fetch the original commit. +8. Patches will have no changelog entries for revisions where they did not +change. For clarity, if there are no changes for this patch in the most +recent revision of the series, a note will be added. For example, a patch +with the following tags in the commit + + Series-version: 5 + Series-changes: 2 + - Some change + + Series-changes: 4 + - Another change + +would have a changelog of + + (no changes since v4) + + Changes in v4: + - Another change + + Changes in v2: + - Some change + Other thoughts ============== diff --git a/tools/patman/series.py b/tools/patman/series.py index e5e28cebdf..be6f061122 100644 --- a/tools/patman/series.py +++ b/tools/patman/series.py @@ -144,38 +144,57 @@ class Series(dict): Changes in v4: - Jog the dial back closer to the widget - Changes in v3: None Changes in v2: - Fix the widget - Jog the dial - etc. + If there are no new changes in a patch, a note will be added + + (no changes since v2) + + Changes in v2: + - Fix the widget + - Jog the dial """ + versions = sorted(self.changes, reverse=True) + newest_version = 1 + if 'version' in self: + newest_version = max(newest_version, int(self.version)) + if versions: + newest_version = max(newest_version, versions[0]) + final = [] process_it = self.get('process_log', '').split(',') process_it = [item.strip() for item in process_it] need_blank = False - for change in sorted(self.changes, reverse=True): + for version in versions: out = [] - for this_commit, text in self.changes[change]: + for this_commit, text in self.changes[version]: if commit and this_commit != commit: continue if 'uniq' not in process_it or text not in out: out.append(text) - line = 'Changes in v%d:' % change - have_changes = len(out) > 0 if 'sort' in process_it: out = sorted(out) + have_changes = len(out) > 0 + line = 'Changes in v%d:' % version if have_changes: out.insert(0, line) - else: - out = [line + ' None'] - if need_blank: - out.insert(0, '') + if version < newest_version and len(final) == 0: + out.insert(0, '') + out.insert(0, '(no changes since v%d)' % version) + newest_version = 0 + # Only add a new line if we output something + if need_blank: + out.insert(0, '') + need_blank = False final += out - need_blank = have_changes - if self.changes: + need_blank = need_blank or have_changes + + if len(final) > 0: final.append('') + elif newest_version != 1: + final = ['(no changes since v1)', ''] return final def DoChecks(self): -- cgit From 6949f70c6d3e1cd4b93cafb8759e333a2e5a7f1e Mon Sep 17 00:00:00 2001 From: Sean Anderson Date: Mon, 4 May 2020 16:28:34 -0400 Subject: patman: Add new tags for finer-grained changelog control By default patman generates a combined changelog for the cover letter. This may not always be desirable. Many patches may have the same changes. These can be coalesced with "Series-process-log: uniq", but this is imperfect. Similar changes like "Move foo to patch 7" will not be merged with the similar "Move foo to this patch from patch 6". Changes may not make sense outside of the patch they are written for. For example, a change line of "Add check for bar" does not make sense outside of the context in which bar might be checked for. Some changes like "New" or "Lint" may be repeated many times throughout different change logs, but carry no useful information in a summary. Lastly, I like to summarize the broad strokes of the changes I have made in the cover letter, while documenting all the details in the appropriate patches. I think this makes it easier to get a good feel for what has changed, without making it difficult to wade through every change in the whole series. This patch adds two new tags to add changelog entries which only appear in the cover letter, or only appear in the commit. Changes documented with "Commit-changes" will only appear in the commit, and will not appear in the cover letter. Changes documented with "Cover-changes" will not appear in any commit, and will only appear in the cover letter. Signed-off-by: Sean Anderson Reviewed-by: Simon Glass --- tools/patman/README | 17 ++++++++++ tools/patman/main.py | 2 +- tools/patman/patchstream.py | 81 +++++++++++++++++++++++++++++---------------- tools/patman/series.py | 15 +++++++-- 4 files changed, 83 insertions(+), 32 deletions(-) diff --git a/tools/patman/README b/tools/patman/README index 092122f3db..a99a68c6d5 100644 --- a/tools/patman/README +++ b/tools/patman/README @@ -247,6 +247,23 @@ Series-changes: n to update the log there and then, knowing that the script will do the rest. +Commit-changes: n +- This line will not appear in the cover-letter changelog + + This tag is like Series-changes, except changes in this changelog will + only appear in the changelog of the commit this tag is in. This is + useful when you want to add notes which may not make sense in the cover + letter. For example, you can have short changes such as "New" or + "Lint". + +Cover-changes: n +- This line will only appear in the cover letter + + This tag is like Series-changes, except changes in this changelog will + only appear in the cover-letter changelog. This is useful to summarize + changes made with Commit-changes, or to add additional context to + changes. + Patch-cc: Their Name This copies a single patch to another email address. Note that the Cc: used by git send-email is ignored by patman, but will be diff --git a/tools/patman/main.py b/tools/patman/main.py index 29518361e5..0974c84059 100755 --- a/tools/patman/main.py +++ b/tools/patman/main.py @@ -65,7 +65,7 @@ parser.add_option('--no-check', action='store_false', dest='check_patch', default=True, help="Don't check for patch compliance") parser.add_option('--no-tags', action='store_false', dest='process_tags', - default=True, help="Don't process subject tags as aliaes") + default=True, help="Don't process subject tags as aliases") parser.add_option('--smtp-server', type='str', help="Specify the SMTP server to 'git send-email'") parser.add_option('--test', action='store_true', dest='test', diff --git a/tools/patman/patchstream.py b/tools/patman/patchstream.py index 405297505c..871c66aeb1 100644 --- a/tools/patman/patchstream.py +++ b/tools/patman/patchstream.py @@ -24,11 +24,8 @@ re_allowed_after_test = re.compile('^Signed-off-by:') # Signoffs re_signoff = re.compile('^Signed-off-by: *(.*)') -# The start of the cover letter -re_cover = re.compile('^Cover-letter:') - -# A cover letter Cc -re_cover_cc = re.compile('^Cover-letter-cc: *(.*)') +# Cover letter tag +re_cover = re.compile('^Cover-([a-z-]*): *(.*)') # Patch series tag re_series_tag = re.compile('^Series-([a-z-]*): *(.*)') @@ -65,7 +62,7 @@ class PatchStream: def __init__(self, series, name=None, is_log=False): self.skip_blank = False # True to skip a single blank line self.found_test = False # Found a TEST= line - self.lines_after_test = 0 # MNumber of lines found after TEST= + self.lines_after_test = 0 # Number of lines found after TEST= self.warn = [] # List of warnings we have collected self.linenum = 1 # Output line number we are up to self.in_section = None # Name of start...END section we are in @@ -73,7 +70,8 @@ class PatchStream: self.section = [] # The current section...END section self.series = series # Info about the patch series self.is_log = is_log # True if indent like git log - self.in_change = 0 # Non-zero if we are in a change list + self.in_change = None # Name of the change list we are in + self.change_version = 0 # Non-zero if we are in a change list self.blank_count = 0 # Number of blank lines stored up self.state = STATE_MSG_HEADER # What state are we in? self.signoff = [] # Contents of signoff line @@ -124,6 +122,22 @@ class PatchStream: self.skip_blank = True self.section = [] + def ParseVersion(self, value, line): + """Parse a version from a *-changes tag + + Args: + value: Tag value (part after 'xxx-changes: ' + line: Source line containing tag + + Returns: + The version as an integer + """ + try: + return int(value) + except ValueError as str: + raise ValueError("%s: Cannot decode version info '%s'" % + (self.commit.hash, line)) + def ProcessLine(self, line): """Process a single line of a patch file or commit log @@ -163,7 +177,6 @@ class PatchStream: change_id_match = re_change_id.match(line) commit_tag_match = re_commit_tag.match(line) cover_match = re_cover.match(line) - cover_cc_match = re_cover_cc.match(line) signoff_match = re_signoff.match(line) tag_match = None if self.state == STATE_PATCH_HEADER: @@ -183,8 +196,7 @@ class PatchStream: # If a tag is detected, or a new commit starts if series_tag_match or commit_tag_match or change_id_match or \ - cover_match or cover_cc_match or signoff_match or \ - self.state == STATE_MSG_HEADER: + cover_match or signoff_match or self.state == STATE_MSG_HEADER: # but we are already in a section, this means 'END' is missing # for that section, fix it up. if self.in_section: @@ -205,8 +217,9 @@ class PatchStream: # but we are already in a change list, that means a blank line # is missing, fix it up. if self.in_change: - self.warn.append("Missing 'blank line' in section 'Series-changes'") - self.in_change = 0 + self.warn.append("Missing 'blank line' in section '%s-changes'" % self.in_change) + self.in_change = None + self.change_version = 0 # If we are in a section, keep collecting lines until we see END if self.in_section: @@ -242,26 +255,37 @@ class PatchStream: elif self.skip_blank and is_blank: self.skip_blank = False - # Detect the start of a cover letter section + # Detect Cover-xxx tags elif cover_match: - self.in_section = 'cover' - self.skip_blank = False - - elif cover_cc_match: - value = cover_cc_match.group(1) - self.AddToSeries(line, 'cover-cc', value) + name = cover_match.group(1) + value = cover_match.group(2) + if name == 'letter': + self.in_section = 'cover' + self.skip_blank = False + elif name == 'letter-cc': + self.AddToSeries(line, 'cover-cc', value) + elif name == 'changes': + self.in_change = 'Cover' + self.change_version = self.ParseVersion(value, line) # If we are in a change list, key collected lines until a blank one elif self.in_change: if is_blank: # Blank line ends this change list - self.in_change = 0 + self.in_change = None + self.change_version = 0 elif line == '---': - self.in_change = 0 + self.in_change = None + self.change_version = 0 out = self.ProcessLine(line) else: if self.is_log: - self.series.AddChange(self.in_change, self.commit, line) + if self.in_change == 'Series': + self.series.AddChange(self.change_version, self.commit, line) + elif self.in_change == 'Cover': + self.series.AddChange(self.change_version, None, line) + elif self.in_change == 'Commit': + self.commit.AddChange(self.change_version, line) self.skip_blank = False # Detect Series-xxx tags @@ -270,12 +294,8 @@ class PatchStream: value = series_tag_match.group(2) if name == 'changes': # value is the version number: e.g. 1, or 2 - try: - value = int(value) - except ValueError as str: - raise ValueError("%s: Cannot decode version info '%s'" % - (self.commit.hash, line)) - self.in_change = int(value) + self.in_change = 'Series' + self.change_version = self.ParseVersion(value, line) else: self.AddToSeries(line, name, value) self.skip_blank = True @@ -297,6 +317,9 @@ class PatchStream: if name == 'notes': self.AddToCommit(line, name, value) self.skip_blank = True + elif name == 'changes': + self.in_change = 'Commit' + self.change_version = self.ParseVersion(value, line) # Detect the start of a new commit elif commit_match: @@ -340,7 +363,7 @@ class PatchStream: elif line == '---': self.state = STATE_DIFFS - # Output the tags (signeoff first), then change list + # Output the tags (signoff first), then change list out = [] log = self.series.MakeChangeLog(self.commit) out += [line] diff --git a/tools/patman/series.py b/tools/patman/series.py index be6f061122..ca7ca556dc 100644 --- a/tools/patman/series.py +++ b/tools/patman/series.py @@ -2,6 +2,9 @@ # Copyright (c) 2011 The Chromium OS Authors. # +from __future__ import print_function + +import collections import itertools import os @@ -156,7 +159,15 @@ class Series(dict): - Fix the widget - Jog the dial """ - versions = sorted(self.changes, reverse=True) + # Collect changes from the series and this commit + changes = collections.defaultdict(list) + for version, changelist in self.changes.items(): + changes[version] += changelist + if commit: + for version, changelist in commit.changes.items(): + changes[version] += [[commit, text] for text in changelist] + + versions = sorted(changes, reverse=True) newest_version = 1 if 'version' in self: newest_version = max(newest_version, int(self.version)) @@ -169,7 +180,7 @@ class Series(dict): need_blank = False for version in versions: out = [] - for this_commit, text in self.changes[version]: + for this_commit, text in changes[version]: if commit and this_commit != commit: continue if 'uniq' not in process_it or text not in out: -- cgit From 0411fff36f432079cacc0697d72140b8594364f1 Mon Sep 17 00:00:00 2001 From: Sean Anderson Date: Mon, 4 May 2020 16:28:35 -0400 Subject: patman: Support multi-line changes in changelogs This patch adds support to multi-line changes. That is, if one has a line in a changelog like - Do a thing but it spans multiple lines Using Series-process-log sort would sort as if those lines were unrelated. With this patch, any change line starting with whitespace will be considered part of the change before it. Signed-off-by: Sean Anderson Reviewed-by: Simon Glass --- tools/patman/README | 10 ++++++++-- tools/patman/patchstream.py | 35 +++++++++++++++++++++++++++-------- 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/tools/patman/README b/tools/patman/README index a99a68c6d5..52b2cf70bd 100644 --- a/tools/patman/README +++ b/tools/patman/README @@ -270,8 +270,14 @@ Patch-cc: Their Name interpreted by git send-email if you use it. Series-process-log: sort, uniq - This tells patman to sort and/or uniq the change logs. It is - assumed that each change log entry is only a single line long. + This tells patman to sort and/or uniq the change logs. Changes may be + multiple lines long, as long as each subsequent line of a change begins + with a whitespace character. For example, + +- This change + continues onto the next line +- But this change is separate + Use 'sort' to sort the entries, and 'uniq' to include only unique entries. If omitted, no change log processing is done. Separate each tag with a comma. diff --git a/tools/patman/patchstream.py b/tools/patman/patchstream.py index 871c66aeb1..4fe465e9ab 100644 --- a/tools/patman/patchstream.py +++ b/tools/patman/patchstream.py @@ -45,6 +45,9 @@ re_commit = re.compile('^commit ([0-9a-f]*)$') # We detect these since checkpatch doesn't always do it re_space_before_tab = re.compile('^[+].* \t') +# Match indented lines for changes +re_leading_whitespace = re.compile('^\s') + # States we can be in - can we use range() and still have comments? STATE_MSG_HEADER = 0 # Still in the message header STATE_PATCH_SUBJECT = 1 # In patch subject (first line of log for a commit) @@ -72,6 +75,7 @@ class PatchStream: self.is_log = is_log # True if indent like git log self.in_change = None # Name of the change list we are in self.change_version = 0 # Non-zero if we are in a change list + self.change_lines = [] # Lines of the current change self.blank_count = 0 # Number of blank lines stored up self.state = STATE_MSG_HEADER # What state are we in? self.signoff = [] # Contents of signoff line @@ -138,6 +142,20 @@ class PatchStream: raise ValueError("%s: Cannot decode version info '%s'" % (self.commit.hash, line)) + def FinalizeChange(self): + """Finalize a (multi-line) change and add it to the series or commit""" + if not self.change_lines: + return + change = '\n'.join(self.change_lines) + + if self.in_change == 'Series': + self.series.AddChange(self.change_version, self.commit, change) + elif self.in_change == 'Cover': + self.series.AddChange(self.change_version, None, change) + elif self.in_change == 'Commit': + self.commit.AddChange(self.change_version, change) + self.change_lines = [] + def ProcessLine(self, line): """Process a single line of a patch file or commit log @@ -178,6 +196,7 @@ class PatchStream: commit_tag_match = re_commit_tag.match(line) cover_match = re_cover.match(line) signoff_match = re_signoff.match(line) + leading_whitespace_match = re_leading_whitespace.match(line) tag_match = None if self.state == STATE_PATCH_HEADER: tag_match = re_tag.match(line) @@ -218,6 +237,7 @@ class PatchStream: # is missing, fix it up. if self.in_change: self.warn.append("Missing 'blank line' in section '%s-changes'" % self.in_change) + self.FinalizeChange() self.in_change = None self.change_version = 0 @@ -272,20 +292,18 @@ class PatchStream: elif self.in_change: if is_blank: # Blank line ends this change list + self.FinalizeChange() self.in_change = None self.change_version = 0 elif line == '---': + self.FinalizeChange() self.in_change = None self.change_version = 0 out = self.ProcessLine(line) - else: - if self.is_log: - if self.in_change == 'Series': - self.series.AddChange(self.change_version, self.commit, line) - elif self.in_change == 'Cover': - self.series.AddChange(self.change_version, None, line) - elif self.in_change == 'Commit': - self.commit.AddChange(self.change_version, line) + elif self.is_log: + if not leading_whitespace_match: + self.FinalizeChange() + self.change_lines.append(line) self.skip_blank = False # Detect Series-xxx tags @@ -378,6 +396,7 @@ class PatchStream: def Finalize(self): """Close out processing of this patch stream""" + self.FinalizeChange() self.CloseCommit() if self.lines_after_test: self.warn.append('Found %d lines after TEST=' % -- cgit From dc03ba48be2b78aaaa597889409cf29bfd2b271e Mon Sep 17 00:00:00 2001 From: Sean Anderson Date: Mon, 4 May 2020 16:28:36 -0400 Subject: patman: Modify functional tests for new behavior This patch adds or modifies functional tests for the Cover-changes, Commit-changes, and Series-process-log tags in order to account for new behavior added in the previous few patches. The '(no changes since v1)' case is not tested for, since that would need an additional commit to test in addition to testing the existing code paths. Signed-off-by: Sean Anderson Reviewed-by: Simon Glass --- tools/patman/func_test.py | 58 +++++++++++++++++++--- .../test/0001-pci-Correct-cast-for-sandbox.patch | 3 ++ ...-cast-for-sandbox-in-fdtdec_setup_mem_siz.patch | 12 ++++- tools/patman/test/test01.txt | 15 +++++- 4 files changed, 79 insertions(+), 9 deletions(-) diff --git a/tools/patman/func_test.py b/tools/patman/func_test.py index b7e2825de8..dc30078cce 100644 --- a/tools/patman/func_test.py +++ b/tools/patman/func_test.py @@ -82,19 +82,33 @@ class TestFunctional(unittest.TestCase): Series-prefix: RFC Series-cc: Stefan Brüns Cover-letter-cc: Lord Mëlchett - Series-version: 2 + Series-version: 3 + Patch-cc: fred + Series-process-log: sort, uniq Series-changes: 4 - Some changes + - Multi + line + change + + Commit-changes: 2 + - Changes only for this commit + + Cover-changes: 4 + - Some notes for the cover letter Cover-letter: test: A test patch series This is a test of how the cover - leter + letter works END and this in the first commit: + Commit-changes: 2 + - second revision change + Series-notes: some notes about some things @@ -202,7 +216,7 @@ class TestFunctional(unittest.TestCase): expected = ''' This is a test of how the cover -leter +letter works some notes @@ -210,7 +224,11 @@ about some things from the first commit Changes in v4: +- Multi + line + change - Some changes +- Some notes for the cover letter Simon Glass (2): pci: Correct cast for sandbox @@ -237,8 +255,34 @@ Simon Glass (2): subject = [line for line in lines if line.startswith('Subject')] self.assertEqual('Subject: [RFC %d/%d]' % (i + 1, count), subject[0][:18]) + + # Check that we got our commit notes + start = 0 + expected = '' + if i == 0: - # Check that we got our commit notes - self.assertEqual('---', lines[17]) - self.assertEqual('Some notes about', lines[18]) - self.assertEqual('the first commit', lines[19]) + start = 17 + expected = '''--- +Some notes about +the first commit + +(no changes since v2) + +Changes in v2: +- second revision change''' + elif i == 1: + start = 17 + expected = '''--- + +Changes in v4: +- Multi + line + change +- Some changes + +Changes in v2: +- Changes only for this commit''' + + if expected: + expected = expected.splitlines() + self.assertEqual(expected, lines[start:(start+len(expected))]) diff --git a/tools/patman/test/0001-pci-Correct-cast-for-sandbox.patch b/tools/patman/test/0001-pci-Correct-cast-for-sandbox.patch index 7191176f75..038943c2c9 100644 --- a/tools/patman/test/0001-pci-Correct-cast-for-sandbox.patch +++ b/tools/patman/test/0001-pci-Correct-cast-for-sandbox.patch @@ -15,6 +15,9 @@ cmd/pci.c:152:11: warning: format ‘%llx’ expects argument of type Fix it with a cast. Signed-off-by: Simon Glass +Commit-changes: 2 +- Changes only for this commit + Series-notes: some notes about some things diff --git a/tools/patman/test/0002-fdt-Correct-cast-for-sandbox-in-fdtdec_setup_mem_siz.patch b/tools/patman/test/0002-fdt-Correct-cast-for-sandbox-in-fdtdec_setup_mem_siz.patch index 702c0306ff..56278a6ce9 100644 --- a/tools/patman/test/0002-fdt-Correct-cast-for-sandbox-in-fdtdec_setup_mem_siz.patch +++ b/tools/patman/test/0002-fdt-Correct-cast-for-sandbox-in-fdtdec_setup_mem_siz.patch @@ -21,13 +21,23 @@ Series-cc: Stefan Brüns Cover-letter-cc: Lord Mëlchett Series-version: 3 Patch-cc: fred +Series-process-log: sort, uniq Series-changes: 4 - Some changes +- Multi + line + change + +Commit-changes: 2 +- Changes only for this commit + +Cover-changes: 4 +- Some notes for the cover letter Cover-letter: test: A test patch series This is a test of how the cover -leter +letter works END --- diff --git a/tools/patman/test/test01.txt b/tools/patman/test/test01.txt index 478ea93674..b238a8b4ba 100644 --- a/tools/patman/test/test01.txt +++ b/tools/patman/test/test01.txt @@ -13,6 +13,9 @@ Date: Sat Apr 15 15:39:08 2017 -0600 Fix it with a cast. Signed-off-by: Simon Glass + Commit-changes: 2 + - second revision change + Series-notes: some notes about some things @@ -45,12 +48,22 @@ Date: Sat Apr 15 15:39:08 2017 -0600 Cover-letter-cc: Lord Mëlchett Series-version: 3 Patch-cc: fred + Series-process-log: sort, uniq Series-changes: 4 - Some changes + - Multi + line + change + + Commit-changes: 2 + - Changes only for this commit + + Cover-changes: 4 + - Some notes for the cover letter Cover-letter: test: A test patch series This is a test of how the cover - leter + letter works END -- cgit