[SCM] The rsync repository. - branch master updated

Rsync CVS commit messages rsync-cvs at lists.samba.org
Sun Apr 12 07:19:51 UTC 2020


The branch, master has been updated
       via  2d0c7adb Change some packaging tools into python3 and make a few improvements.
       via  0b4b31a9 Add a (pending) release line for 3.1.4.
       via  8a21e5a8 Use the --quiet option.
      from  fa9c8d04 Put the year-tweak script into packaging dir.

https://git.samba.org/?p=rsync.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 2d0c7adba9915b8a4ae379f351775a8b314671c0
Author: Wayne Davison <wayned at samba.org>
Date:   Sun Apr 12 00:13:35 2020 -0700

    Change some packaging tools into python3 and make a few improvements.

commit 0b4b31a9605a5495cfdb722d28913b792d5e27c5
Author: Wayne Davison <wayned at samba.org>
Date:   Sat Apr 11 17:59:22 2020 -0700

    Add a (pending) release line for 3.1.4.

commit 8a21e5a8c6ff4388f9a5c55d9ebb2616d87ff1e4
Author: Wayne Davison <wayned at samba.org>
Date:   Thu Apr 9 18:42:31 2020 -0700

    Use the --quiet option.

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

Summary of changes:
 OLDNEWS                     |   1 +
 packaging/branch-from-patch | 356 ++++++++++----------
 packaging/git-status.pl     |  52 ---
 packaging/nightly-rsync     |   2 +-
 packaging/patch-update      | 442 ++++++++++++------------
 packaging/pkglib.py         | 160 +++++++++
 packaging/release-rsync     | 795 +++++++++++++++++++++++---------------------
 support/git-set-file-times  |  43 ++-
 8 files changed, 978 insertions(+), 873 deletions(-)
 delete mode 100644 packaging/git-status.pl
 create mode 100644 packaging/pkglib.py


Changeset truncated at 500 lines:

diff --git a/OLDNEWS b/OLDNEWS
index 7bc36eeb..de195420 100644
--- a/OLDNEWS
+++ b/OLDNEWS
@@ -3746,6 +3746,7 @@ Changes since 2.4.6:
 
 Partial Protocol History
 	RELEASE DATE	VER.	DATE OF COMMIT*	PROTOCOL
+	?? May 2020	3.1.4			??
 	28 Jan 2018	3.1.3			31
 	21 Dec 2015	3.1.2			31
 	22 Jun 2014	3.1.1			31
