|
|
Chromium Code Reviews|
Created:
7 years, 9 months ago by szager1 Modified:
7 years, 9 months ago CC:
chromium-reviews, Dirk Pranke, cmp-cc_chromium.org, iannucci+depot_tools_chromium.org Visibility:
Public. |
DescriptionExecute a temp copy of update_depot_tools.bat
Windows will sometimes freak out if a file is rewritten while
it's being executed. That can happen when update_depot_tools.bat
runs.
R=iannucci@chromium.org,maruel@chromium.org
BUG=
Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=189429
Patch Set 1 #
Total comments: 16
Patch Set 2 : Add goto :EOF #Patch Set 3 : Remove 'sometimes' #Patch Set 4 : copy to %TEMP% #Messages
Total messages: 15 (0 generated)
Pulling out this functionality from here: https://codereview.chromium.org/12865010/
https://codereview.chromium.org/12755033/diff/1/update_depot_tools.bat File update_depot_tools.bat (right): https://codereview.chromium.org/12755033/diff/1/update_depot_tools.bat#newcode10 update_depot_tools.bat:10: :: Windows sometimes freaks out if a file is overwritten while it's being 'sometimes'? https://codereview.chromium.org/12755033/diff/1/update_depot_tools.bat#newcode14 update_depot_tools.bat:14: COPY /Y %~dp0update_depot_tools.bat %~dp0update_depot_tools_tmp.bat >nul is %~dp guaranteed to end with a r'\' ? https://codereview.chromium.org/12755033/diff/1/update_depot_tools.bat#newcode16 update_depot_tools.bat:16: %~dp0update_depot_tools_tmp.bat %* Should we goto :EOF after this? I forget how batch subinvocations work...
https://codereview.chromium.org/12755033/diff/1/.gitignore File .gitignore (right): https://codereview.chromium.org/12755033/diff/1/.gitignore#newcode22 .gitignore:22: # Ignore temporary locations for auto-updating scripts. These are necessary Not needed. https://codereview.chromium.org/12755033/diff/1/update_depot_tools.bat File update_depot_tools.bat (right): https://codereview.chromium.org/12755033/diff/1/update_depot_tools.bat#newcode14 update_depot_tools.bat:14: COPY /Y %~dp0update_depot_tools.bat %~dp0update_depot_tools_tmp.bat >nul Please use %TEMP%\update_depot_tools_%RANDOM%.bat, so the likelihood of 2 gclient process breaking each other lowers from 100% to 1/~10000, since we can't trust the random number generator to be efficient. You could use %RANDOM%_%RANDOM% if you prefer but since it's a pseudo-random generator, it won't help much.
https://codereview.chromium.org/12755033/diff/1/update_depot_tools.bat File update_depot_tools.bat (right): https://codereview.chromium.org/12755033/diff/1/update_depot_tools.bat#newcode10 update_depot_tools.bat:10: :: Windows sometimes freaks out if a file is overwritten while it's being On 2013/03/20 21:06:14, iannucci wrote: > 'sometimes'? I haven't explored every nuance of this behavior (e.g., what happens with subprocesses, or exec from bash, or ...). But I can reproduce the bad situation, if necessary. https://codereview.chromium.org/12755033/diff/1/update_depot_tools.bat#newcode14 update_depot_tools.bat:14: COPY /Y %~dp0update_depot_tools.bat %~dp0update_depot_tools_tmp.bat >nul On 2013/03/20 21:06:37, Marc-Antoine Ruel wrote: > Please use %TEMP%\update_depot_tools_%RANDOM%.bat, so the likelihood of 2 > gclient process breaking each other lowers from 100% to 1/~10000, since we can't > trust the random number generator to be efficient. You could use > %RANDOM%_%RANDOM% if you prefer but since it's a pseudo-random generator, it > won't help much. That means that I have to fix every occurence of %~dp0 in this file. Which I can do, but I was hoping to leave a smaller footprint. Do we really claim to support multiple concurrent invocations of gclient? https://codereview.chromium.org/12755033/diff/1/update_depot_tools.bat#newcode16 update_depot_tools.bat:16: %~dp0update_depot_tools_tmp.bat %* On 2013/03/20 21:06:14, iannucci wrote: > Should we goto :EOF after this? I forget how batch subinvocations work... Empirical evidence suggests that it's not necessary, but I'll add it anyways, just to be safe.
https://codereview.chromium.org/12755033/diff/1/update_depot_tools.bat File update_depot_tools.bat (right): https://codereview.chromium.org/12755033/diff/1/update_depot_tools.bat#newcode10 update_depot_tools.bat:10: :: Windows sometimes freaks out if a file is overwritten while it's being On 2013/03/20 21:19:10, szager1 wrote: > On 2013/03/20 21:06:14, iannucci wrote: > > 'sometimes'? > > I haven't explored every nuance of this behavior (e.g., what happens with > subprocesses, or exec from bash, or ...). But I can reproduce the bad > situation, if necessary. I was meaning that the 'sometimes' can just be omitted :). I believe that batch scripts are modifiable 'live', so if svn pulls a change which moves all the lines in the batch file, cmd.exe could end up skipping a line or executing a line (or lines(s)) multiple times. See 'Compound Modification' in http://en.wikipedia.org/wiki/Self-modifying_code
https://codereview.chromium.org/12755033/diff/1/update_depot_tools.bat File update_depot_tools.bat (right): https://codereview.chromium.org/12755033/diff/1/update_depot_tools.bat#newcode10 update_depot_tools.bat:10: :: Windows sometimes freaks out if a file is overwritten while it's being On 2013/03/20 21:33:14, iannucci wrote: > I believe that batch > scripts are modifiable 'live' (...) Exact, cmd.exe keeps a byte offset and re-reads the file on every line. No wonder batch files are slow as molasse. https://codereview.chromium.org/12755033/diff/1/update_depot_tools.bat#newcode14 update_depot_tools.bat:14: COPY /Y %~dp0update_depot_tools.bat %~dp0update_depot_tools_tmp.bat >nul On 2013/03/20 21:19:10, szager1 wrote: > On 2013/03/20 21:06:37, Marc-Antoine Ruel wrote: > > Please use %TEMP%\update_depot_tools_%RANDOM%.bat, so the likelihood of 2 > > gclient process breaking each other lowers from 100% to 1/~10000, since we > can't > > trust the random number generator to be efficient. You could use > > %RANDOM%_%RANDOM% if you prefer but since it's a pseudo-random generator, it > > won't help much. > > That means that I have to fix every occurence of %~dp0 in this file. Which I > can do, but I was hoping to leave a smaller footprint. > > Do we really claim to support multiple concurrent invocations of gclient? I don't mind about not using random but you should still put it in TEMP. https://codereview.chromium.org/12755033/diff/1/update_depot_tools.bat#newcode16 update_depot_tools.bat:16: %~dp0update_depot_tools_tmp.bat %* On 2013/03/20 21:19:10, szager1 wrote: > On 2013/03/20 21:06:14, iannucci wrote: > > Should we goto :EOF after this? I forget how batch subinvocations work... > > Empirical evidence suggests that it's not necessary, but I'll add it anyways, > just to be safe. No it's not necessary. As long as there is not 'call' statement, the control is deferred to the called batch file.
https://codereview.chromium.org/12755033/diff/1/update_depot_tools.bat File update_depot_tools.bat (right): https://codereview.chromium.org/12755033/diff/1/update_depot_tools.bat#newcode10 update_depot_tools.bat:10: :: Windows sometimes freaks out if a file is overwritten while it's being On 2013/03/20 21:33:14, iannucci wrote: > On 2013/03/20 21:19:10, szager1 wrote: > > On 2013/03/20 21:06:14, iannucci wrote: > > > 'sometimes'? > > > > I haven't explored every nuance of this behavior (e.g., what happens with > > subprocesses, or exec from bash, or ...). But I can reproduce the bad > > situation, if necessary. > > I was meaning that the 'sometimes' can just be omitted :). I believe that batch > scripts are modifiable 'live', so if svn pulls a change which moves all the > lines in the batch file, cmd.exe could end up skipping a line or executing a > line (or lines(s)) multiple times. See 'Compound Modification' in > http://en.wikipedia.org/wiki/Self-modifying_code OK, I removed 'sometimes'. Why give false hope? https://codereview.chromium.org/12755033/diff/1/update_depot_tools.bat#newcode14 update_depot_tools.bat:14: COPY /Y %~dp0update_depot_tools.bat %~dp0update_depot_tools_tmp.bat >nul On 2013/03/20 21:06:14, iannucci wrote: > is %~dp guaranteed to end with a r'\' ? Hmmm... I've never seen it any other way. https://codereview.chromium.org/12755033/diff/1/update_depot_tools.bat#newcode14 update_depot_tools.bat:14: COPY /Y %~dp0update_depot_tools.bat %~dp0update_depot_tools_tmp.bat >nul On 2013/03/20 21:06:14, iannucci wrote: > is %~dp guaranteed to end with a r'\' ? Hmmm... I've never seen it any other way. Theoretically, if the script was at the top directory level, I suppose that might not be true. But if that happens, I'd just as soon this script died, since you're clearly in a bad state.
https://codereview.chromium.org/12755033/diff/1/update_depot_tools.bat File update_depot_tools.bat (right): https://codereview.chromium.org/12755033/diff/1/update_depot_tools.bat#newcode14 update_depot_tools.bat:14: COPY /Y %~dp0update_depot_tools.bat %~dp0update_depot_tools_tmp.bat >nul On 2013/03/20 21:51:22, Marc-Antoine Ruel wrote: > On 2013/03/20 21:19:10, szager1 wrote: > > On 2013/03/20 21:06:37, Marc-Antoine Ruel wrote: > > > Please use %TEMP%\update_depot_tools_%RANDOM%.bat, so the likelihood of 2 > > > gclient process breaking each other lowers from 100% to 1/~10000, since we > > can't > > > trust the random number generator to be efficient. You could use > > > %RANDOM%_%RANDOM% if you prefer but since it's a pseudo-random generator, it > > > won't help much. > > > > That means that I have to fix every occurence of %~dp0 in this file. Which I > > can do, but I was hoping to leave a smaller footprint. > > > > Do we really claim to support multiple concurrent invocations of gclient? > > I don't mind about not using random but you should still put it in TEMP. Done.
lgtm
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/szager@chromium.org/12755033/15001
Failed to apply patch for depot_tools/update_depot_tools.bat:
While running patch -p1 --forward --force --no-backup-if-mismatch;
patching file depot_tools/update_depot_tools.bat
Hunk #1 FAILED at 7.
Hunk #2 FAILED at 22.
Hunk #3 FAILED at 51.
3 out of 3 hunks FAILED -- saving rejects to file
depot_tools/update_depot_tools.bat.rej
Patch: depot_tools/update_depot_tools.bat
Index: update_depot_tools.bat
diff --git depot_tools/update_depot_tools.bat depot_tools/update_depot_tools.bat
index
f880d9b895a384c616915c6d1f4ce5bc7c063319..20ac0d7cd45bf214220a1eca40708e7f4cc9358a
100644
--- a/depot_tools/update_depot_tools.bat
+++ b/depot_tools/update_depot_tools.bat
@@ -7,13 +7,25 @@
setlocal
+:: Windows freaks out if a file is overwritten while it's being executed. Copy
+:: this script off to a temporary location and reinvoke from there before
+:: running any svn or git commands.
+IF %~nx0==update_depot_tools.bat (
+ COPY /Y %~dp0update_depot_tools.bat %TEMP%\update_depot_tools_tmp.bat >nul
+ if errorlevel 1 goto :EOF
+ %TEMP%\update_depot_tools_tmp.bat %~dp0 %*
+)
+
+set DEPOT_TOOLS_DIR=%1
+SHIFT
+
set GIT_URL=https://chromium.googlesource.com/chromium/tools/depot_tools.git
:: Will download svn and python.
:: If you don't want to install the depot_tools version of these tools, remove
:: the 'force' option on the next command. The tools will be installed only if
:: not already in the PATH environment variable.
-call "%~dp0bootstrap\win\win_tools.bat" force
+call "%DEPOT_TOOLS_DIR%bootstrap\win\win_tools.bat" force
if errorlevel 1 goto :EOF
:: Now clear errorlevel so it can be set by other programs later.
set errorlevel=
@@ -22,19 +34,19 @@ set errorlevel=
IF "%DEPOT_TOOLS_UPDATE%" == "0" GOTO :EOF
:: We need either .\.svn\. or .\.git\. to be able to sync.
-IF EXIST "%~dp0.svn\." GOTO :SVN_UPDATE
-IF EXIST "%~dp0.git\." GOTO :GIT_UPDATE
+IF EXIST "%DEPOT_TOOLS_DIR%.svn\." GOTO :SVN_UPDATE
+IF EXIST "%DEPOT_TOOLS_DIR%.git\." GOTO :GIT_UPDATE
echo Error updating depot_tools, no revision tool found.
goto :EOF
:SVN_UPDATE
-call svn up -q "%~dp0."
+call svn up -q "%DEPOT_TOOLS_DIR%."
goto :EOF
:GIT_UPDATE
-cd /d "%~dp0."
+cd /d "%DEPOT_TOOLS_DIR%."
call git config remote.origin.fetch > NUL
if errorlevel 1 goto :GIT_SVN_UPDATE
for /F %%x in ('git config --get remote.origin.url') DO (
@@ -51,6 +63,6 @@ call git rebase -q origin/master > NUL
goto :EOF
:GIT_SVN_UPDATE
-cd /d "%~dp0."
+cd /d "%DEPOT_TOOLS_DIR%."
call git svn rebase -q -q
goto :EOF
Message was sent while issue was closed.
Committed patchset #4 manually as r189429.
Message was sent while issue was closed.
On 2013/03/20 22:13:26, szager1 wrote: > Committed patchset #4 manually as r189429. Did you commit from a windows machine to be sure it still works? :D
On Wed, Mar 20, 2013 at 3:17 PM, <maruel@chromium.org> wrote: > On 2013/03/20 22:13:26, szager1 wrote: > >> Committed patchset #4 manually as r189429. >> > > Did you commit from a windows machine to be sure it still works? > > :D > Yechh. No, I didn't. But I just updated my win checkout, and it works for me. |
