@@ -84,6 +84,27 @@ my $shallow_import = run_git("config --get --bool remote.". $remotename .".shall
84
84
chomp ($shallow_import );
85
85
$shallow_import = ($shallow_import eq " true" );
86
86
87
+ # Dumb push: don't update notes and mediawiki ref to reflect the last push.
88
+ #
89
+ # Configurable with mediawiki.dumbPush, or per-remote with
90
+ # remote.<remotename>.dumbPush.
91
+ #
92
+ # This means the user will have to re-import the just-pushed
93
+ # revisions. On the other hand, this means that the Git revisions
94
+ # corresponding to MediaWiki revisions are all imported from the wiki,
95
+ # regardless of whether they were initially created in Git or from the
96
+ # web interface, hence all users will get the same history (i.e. if
97
+ # the push from Git to MediaWiki loses some information, everybody
98
+ # will get the history with information lost). If the import is
99
+ # deterministic, this means everybody gets the same sha1 for each
100
+ # MediaWiki revision.
101
+ my $dumb_push = run_git(" config --get --bool remote.$remotename .dumbPush" );
102
+ unless ($dumb_push ) {
103
+ $dumb_push = run_git(" config --get --bool mediawiki.dumbPush" );
104
+ }
105
+ chomp ($dumb_push );
106
+ $dumb_push = ($dumb_push eq " true" );
107
+
87
108
my $wiki_name = $url ;
88
109
$wiki_name =~ s / [^\/ ]*:\/\/ // ;
89
110
@@ -598,6 +619,9 @@ sub mw_push_file {
598
619
my $complete_file_name = shift ;
599
620
# Commit message
600
621
my $summary = shift ;
622
+ # MediaWiki revision number. Keep the previous one by default,
623
+ # in case there's no edit to perform.
624
+ my $newrevid = shift ;
601
625
602
626
my $new_sha1 = $diff_info_split [3];
603
627
my $old_sha1 = $diff_info_split [2];
@@ -631,10 +655,12 @@ sub mw_push_file {
631
655
}) || die ' Fatal: Error ' .
632
656
$mediawiki -> {error }-> {code } .
633
657
' from mediwiki: ' . $mediawiki -> {error }-> {details };
658
+ $newrevid = $result -> {edit }-> {newrevid };
634
659
print STDERR " Pushed file : $new_sha1 - $title \n " ;
635
660
} else {
636
661
print STDERR " $complete_file_name not a mediawiki file (Not pushable on this version of git-remote-mediawiki).\n "
637
662
}
663
+ return $newrevid ;
638
664
}
639
665
640
666
sub mw_push {
@@ -666,7 +692,7 @@ sub mw_push {
666
692
# Notify Git that the push is done
667
693
print STDOUT " \n " ;
668
694
669
- if ($pushed ) {
695
+ if ($pushed && $dumb_push ) {
670
696
print STDERR " Just pushed some revisions to MediaWiki.\n " ;
671
697
print STDERR " The pushed revisions now have to be re-imported, and your current branch\n " ;
672
698
print STDERR " needs to be updated with these re-imported commits. You can do this with\n " ;
@@ -682,6 +708,7 @@ sub mw_push_revision {
682
708
my $last_local_revid = get_last_local_revision();
683
709
print STDERR " .\n " ; # Finish sentence started by get_last_local_revision()
684
710
my $last_remote_revid = get_last_remote_revision();
711
+ my $mw_revision = $last_remote_revid ;
685
712
686
713
# Get sha1 of commit pointed by local HEAD
687
714
my $HEAD_sha1 = run_git(" rev-parse $local 2>/dev/null" ); chomp ($HEAD_sha1 );
@@ -747,7 +774,11 @@ sub mw_push_revision {
747
774
# and we've split on \0.
748
775
my $info = shift (@diff_info_list );
749
776
my $file = shift (@diff_info_list );
750
- mw_push_file($info , $file , $commit_msg );
777
+ $mw_revision = mw_push_file($info , $file , $commit_msg , $mw_revision );
778
+ }
779
+ unless ($dumb_push ) {
780
+ run_git(" notes --ref=$remotename /mediawiki add -m \" mediawiki_revision: $mw_revision \" $sha1_commit " );
781
+ run_git(" update-ref -m \" Git-MediaWiki push\" refs/mediawiki/$remotename /master $sha1_commit $sha1_child " );
751
782
}
752
783
}
753
784
0 commit comments