diff --git a/packaging/branch-from-patch b/packaging/branch-from-patch
index a66cb16f..493f557d 100755
--- a/packaging/branch-from-patch
+++ b/packaging/branch-from-patch
@@ -1,182 +1,174 @@
-#!/usr/bin/perl
-
-use strict;
-use warnings;
-use Getopt::Long;
-
-&Getopt::Long::Configure('bundling');
-&usage if !&GetOptions(
-    'branch|b=s' => \( my $master_branch = 'master' ),
-    'skip-check' => \( my $skip_branch_check ),
-    'delete' => \( my $delete_local_branches ),
-    'help|h' => \( my $help_opt ),
-);
-&usage if $help_opt;
-
-push @INC, '.';
-
-require 'packaging/git-status.pl';
-check_git_state($master_branch, !$skip_branch_check, 1);
-
-my %local_branch;
-open PIPE, '-|', 'git branch -l' or die "Unable to fork: $!\n";
-while (<PIPE>) {
-    if (m# patch/\Q$master_branch\E/(.*)#o) {
-	$local_branch{$1} = 1;
-    }
-}
-close PIPE;
-
-if ($delete_local_branches) {
-    foreach my $name (sort keys %local_branch) {
-	my $branch = "patch/$master_branch/$name";
-	system 'git', 'branch', '-D', $branch and exit 1;
-    }
-    %local_branch = ( );
-}
-
-my @patch_list;
-foreach (@ARGV) {
-    if (!-f $_) {
-	die "File not found: $_\n";
-    }
-    die "Filename is not a .diff file: $_\n" unless /\.diff$/;
-    push @patch_list, $_;
-}
-
-exit unless @patch_list;
-
-my(%scanned, %created, %info);
-
-foreach my $patch (@patch_list) {
-    my($where, $name) = $patch =~ m{^(.*?)([^/]+)\.diff$};
-    next if $scanned{$name}++;
-
-    open IN, '<', $patch or die "Unable to open $patch: $!\n";
-
-    my $info = '';
-    my $commit;
-    while (<IN>) {
-	if (m#^based-on: (\S+)#) {
-	    $commit = $1;
-	    last;
-	}
-	last if m#^index .*\.\..* \d#;
-	last if m#^diff --git #;
-	last if m#^--- (old|a)/#;
-	$info .= $_;
-    }
-    close IN;
-
-    $info =~ s/\s+\Z/\n/;
-
-    my $parent = $master_branch;
-    my @patches = $info =~ m#patch -p1 <patches/(\S+)\.diff#g;
-    if (@patches) {
-	if ($patches[-1] eq $name) {
-	    pop @patches;
-	} else {
-	    warn "No identity patch line in $patch\n";
-	}
-	if (@patches) {
-	    $parent = pop @patches;
-	    if (!$scanned{$parent}) {
-		unless (-f "$where$parent.diff") {
-		    die "Unknown parent of $patch: $parent\n";
-		}
-		# Add parent to @patch_list so that we will look for the
-		# parent's parent.  Any duplicates will just be ignored.
-		push @patch_list, "$where$parent.diff";
-	    }
-	}
-    } else {
-	warn "No patch lines found in $patch\n";
-    }
-
-    $info{$name} = [ $parent, $info, $commit ];
-}
-
-foreach my $patch (@patch_list) {
-    create_branch($patch);
-}
-
-system 'git', 'checkout', $master_branch and exit 1;
-
-exit;
-
-sub create_branch
-{
-    my($patch) = @_;
-    my($where, $name) = $patch =~ m{^(.*?)([^/]+)\.diff$};
-
-    return if $created{$name}++;
-
-    my $ref = $info{$name};
-    my($parent, $info, $commit) = @$ref;
-
-    my $parent_branch;
-    if ($parent eq $master_branch) {
-	$parent_branch = $master_branch;
-	$parent_branch = $commit if defined $commit;
-    } else {
-	create_branch("$where/$parent.diff");
-	$parent_branch = "patch/$master_branch/$parent";
-    }
-
-    my $branch = "patch/$master_branch/$name";
-    print "\n", '=' x 64, "\nProcessing $branch ($parent_branch)\n";
-
-    if ($local_branch{$name}) {
-	system 'git', 'branch', '-D', $branch and exit 1;
-    }
-
-    system 'git', 'checkout', '-b', $branch, $parent_branch and exit 1;
-
-    open OUT, '>', "PATCH.$name" or die $!;
-    print OUT $info;
-    close OUT;
-    system 'git', 'add', "PATCH.$name" and exit 1;
-
-    open IN, '<', $patch or die "Unable to open $patch: $!\n";
-    $_ = join('', <IN>);
-    close IN;
-
-    open PIPE, '|-', 'patch -p1' or die $!;
-    print PIPE $_;
-    close PIPE;
-
-    system 'rm -f *.orig */*.orig';
-
-    while (m#\nnew file mode (\d+)\s+--- /dev/null\s+\Q+++\E b/(.*)#g) {
-	chmod oct($1), $2;
-	system 'git', 'add', $2;
-    }
-
-    while (1) {
-	system 'git status';
-	print 'Press Enter to commit, Ctrl-C to abort, or type a wild-name to add a new file: ';
-	$_ = <STDIN>;
-	last if /^$/;
-	chomp;
-	system "git add $_";
-    }
-
-    while (system 'git', 'commit', '-a', '-m', "Creating branch from $name.diff.") {
-	exit 1 if system '/bin/zsh';
-    }
-}
-
-sub usage
-{
-    die <<EOT;
-Usage branch-from-patch [OPTIONS] patches/DIFF...
-
-Options:
--b, --branch=BRANCH  Create branches relative to BRANCH if no "based-on"
-                     header was found in the patch file.
-    --skip-check     Skip the check that ensures starting with a clean branch.
-    --delete         Delete all the local patch/BASE/* branches, not just the ones
-                     that are being recreated.
--h, --help           Output this help message.
-EOT
-}
+#!/usr/bin/python3 -B
+
+# This script turns one or more diff files in the patches dir (which is
+# expected to be a checkout of the rsync-patches git repo) into a branch
+# in the main rsync git checkout. This allows the applied patch to be
+# merged with the latest rsync changes and tested.  To update the diff
+# with the resulting changes, see the patch-update script.
+
+import os, sys, re, argparse, glob
+
+sys.path = ['packaging'] + sys.path
+
+from pkglib import *
+
+def main():
+    global created, info, local_branch
+
+    cur_branch, args.base_branch = check_git_state(args.base_branch, not args.skip_check, args.patches_dir)
+
+    local_branch = get_patch_branches(args.base_branch)
+
+    if args.delete_local_branches:
+        for name in sorted(local_branch):
+            branch = f"patch/{args.base_branch}/{name}"
+            cmd_chk(['git', 'branch', '-D', branch])
+        local_branch = set()
+
+    if args.add_missing:
+        for fn in sorted(glob.glob(f"{args.patches_dir}/*.diff")):
+            name = re.sub(r'\.diff$', '', re.sub(r'.+/', '', fn))
+            if name not in local_branch and fn not in args.patch_files:
+                args.patch_files.append(fn)
+
+    if not args.patch_files:
+        return
+
+    for fn in args.patch_files:
+        if not fn.endswith('.diff'):
+            die(f"Filename is not a .diff file: {fn}")
+        if not os.path.isfile(fn):
+            die(f"File not found: {fn}")
+
+    scanned = set()
+    info = { }
+
+    patch_list = [ ]
+    for fn in args.patch_files:
+        m = re.match(r'^(?P<dir>.*?)(?P<name>[^/]+)\.diff$', fn)
+        patch = argparse.Namespace(**m.groupdict())
+        if patch.name in scanned:
+            continue
+        patch.fn = fn
+
+        lines = [ ]
+        commit_hash = None
+        with open(patch.fn, 'r', encoding='utf-8') as fh:
+            for line in fh:
+                m = re.match(r'^based-on: (\S+)', line)
+                if m:
+                    commit_hash = m[1]
+                    break
+                if (re.match(r'^index .*\.\..* \d', line)
+                 or re.match(r'^diff --git ', line)
+                 or re.match(r'^--- (old|a)/', line)):
+                    break
+                lines.append(re.sub(r'\s*\Z', "\n", line))
+        info_txt = ''.join(lines).strip() + "\n"
+        lines = None
+
+        parent = args.base_branch
+        patches = re.findall(r'patch -p1 <%s/(\S+)\.diff' % args.patches_dir, info_txt)
+        if patches:
+            last = patches.pop()
+            if last != patch.name:
+                warn(f"No identity patch line in {patch.fn}")
+                patches.append(last)
+            if patches:
+                parent = patches.pop()
+                if parent not in scanned:
+                    diff_fn = patch.dir + parent + '.diff'
+                    if not os.path.isfile(diff_fn):
+                        die(f"Failed to find parent of {patch.fn}: {parent}")
+                    # Add parent to args.patch_files so that we will look for the
+                    # parent's parent.  Any duplicates will be ignored.
+                    args.patch_files.append(diff_fn)
+        else:
+            warn(f"No patch lines found in {patch.fn}")
+
+        info[patch.name] = [ parent, info_txt, commit_hash ]
+
+        patch_list.append(patch)
+
+    created = set()
+    for patch in patch_list:
+        create_branch(patch)
+
+    cmd_chk(['git', 'checkout', args.base_branch])
+
+
+def create_branch(patch):
+    if patch.name in created:
+        return
+    created.add(patch.name)
+
+    parent, info_txt, commit_hash = info[patch.name]
+    parent = argparse.Namespace(dir=patch.dir, name=parent, fn=patch.dir + parent + '.diff')
+
+    if parent.name == args.base_branch:
+        parent_branch = commit_hash if commit_hash else args.base_branch
+    else:
+        create_branch(parent)
+        parent_branch = '/'.join(['patch', args.base_branch, parent.name])
+
+    branch = '/'.join(['patch', args.base_branch, patch.name])
+    print("\n" + '=' * 64)
+    print(f"Processing {branch} ({parent_branch})")
+
+    if patch.name in local_branch:
+        cmd_chk(['git', 'branch', '-D', branch])
+
+    cmd_chk(['git', 'checkout', '-b', branch, parent_branch])
+
+    info_fn = 'PATCH.' + patch.name
+    with open(info_fn, 'w', encoding='utf-8') as fh:
+        fh.write(info_txt)
+    cmd_chk(['git', 'add', info_fn])
+
+    with open(patch.fn, 'r', encoding='utf-8') as fh:
+        patch_txt = fh.read()
+
+    cmd_run('patch -p1'.split(), input=patch_txt)
+
+    for fn in glob.glob('*.orig') + glob.glob('*/*.orig'):
+        os.unlink(fn)
+
+    pos = 0
+    new_file_re = re.compile(r'\nnew file mode (?P<mode>\d+)\s+--- /dev/null\s+\+\+\+ b/(?P<fn>.+)')
+    while True:
+        m = new_file_re.search(patch_txt, pos)
+        if not m:
+            break
+        os.chmod(m['fn'], int(m['mode'], 8))
+        cmd_chk(['git', 'add', m['fn']])
+        pos = m.end()
+
+    while True:
+        cmd_chk('git status'.split())
+        ans = input('Press Enter to commit, Ctrl-C to abort, or type a wild-name to add a new file: ')
+        if ans == '':
+            break
+        cmd_chk("git add " + ans, shell=True)
+
+    while True:
+        s = cmd_run(['git', 'commit', '-a', '-m', f"Creating branch from {patch.name}.diff."])
+        if not s.returncode:
+            break
+        s = cmd_run(['/bin/zsh'])
+        if s.returncode:
+            die('Aborting due to shell error code')
+
+
+if __name__ == '__main__':
+    parser = argparse.ArgumentParser(description="Create a git patch branch from an rsync patch file.", add_help=False)
+    parser.add_argument('--branch', '-b', dest='base_branch', metavar='BASE_BRANCH', default='master', help="The branch the patch is based on. Default: master.")
+    parser.add_argument('--add-missing', '-a', action='store_true', help="Add a branch for every patches/*.diff that doesn't have a branch.")
+    parser.add_argument('--skip-check', action='store_true', help="Skip the check that ensures starting with a clean branch.")
+    parser.add_argument('--delete', dest='delete_local_branches', action='store_true', help="Delete all the local patch/BASE/* branches, not just the ones that are being recreated.")
+    parser.add_argument('--patches-dir', '-p', metavar='DIR', default='patches', help="Override the location of the rsync-patches dir. Default: patches.")
+    parser.add_argument('patch_files', metavar='patches/DIFF_FILE', nargs='*', help="Specify what patch diff files to process. Default: all of them.")
+    parser.add_argument("--help", "-h", action="help", help="Output this help message and exit.")
+    args = parser.parse_args()
+    main()
+
+# vim: sw=4 et
diff --git a/packaging/git-status.pl b/packaging/git-status.pl
deleted file mode 100644
index f68023ac..00000000
--- a/packaging/git-status.pl
+++ /dev/null
@@ -1,52 +0,0 @@
-# Do some git-status checking for the current dir and (optionally)
-# the patches dir.
-
-sub check_git_state
-{
-    my($master_branch, $fatal_unless_clean, $check_patches_dir) = @_;
-
-    my($cur_branch) = check_git_status($fatal_unless_clean);
-    (my $branch = $cur_branch) =~ s{^patch/([^/]+)/[^/]+$}{$1}; # change patch/BRANCH/PATCH_NAME into BRANCH
-    if ($branch ne $master_branch) {
-	print "The checkout is not on the $master_branch branch.\n";
-	exit 1 if $master_branch ne 'master';
-	print "Do you want me to continue with --branch=$branch? [n] ";
-	$_ = <STDIN>;
-	exit 1 unless /^y/i;
-	$_[0] = $master_branch = $branch; # Updates caller's $master_branch too.
-    }
-
-    if ($check_patches_dir && -d 'patches/.git') {
-	($branch) = check_git_status($fatal_unless_clean, 'patches');
-	if ($branch ne $master_branch) {
-	    print "The *patches* checkout is on branch $branch, not branch $master_branch.\n";
-	    print "Do you want to change it to branch $master_branch? [n] ";
-	    $_ = <STDIN>;
-	    exit 1 unless /^y/i;
-	    system "cd patches && git checkout '$master_branch'";
-	}
-    }
-
-    return $cur_branch;
-}
-
-sub check_git_status
-{
-    my($fatal_unless_clean, $subdir) = @_;
-    $subdir = '.' unless defined $subdir;
-    my $status = `cd '$subdir' && git status`;
-    my $is_clean = $status =~ /\nnothing to commit.+working (directory|tree) clean/;
-
-    my($cur_branch) = $status =~ /^(?:# )?On branch (.+)\n/;
-    if ($fatal_unless_clean && !$is_clean) {
-	if ($subdir eq '.') {
-	    $subdir = '';
-	} else {
-	    $subdir = " *$subdir*";
-	}
-	die "The$subdir checkout is not clean:\n", $status;
-    }
-    ($cur_branch, $is_clean, $status);
-}
-
-1;
diff --git a/packaging/nightly-rsync b/packaging/nightly-rsync
index 74891baa..060f1a40 100755
--- a/packaging/nightly-rsync
+++ b/packaging/nightly-rsync
@@ -112,7 +112,7 @@ if ($make_tar) {
     print "Creating $name.tar.gz\n";
     system "rsync -a @extra_files $name/";
     system "git archive --format=tar --prefix=$name/ HEAD | tar xf -";
-    system "support/git-set-file-times --prefix=$name/";
+    system "support/git-set-file-times --quiet --prefix=$name/";
     system "fakeroot tar czf $dest/$name.tar.gz $name; rm -rf $name";
 
     unlink($nightly_symlink);
diff --git a/packaging/patch-update b/packaging/patch-update
index e279c6bc..e13679c0 100755
--- a/packaging/patch-update
+++ b/packaging/patch-update
@@ -1,244 +1,210 @@
-#!/usr/bin/perl
+#!/usr/bin/python3 -B
+
 # This script is used to turn one or more of the "patch/BASE/*" branches
 # into one or more diffs in the "patches" directory.  Pass the option
 # --gen if you want generated files in the diffs.  Pass the name of
 # one or more diffs if you want to just update a subset of all the
 # diffs.
 
-use strict;
-use warnings;
-use Getopt::Long;
-
-my $patches_dir = 'patches';
-my $tmp_dir = "patches.$$";
-my $make_gen_cmd = 'make -f prepare-source.mak conf && ./config.status && make gen';
-
-&Getopt::Long::Configure('bundling');
-&usage if !&GetOptions(
-    'branch|b=s' => \( my $master_branch = 'master' ),
-    'skip-check' => \( my $skip_branch_check ),
-    'shell|s' => \( my $launch_shell ),
-    'gen:s' => \( my $incl_generated_files ),
-    'help|h' => \( my $help_opt ),
-);
-&usage if $help_opt;
-
-$ENV{GIT_MERGE_AUTOEDIT} = 'no';
-
-if (defined $incl_generated_files) {
-    $patches_dir = $incl_generated_files if $incl_generated_files ne '';
-    $incl_generated_files = 1;
-}
-
-die "No '$patches_dir' directory was found.\n" unless -d $patches_dir;
-die "No '.git' directory present in the current dir.\n" unless -d '.git';
-
-push @INC, '.';
-
-require 'packaging/git-status.pl';
-my $starting_branch = check_git_state($master_branch, !$skip_branch_check, 1);
-
-my $master_commit;
-open PIPE, '-|', "git log -1 --no-color $master_branch" or die $!;
-while (<PIPE>) {
-    if (/^commit (\S+)/) {
-	$master_commit = $1;
-	last;
-    }
-}
-close PIPE;


-- 
The rsync repository.



More information about the rsync-cvs mailing list