+ get_archive_dsc();
+ if (check_for_git()) {
+ runcmd_ordryrun @git, qw(fetch -p),$remotename,
+ '+refs/heads/*:refs/remotes/origin/*';
+ }
+ fetch_from_archive();
+}
+
+sub pull () {
+ fetch();
+ runcmd_ordryrun @git, qw(merge -m),"Merge from $suite [dgit]",
+ lref(uploadbranch());
+}
+
+sub dopush () {
+ runcmd @git, qw(diff --quiet HEAD);
+ my $clogp = parsechangelog();
+ $package = $clogp->{Source};
+ my $dscfn = "${package}_$clogp->{Version}.dsc";
+ stat "../$dscfn" or die "$dscfn $!";
+ $dsc = parsecontrol("../$dscfn");
+ prep_ud();
+ chdir $ud or die $!;
+ print "checking that $dscfn corresponds to HEAD\n";
+ runcmd qw(dpkg-source -x --), "../../../../$dscfn";
+ my ($tree,$dir) = mktree_in_ud_from_only_subdir();
+ chdir '../../../..' or die $!;
+ runcmd @git, qw(diff --exit-code), $tree;
+#fetch from alioth
+#do fast forward check and maybe fake merge
+# if (!is_fast_fwd(mainbranch
+# runcmd @git, qw(fetch -p ), "$alioth_git/$package.git",
+# map { lref($_).":".rref($_) }
+# (uploadbranch());
+ $dsc->{$ourdscfield} = rev_parse('HEAD');
+ $dsc->save("../$dscfn.tmp") or die $!;
+ if (!$dryrun) {
+ rename "../$dscfn.tmp","../$dscfn" or die "$dscfn $!";
+ } else {
+ print "[new .dsc left in $dscfn.tmp]\n";
+ }
+ if (!$changesfile) {
+ my $pat = "../${package}_$clogp->{Version}_*.changes";
+ my @cs = glob $pat;
+ die "$pat ?" unless @cs==1;
+ ($changesfile) = @cs;
+ }
+ my $tag = debiantag($dsc->{Version});
+ if (!check_for_git()) {
+ runcmd_ordryrun qw(ssh),$alioth_sshtestbodge->[0],
+ "set -e; cd $alioth_sshtestbodge->[1];".
+ " mkdir -p $package.git;".
+ " cd $package.git;".
+ " if ! test -d objects; then git init --bare; fi";
+ }
+ runcmd_ordryrun @git, qw(push),$remotename,"HEAD:".lref(uploadbranch());
+ if ($sign) {
+ my @tag_cmd = (@git, qw(tag -s -m),
+ "Release $dsc->{Version} for $suite [dgit]");
+ push @tag_cmd, qw(-u),$keyid if defined $keyid;
+ push @tag_cmd, $tag;
+ runcmd_ordryrun @tag_cmd;
+ my @debsign_cmd = @debsign;
+ push @debsign_cmd, "-k$keyid" if defined $keyid;
+ push @debsign_cmd, $changesfile;
+ runcmd_ordryrun @debsign_cmd;
+ }
+ runcmd_ordryrun @git, qw(push),$remotename,"refs/tags/$tag";
+ runcmd_ordryrun @dput, $changesfile;
+}
+
+sub cmd_clone {
+ my $dstdir;
+ if (@ARGV==1) {
+ ($package) = @ARGV;
+ } elsif (@ARGV==2 && $ARGV[1] =~ m#^\w#) {
+ ($package,$suite) = @ARGV;
+ } elsif (@ARGV==2 && $ARGV[1] =~ m#^[./]#) {
+ ($package,$dstdir) = @ARGV;
+ } elsif (@ARGV==3) {
+ ($package,$suite,$dstdir) = @ARGV;
+ } else {
+ die;
+ }
+ $dstdir ||= "$package";
+ clone($dstdir);
+}
+
+sub branchsuite () {
+ my $branch = cmdoutput_errok @git, qw(symbolic-ref HEAD);
+ chomp $branch;
+ if ($branch =~ m#^refs/heads/$branchprefix/([^/.]+)$#o) {
+ return $1;
+ } else {
+ return undef;
+ }
+}
+
+sub fetchpullargs () {
+ my $clogp = parsechangelog();
+ $package = $clogp->{Source};
+ if (@ARGV==0) {
+ $suite = branchsuite();
+ $suite ||= $clogp->{Distribution};
+ canonicalise_suite();
+ print "fetching from suite $suite\n";
+ } elsif (@ARGV==1) {
+ ($suite) = @ARGV;
+ canonicalise_suite();
+ } else {
+ die;
+ }