[commit: ghc] master: Change how sync-all handles directory changes (b339dd4)

Ian Lynagh <[email protected]>
Newsgroups gmane.comp.lang.haskell.cvs.ghc
Message-ID <[email protected]>
Repository : ssh://darcs.haskell.org//srv/darcs/ghc

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/b339dd488119b491da2631e95170ebaa12efea31

>---------------------------------------------------------------

commit b339dd488119b491da2631e95170ebaa12efea31
Author: Ian Lynagh <[email protected]>
Date:   Sun Dec 9 19:34:28 2012 +0000

    Change how sync-all handles directory changes
    
    We now remember the current working directory right at the start,
    and change back to it after we've finished working in a subdirectory.
    
    This should fix a problem some people have been seeing, where
    sync-all thinks that they have an out-of-date time library because
    its working directory has gone wrong somehow.

>---------------------------------------------------------------

 sync-all |   27 ++++++++++++++-------------
 1 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/sync-all b/sync-all
index 9aa40d5..225ad36 100755
--- a/sync-all
+++ b/sync-all
@@ -5,6 +5,8 @@ use Cwd;
 
 $| = 1; # autoflush stdout after each print, to avoid output after die
 
+my $initial_working_directory;
+
 my $defaultrepo;
 my @packages;
 my $verbose = 2;
@@ -143,13 +145,11 @@ sub gitNewWorkdir {
     my $dir = shift;
     my $target = shift;
     my $target_dir = "$target/$dir";
-    my $pwd;
 
     if ($dir eq '.') {
         message "== running git-new-workdir . $target_dir @_";
     } else {
         message "== $dir: running git-new-workdir . $target_dir @_";
-        $pwd = getcwd();
         chdir($dir);
     }
 
@@ -158,20 +158,18 @@ sub gitNewWorkdir {
         or die "git-new-workdir failed: $?";
 
     if ($dir ne '.') {
-        chdir($pwd);
+        chdir($initial_working_directory);
     }
 }
 
 sub scm {
     my $dir = shift;
     my $scm = shift;
-    my $pwd;
 
     if ($dir eq '.') {
         message "== running $scm @_";
     } else {
         message "== $dir: running $scm @_";
-        $pwd = getcwd();
         chdir($dir);
     }
 
@@ -180,7 +178,7 @@ sub scm {
         or die "$scm failed: $?";
 
     if ($dir ne '.') {
-        chdir($pwd);
+        chdir($initial_working_directory);
     }
 }
 
@@ -196,9 +194,7 @@ sub scmall {
     my $subcommand;
 
     my $path;
-    my $wd_before = getcwd;
 
-    my $pwd;
     my @args;
 
     my $started;
@@ -796,9 +792,14 @@ sub main {
     }
 }
 
+BEGIN {
+    $initial_working_directory = getcwd();
+}
+
 END {
     my $ec = $?;
-    my $pwd = getcwd();
+
+    chdir($initial_working_directory);
 
     message "== Checking for old haddock repo";
     if (-d "utils/haddock/.git") {
@@ -815,7 +816,7 @@ Please remove it (e.g. "rm -r utils/haddock"), and then run
 ============================
 EOF
         }
-        chdir($pwd);
+        chdir($initial_working_directory);
     }
 
     message "== Checking for old binary repo";
@@ -833,7 +834,7 @@ Please remove it (e.g. "rm -r libraries/binary"), and then run
 ============================
 EOF
         }
-        chdir($pwd);
+        chdir($initial_working_directory);
     }
 
     message "== Checking for old mtl repo";
@@ -851,7 +852,7 @@ Please remove it (e.g. "rm -r libraries/mtl"), and then run
 ============================
 EOF
         }
-        chdir($pwd);
+        chdir($initial_working_directory);
     }
 
     message "== Checking for old Cabal repo";
@@ -869,7 +870,7 @@ Please remove it (e.g. "rm -r libraries/Cabal"), and then run
 ============================
 EOF
         }
-        chdir($pwd);
+        chdir($initial_working_directory);
     }
 
     message "== Checking for old time from tarball";
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.