Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH] buildhistory-diff: report directory renames
@ 2016-11-28 17:28 Ed Bartosh
  2016-11-29 13:51 ` Alexander Kanavin
  0 siblings, 1 reply; 3+ messages in thread
From: Ed Bartosh @ 2016-11-28 17:28 UTC (permalink / raw)
  To: openembedded-core

The script detects directory renaming if two different
directories with the same set of files are added and removed.

[YOCTO #10691]

Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
---
 meta/lib/oe/buildhistory_analysis.py | 34 +++++++++++++++++++++++++++++++---
 1 file changed, 31 insertions(+), 3 deletions(-)

diff --git a/meta/lib/oe/buildhistory_analysis.py b/meta/lib/oe/buildhistory_analysis.py
index b6c0265..19b3bc4 100644
--- a/meta/lib/oe/buildhistory_analysis.py
+++ b/meta/lib/oe/buildhistory_analysis.py
@@ -69,7 +69,22 @@ class ChangeRecord:
                     pkglist.append(k)
             return pkglist
 
+        def detect_renamed_dirs(aitems, bitems):
+            adirs = set(map(os.path.dirname, aitems))
+            bdirs = set(map(os.path.dirname, bitems))
+            files_ab = [(name, sorted(os.path.basename(item) for item in aitems if os.path.dirname(item) == name)) \
+                                for name in adirs - bdirs]
+            files_ba = [(name, sorted(os.path.basename(item) for item in bitems if os.path.dirname(item) == name)) \
+                                for name in bdirs - adirs]
+            renamed_dirs = [(dir1, dir2) for dir1, files1 in files_ab for dir2, files2 in files_ba if files1 == files2]
+            # remove files that belong to renamed dirs from aitems and bitems
+            for dir1, dir2 in renamed_dirs:
+                aitems = [item for item in aitems if os.path.dirname(item) not in (dir1, dir2)]
+                bitems = [item for item in bitems if os.path.dirname(item) not in (dir1, dir2)]
+            return renamed_dirs, aitems, bitems
+
         if self.fieldname in list_fields or self.fieldname in list_order_fields:
+            renamed_dirs = []
             if self.fieldname in ['RPROVIDES', 'RDEPENDS', 'RRECOMMENDS', 'RSUGGESTS', 'RREPLACES', 'RCONFLICTS']:
                 (depvera, depverb) = compare_pkg_lists(self.oldvalue, self.newvalue)
                 aitems = pkglist_combine(depvera)
@@ -77,16 +92,29 @@ class ChangeRecord:
             else:
                 aitems = self.oldvalue.split()
                 bitems = self.newvalue.split()
+                if self.fieldname == 'FILELIST':
+                    renamed_dirs, aitems, bitems = detect_renamed_dirs(aitems, bitems)
+
             removed = list(set(aitems) - set(bitems))
             added = list(set(bitems) - set(aitems))
 
+            lines = []
+            if renamed_dirs:
+                for dfrom, dto in renamed_dirs:
+                    lines.append('directory renamed %s -> %s' % (dfrom, dto))
             if removed or added:
                 if removed and not bitems:
-                    out = '%s: removed all items "%s"' % (self.fieldname, ' '.join(removed))
+                    lines.append('removed all items "%s"' % ' '.join(removed))
                 else:
-                    out = '%s:%s%s' % (self.fieldname, ' removed "%s"' % ' '.join(removed) if removed else '', ' added "%s"' % ' '.join(added) if added else '')
+                    if removed:
+                        lines.append('removed "%s"' % ' '.join(removed))
+                    if added:
+                        lines.append('added "%s"' % ' '.join(added))
             else:
-                out = '%s changed order' % self.fieldname
+                lines.append('changed order')
+
+            out = '%s: %s' % (self.fieldname, ', '.join(lines))
+
         elif self.fieldname in numeric_fields:
             aval = int(self.oldvalue or 0)
             bval = int(self.newvalue or 0)
-- 
2.1.4



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] buildhistory-diff: report directory renames
  2016-11-28 17:28 [PATCH] buildhistory-diff: report directory renames Ed Bartosh
@ 2016-11-29 13:51 ` Alexander Kanavin
  2016-12-01 15:57   ` Ed Bartosh
  0 siblings, 1 reply; 3+ messages in thread
From: Alexander Kanavin @ 2016-11-29 13:51 UTC (permalink / raw)
  To: openembedded-core

On 11/28/2016 07:28 PM, Ed Bartosh wrote:
> The script detects directory renaming if two different
> directories with the same set of files are added and removed.

What happens if the sets of files are slightly different? (e.g. a couple 
of files are added or removed). Can we get some wiggle space here?

Alex



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] buildhistory-diff: report directory renames
  2016-11-29 13:51 ` Alexander Kanavin
@ 2016-12-01 15:57   ` Ed Bartosh
  0 siblings, 0 replies; 3+ messages in thread
From: Ed Bartosh @ 2016-12-01 15:57 UTC (permalink / raw)
  To: Alexander Kanavin; +Cc: openembedded-core

On Tue, Nov 29, 2016 at 03:51:21PM +0200, Alexander Kanavin wrote:
> On 11/28/2016 07:28 PM, Ed Bartosh wrote:
> >The script detects directory renaming if two different
> >directories with the same set of files are added and removed.
> 
> What happens if the sets of files are slightly different? (e.g. a
> couple of files are added or removed). Can we get some wiggle space
> here?
> 
In this case script will behave like it does currently. It will show all
added and removed files.

--
Regards,
Ed


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-12-01 15:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-28 17:28 [PATCH] buildhistory-diff: report directory renames Ed Bartosh
2016-11-29 13:51 ` Alexander Kanavin
2016-12-01 15:57   ` Ed Bartosh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox