The patch number 11258 was added via Mauro Carvalho Chehab <[email protected]>
to http://linuxtv.org/hg/v4l-dvb master development tree.

Kernel patches in this development tree may be modified to be backward
compatible with older kernels. Compatibility modifications will be
removed before inclusion into the mainstream Kernel

If anyone has any objections, please let us know by sending a message to:
        Linux Media Mailing List <[email protected]>

------

From: Mauro Carvalho Chehab  <[email protected]>
Added a script to run the tree merge procedure


hgimport was recommending a basic merge procedure. However, with some troubles:
- The procedure only works if the pulled tree creates a new head;
- The merge message should be manually written;
- No sanity checks were done before doing the merge;
- No error status were done.

The new perl script implements a better way to handle it, doing the necessary 
checks.

hgimport was updated to recommend the script usage.

Priority: normal

Signed-off-by: Mauro Carvalho Chehab <[email protected]>


---

 hgimport                |    4 
 v4l/scripts/do_merge.pl |  175 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 177 insertions(+), 2 deletions(-)

diff -r e5e3c5df85be -r ce3000494981 hgimport
--- a/hgimport  Sun Mar 29 05:34:18 2009 -0300
+++ b/hgimport  Sun Mar 29 05:42:13 2009 -0300
@@ -104,5 +104,5 @@ done
 
 echo To cherry pick all files, you can do something like:
 echo "for i in $TMP/*.patch; do ./mailimport \$i; done"
-echo "To merge it, the better is to do:"
-echo "hg pull $1 && hg merge && hg commit && make && hg push"
+echo "To merge it, the better is to run the merge script:"
+echo "./v4l/scripts/do_merge.pl $1"
diff -r e5e3c5df85be -r ce3000494981 v4l/scripts/do_merge.pl
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/v4l/scripts/do_merge.pl   Sun Mar 29 05:42:13 2009 -0300
@@ -0,0 +1,175 @@
+#!/usr/bin/perl
+
+my $merge_tree=shift or die "Should specify the pulled tree";
+
+sub hgrcuser($)
+{
+       my $file = shift;
+       my $ui = 0;
+       open IN, '<', $file;
+       while (<IN>) {
+               $ui = 1 if (/^\s*\[ui\]/);
+               if ($ui && /^\s*username\s*=\s*(\S.*?)\s*$/) {
+                       close IN;
+                       return($1);
+               }
+       }
+       close IN;
+       return("");
+}
+
+sub check_heads()
+{
+       my $count=0;
+       open IN, 'hg heads|';
+       while (<IN>) {
+               if (m/^[Cc]hangeset:/) {
+                       $count++;
+               }
+       }
+       close IN;
+       return $count;
+}
+
+sub curr_changeset()
+{
+       my $changeset = -1;
+
+       open IN, 'hg heads|';
+       while (<IN>) {
+               if (m/^[Cc]hangeset:\s*(\d+)/) {
+                       if ($changeset < 0) {
+                               $changeset = $1;
+                       } else {
+                               if ($1 < $changeset) {
+                                       $changeset = $1;
+                               }
+                       }
+               }
+       }
+       close IN;
+       return $changeset;
+}
+
+sub check_status()
+{
+       my $count=0;
+       open IN, 'hg status -m -a -d -r|';
+       while (<IN>) {
+               $count++;
+       }
+       close IN;
+       return $count;
+}
+
+sub rollback()
+{
+       print "Rolling back hg pull $merge_tree\n";
+       system("hg rollback");
+       system("hg update -C");
+       exit -1;
+}
+
+####################
+# Determine username
+
+# Get Hg username from environment
+my $user = $ENV{HGUSER};
+
+# Didn't work? Try the repo's .hgrc file
+if ($user eq "") {
+       my $hgroot = `hg root`;
+       chomp($hgroot);
+       $user = hgrcuser("$hgroot/.hg/hgrc");
+}
+# Ok, try ~/.hgrc next
+if ($user eq "") {
+       $user = hgrcuser("$ENV{HOME}/.hgrc");
+}
+
+# Still no luck? Try some other environment variables
+if ($user eq "") {
+       my $name = $ENV{CHANGE_LOG_NAME};
+       my $email = $ENV{CHANGE_LOG_EMAIL_ADDRESS};
+       $user = "$name <$email>" if ($name ne "" || $email ne "");
+}
+
+# Last try to come up with something
+if ($user eq "") {
+       print "User not known. Can't procceed\n";
+       exit -1;
+}
+
+######################
+# Do some sanity tests
+
+print "Checking if everything is ok, before applying the new tree.\n";
+
+my $n_heads = check_heads();
+die "Your tree currently have more than one head (it has $n_heads heads). 
Can't procceed\n" if ($n_heads > 1);
+
+my $dirty = check_status();
+die "Your tree currently has changes. Can't procceed\n" if ($dirty);
+
+my $curr_cs = curr_changeset();
+
+###########
+# Pull tree
+
+print "hg pull $merge_tree\n";
+
+my $ret = system("hg pull $merge_tree");
+die "Couldn't pull from $merge_tree\n" if ($ret);
+
+#############################
+# Merge and commit, if needed
+
+$n_heads = check_heads();
+if ($n_heads > 2) {
+       print "The merged tree have more than one head (it has $n_heads heads). 
Can't procceed.\n";
+       rollback();
+}
+
+if ($n_heads == 2) {
+       print "Merging the new changesets\n";
+
+       $ret = system("hg merge");
+       if ($ret) {
+               print "hg merge failed. Can't procceed.\n";
+               rollback();
+       }
+
+       print "Committing the new tree\n";
+       # Write the commit message
+       $msg= "merge: $merge_tree\n\nFrom: $user\n\nSigned-off-by: $user\n";
+       $ret=system("hg commit -m '$msg'");
+       if ($ret) {
+               print "hg commit failed. Can't procceed.\n";
+               rollback();
+       }
+}
+
+#####################
+# Test resulting tree
+
+print "Testing if the build didn't break compilation. Only errors and warnings 
will be displayed. Please wait.\n";
+$ret = system ('make all|grep -v "^ CC"|grep -v "^ LD"');
+if ($ret) {
+       print "Build failed. Can't procceed.\n";
+
+       # To avoid the risk of doing something really bad, let's ask the user 
to run hg strip
+       print "Your tree is dirty. Since hg has only one rollback level, you'll 
need to use, instead:";
+       print "\thg strip $curr_cs; hg update -C";
+       print "You'll need to have hg mq extension enabled for hg strip to 
work.\n";
+
+       exit -1;
+}
+
+##############################
+# Everything is ok, let's push
+
+print "Pushing the new tree at the remote repository specified at .hg/hgrc\n";
+$ret=system ("hg push");
+if ($ret) {
+       print "hg push failed. Don't forget to do the push later.\n";
+}


---

Patch is available at: 
http://linuxtv.org/hg/v4l-dvb/rev/ce300049498134d717122139e42cfb060bc83974

_______________________________________________
linuxtv-commits mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits

Reply via email to