X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=dgit.git;a=blobdiff_plain;f=dgit;h=9aadaf0d4753c5231c0d3d6ea95c05311397e4f0;hp=d772a9037c7b9aab429ccc0e2df9ad39f4754bf8;hb=2ef2809f38beeafcccd904267b82849ddcb17957;hpb=8b34c8e50e236ea9340693c9a425cc2cb2f957ad diff --git a/dgit b/dgit index d772a903..9aadaf0d 100755 --- a/dgit +++ b/dgit @@ -19,7 +19,7 @@ use strict; -use Debian::Dgit; +use Debian::Dgit qw(:DEFAULT :playground); setup_sigwarn(); use IO::Handle; @@ -557,7 +557,7 @@ sub nextarg { } sub pre_help () { - no_local_git_cfg(); + not_necessarily_a_tree(); } sub cmd_help () { print $helpmsg or die $!; @@ -681,7 +681,7 @@ sub cfg { "$us: distro or suite appears not to be (properly) supported"; } -sub no_local_git_cfg () { +sub not_necessarily_a_tree () { # needs to be called from pre_* @gitcfgsources = grep { $_ ne 'local' } @gitcfgsources; } @@ -985,12 +985,6 @@ sub commit_getclogp ($) { $commit_getclogp_memo{$objid} = parsechangelog("-l$mclog"); } -sub must_getcwd () { - my $d = getcwd(); - defined $d or fail "getcwd failed: $!"; - return $d; -} - sub parse_dscdata () { my $dscfh = new IO::File \$dscdata, '<' or die $!; printdebug Dumper($dscdata) if $debuglevel>1; @@ -1674,18 +1668,13 @@ sub create_remote_git_repo () { our ($dsc_hash,$lastpush_mergeinput); our ($dsc_distro, $dsc_hint_tag, $dsc_hint_url); -our $ud = '.git/dgit/unpack'; -sub prep_ud (;$) { - my ($d) = @_; - $d //= $ud; - rmtree($d); - mkpath '.git/dgit'; - mkdir $d or die $!; +sub prep_ud () { + fresh_playground 'dgit/unpack'; } sub mktree_in_ud_here () { - workarea_setup $gitcfgs{local}; + playtree_setup $gitcfgs{local}; } sub git_write_tree () { @@ -2060,7 +2049,7 @@ sub generate_commits_from_dsc () { # See big comment in fetch_from_archive, below. # See also README.dsc-import. prep_ud(); - changedir $ud; + changedir $playground; my @dfi = dsc_files_info(); foreach my $fi (@dfi) { @@ -2470,8 +2459,8 @@ END @output = $lastpush_mergeinput; } } - changedir '../../../..'; - rmtree($ud); + changedir $maindir; + rmtree $playground; return @output; } @@ -4177,7 +4166,7 @@ END if (madformat_wantfixup($format)) { # user might have not used dgit build, so maybe do this now: if (quiltmode_splitbrain()) { - changedir $ud; + changedir $playground; quilt_make_fake_dsc($upstreamversion); my $cachekey; ($dgithead, $cachekey) = @@ -4190,7 +4179,7 @@ END $actualhead, $dgithead, $archive_hash); $maintviewhead = $actualhead; - changedir '../../../..'; + changedir $maindir; prep_ud(); # so _only_subdir() works, below } else { commit_quilty_patch(); @@ -4221,13 +4210,13 @@ END } } - changedir $ud; + changedir $playground; progress "checking that $dscfn corresponds to HEAD"; runcmd qw(dpkg-source -x --), $dscpath =~ m#^/# ? $dscpath : "../../../$dscpath"; my ($tree,$dir) = mktree_in_ud_from_only_subdir("source package"); check_for_vendor_patches() if madformat($dsc->{format}); - changedir '../../../..'; + changedir $maindir; my @diffcmd = (@git, qw(diff --quiet), $tree, $dgithead); debugcmd "+",@diffcmd; $!=0; $?=-1; @@ -4389,7 +4378,7 @@ END } sub pre_clone () { - no_local_git_cfg(); + not_necessarily_a_tree(); } sub cmd_clone { parseopts(); @@ -4603,7 +4592,7 @@ sub i_method { } sub pre_rpush () { - no_local_git_cfg(); + not_necessarily_a_tree(); } sub cmd_rpush { my $host = nextarg; @@ -5016,7 +5005,7 @@ END my $dgitview = git_rev_parse 'HEAD'; - changedir '../../../..'; + changedir $maindir; # When we no longer need to support squeeze, use --create-reflog # instead of this: ensuredir ".git/logs/refs/dgit-intern"; @@ -5041,7 +5030,7 @@ END runcmd @git, qw(update-ref -m), $cachekey, "refs/$splitbraincache", $dgitview; - changedir '.git/dgit/unpack/work'; + changedir "$playground/work"; my $saved = maybe_split_brain_save $headref, $dgitview, "converted"; progress "dgit view: created ($saved)"; @@ -5340,7 +5329,7 @@ END my $headref = git_rev_parse('HEAD'); prep_ud(); - changedir $ud; + changedir $playground; my $upstreamversion = upstreamversion $version; @@ -5352,7 +5341,7 @@ END die 'bug' if $split_brain && !$need_split_build_invocation; - changedir '../../../..'; + changedir $maindir; runcmd_ordryrun_local @git, qw(pull --ff-only -q .git/dgit/unpack/work master); } @@ -5463,7 +5452,7 @@ END sub quilt_check_splitbrain_cache ($$) { my ($headref, $upstreamversion) = @_; # Called only if we are in (potentially) split brain mode. - # Called in $ud. + # Called in playground. # Computes the cache key and looks in the cache. # Returns ($dgit_view_commitid, $cachekey) or (undef, $cachekey) @@ -6139,10 +6128,10 @@ sub build_source { } else { my @cmd = (@dpkgsource, qw(-b --)); if ($split_brain) { - changedir $ud; + changedir $playground; runcmd_ordryrun_local @cmd, "work"; my @udfiles = <${package}_*>; - changedir "../../.."; + changedir $maindir; foreach my $f (@udfiles) { printdebug "source copy, found $f\n"; next unless @@ -6150,7 +6139,7 @@ sub build_source { ($f =~ m/\.debian\.tar(?:\.\w+)$/ && $f eq srcfn($version, $&)); printdebug "source copy, found $f - renaming\n"; - rename "$ud/$f", "../$f" or $!==ENOENT + rename "$playground/$f", "../$f" or $!==ENOENT or fail "put in place new source file ($f): $!"; } } else { @@ -6380,7 +6369,7 @@ END } sub pre_archive_api_query () { - no_local_git_cfg(); + not_necessarily_a_tree(); } sub cmd_archive_api_query { badusage "need only 1 subpath argument" unless @ARGV==1; @@ -6399,7 +6388,7 @@ sub repos_server_url () { } sub pre_clone_dgit_repos_server () { - no_local_git_cfg(); + not_necessarily_a_tree(); } sub cmd_clone_dgit_repos_server { badusage "need destination argument" unless @ARGV==1; @@ -6411,7 +6400,7 @@ sub cmd_clone_dgit_repos_server { } sub pre_print_dgit_repos_server_source_url () { - no_local_git_cfg(); + not_necessarily_a_tree(); } sub cmd_print_dgit_repos_server_source_url { badusage "no arguments allowed to dgit print-dgit-repos-server-source-url"