Bug 7907

Summary: devtool: update-recipe: only update SRCREV in auto mode when changes already pushed
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Paul Eggleton <bluelightning>
Component: devtools / tool chainAssignee: Markus Lehtonen <markus.lehtonen>
Status: VERIFIED FIXED QA Contact: Daniel Istrate <daniel.alexandrux.istrate>
Severity: enhancement    
Priority: Medium CC: bogdanx.a.voiculescu, meta.mr.watcher, meta.watcher, patrick.ohly, ross.burton
Version: 1.8   
Target Milestone: 1.9   
Hardware: All   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: Yes (doc changes required)

Description Paul Eggleton 2015-06-18 14:10:24 UTC
It seems to me that when devtool update-recipe is used on a recipe pointing to a git repository, it probably shouldn't update SRCREV when mode is "auto" unless it can tell that the changes have already been pushed upstream (i.e. it should check assuming that's practical).
Comment 1 Markus Lehtonen 2015-07-08 14:06:06 UTC
This probably makes sense. What would you think about the logic for checking that? See if the commit is in origin/${BRANCH}, where ${BRANCH} is the branch defined in src_uri parameter (or master, if not defined)?

It probably would be right thing to do to look at the patch filenames (instead of commit sha1) when checking if a patch has been merged upstream.
Comment 2 Paul Eggleton 2015-07-09 16:44:44 UTC
I figured it would be as simple as checking if the revision at the head of origin/${BRANCH} matched the tip of the devtool branch and if so, set SRCREV to that. I wasn't thinking of looking at individual commits, just the revision hashes.
Comment 3 Markus Lehtonen 2015-07-09 19:37:58 UTC
Oh, that simple ;) But yes, we can start with that.
Comment 5 Daniel Istrate 2015-10-12 10:56:36 UTC
Verified on master: e35c404537db0b46047fcb2ee7d3645e3e0935c5

Steps to verify:
1. You need some package with git sources e.g. btrfs-tools
devtool modify -x btrfs-tools btrfs-tools

2. Then make a change to the source code and commit
cd btrfs-tools/
echo foobar >> INSTALL; git commit -am"My change"

3. Run devtool
cd ..
devtool update-recipe btrfs-tools

4. You can fool devtool a bit to think that your change is already in upstream
cd btrfs-tools/
git rev-parse HEAD > .git/refs/remotes/origin/master

5. Run devtool
cd ..
devtool update-recipe btrfs-tools

6. Check that the patches are deleted and SRCREV updated
git diff meta/recipes-devtools/btrfs-tools/btrfs-tools_*.bb
SRCREV should be the same with 'git rev-parse HEAD' typed earlier.


-------------------------------------------------------------------------

[daniel@fedora-ws poky-build]$ devtool modify -x btrfs-tools btrfs-tools
NOTE: Creating workspace layer in /media/ssd/poky-build/workspace
NOTE: Enabling workspace layer in bblayers.conf
Parsing recipes..done.
NOTE: Fetching btrfs-tools...
NOTE: Unpacking...
NOTE: Patching...
NOTE: Source tree extracted to /media/ssd/poky-build/btrfs-tools
NOTE: Using source tree as build directory since recipe inherits autotools-brokensep
NOTE: Recipe btrfs-tools now set up to build from /media/ssd/poky-build/btrfs-tools
[daniel@fedora-ws poky-build]$ cd btrfs-tools/
[daniel@fedora-ws btrfs-tools]$ echo foobar >> INSTALL; git commit -am"My change"
[devtool 064d0c3] My change
 1 file changed, 1 insertion(+)
[daniel@fedora-ws btrfs-tools]$ cd ..
[daniel@fedora-ws poky-build]$ devtool update-recipe btrfs-tools
Parsing recipes..done.
NOTE: Adding new patch 0001-My-change.patch
NOTE: Updating recipe btrfs-tools_4.1.2.bb
[daniel@fedora-ws poky-build]$ cd btrfs-tools/
[daniel@fedora-ws btrfs-tools]$ git rev-parse HEAD > .git/refs/remotes/origin/master
[daniel@fedora-ws btrfs-tools]$ cd ..
[daniel@fedora-ws poky-build]$ devtool update-recipe btrfs-tools
Parsing recipes..done.
NOTE: Updating SRCREV in recipe btrfs-tools_4.1.2.bb
NOTE: Removing file /home/daniel/poky/meta/recipes-devtools/btrfs-tools/btrfs-tools/0001-My-change.patch
NOTE: Removing file /home/daniel/poky/meta/recipes-devtools/btrfs-tools/btrfs-tools/fix-parallel.patch
[daniel@fedora-ws poky]$ git diff meta/recipes-devtools/btrfs-tools/btrfs-tools_*.bb
diff --git a/meta/recipes-devtools/btrfs-tools/btrfs-tools_4.1.2.bb b/meta/recipes-devtools/btrfs-tools/btrfs-tools_4.1.2.bb
index 37c622b..0159eb0 100644
--- a/meta/recipes-devtools/btrfs-tools/btrfs-tools_4.1.2.bb
+++ b/meta/recipes-devtools/btrfs-tools/btrfs-tools_4.1.2.bb
@@ -12,10 +12,8 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=fcb02dc552a041dee27e4b85c7396067"
 SECTION = "base"
 DEPENDS = "util-linux attr e2fsprogs lzo acl"
 
-SRCREV = "7f1328ccb5d159efe850d4eaea9b49bbe8c4181e"
-SRC_URI = "git://git.kernel.org/pub/scm/linux/kernel/git/kdave/btrfs-progs.git \
-           file://fix-parallel.patch \
-"
+SRCREV = "064d0c33f9befe7170618036cce967fe59ed1084"
+SRC_URI = "git://git.kernel.org/pub/scm/linux/kernel/git/kdave/btrfs-progs.git"
 
 inherit autotools-brokensep pkgconfig
 
[daniel@fedora-ws poky]$