#! /bin/csh -f

#
# Script to move files around for the editor reorganization
# (bug http://bugzilla.mozilla.org/show_bug.cgi?id=66345).
# Adapted from Kin's .bat file.
#

# set verbose

set dir = `pwd`

# ********************************************************
# *
# * Now link the files from base to the correct place.
# * When we do this for real, we'll need to mv 
# * in the repository rather than ln.
# *
# ********************************************************
# set golive
if ($?golive) then
  set CMD = "cp"
  set OLDBASE = "$dir/base"
else
  set CMD = "ln -s"
  set OLDBASE = "$OLDBASE"
endif

# ****************************************************
# *
# * Start assuming that everything is still in base,
# * and the new directories are not there.
# *
# ****************************************************
if (! $?golive) then
  if (-d oldbase) then
    echo oldbase is already there -- please clean up before running this
    exit
  endif
endif

# **********************************
# *
# * Move the base directory aside
# *
# **********************************
if (! $?golive) then
  mv base oldbase
endif

# **********************************************
# *
# * Create the neccessary source directories.
# *
# **********************************************
mkdir -p libeditor/public
mkdir -p libeditor/base
mkdir -p libeditor/text
mkdir -p libeditor/html
mkdir -p libeditor/build

# ******************
# * libeditor/base
# ******************
$CMD $OLDBASE/nsEditorController.h libeditor/base/nsEditorController.h
$CMD $OLDBASE/nsEditorController.cpp libeditor/base/nsEditorController.cpp
$CMD $OLDBASE/nsIEditProperty.h libeditor/base/nsIEditProperty.h
$CMD $OLDBASE/ChangeAttributeTxn.cpp libeditor/base/ChangeAttributeTxn.cpp
$CMD $OLDBASE/CreateElementTxn.cpp libeditor/base/CreateElementTxn.cpp
$CMD $OLDBASE/DeleteElementTxn.cpp libeditor/base/DeleteElementTxn.cpp
$CMD $OLDBASE/DeleteRangeTxn.cpp libeditor/base/DeleteRangeTxn.cpp
$CMD $OLDBASE/DeleteTextTxn.cpp libeditor/base/DeleteTextTxn.cpp
$CMD $OLDBASE/EditAggregateTxn.cpp libeditor/base/EditAggregateTxn.cpp
$CMD $OLDBASE/EditTxn.cpp libeditor/base/EditTxn.cpp
$CMD $OLDBASE/IMETextTxn.h libeditor/base/IMETextTxn.h
$CMD $OLDBASE/InsertElementTxn.cpp libeditor/base/InsertElementTxn.cpp
$CMD $OLDBASE/InsertTextTxn.cpp libeditor/base/InsertTextTxn.cpp
$CMD $OLDBASE/JoinElementTxn.cpp libeditor/base/JoinElementTxn.cpp
$CMD $OLDBASE/nsEditorCommands.cpp libeditor/base/nsEditorCommands.cpp
$CMD $OLDBASE/nsEditor.cpp libeditor/base/nsEditor.cpp
$CMD $OLDBASE/nsEditorService.cpp libeditor/base/nsEditorService.cpp
$CMD $OLDBASE/nsEditorUtils.cpp libeditor/base/nsEditorUtils.cpp
$CMD $OLDBASE/nsSelectionState.cpp libeditor/base/nsSelectionState.cpp
$CMD $OLDBASE/nsStyleSheetTxns.cpp libeditor/base/nsStyleSheetTxns.cpp
$CMD $OLDBASE/PlaceholderTxn.cpp libeditor/base/PlaceholderTxn.cpp
$CMD $OLDBASE/SetDocTitleTxn.cpp libeditor/base/SetDocTitleTxn.cpp
$CMD $OLDBASE/SplitElementTxn.cpp libeditor/base/SplitElementTxn.cpp
$CMD $OLDBASE/TransactionFactory.cpp libeditor/base/TransactionFactory.cpp
$CMD $OLDBASE/ChangeAttributeTxn.h libeditor/base/ChangeAttributeTxn.h
$CMD $OLDBASE/CreateElementTxn.h libeditor/base/CreateElementTxn.h
$CMD $OLDBASE/DeleteElementTxn.h libeditor/base/DeleteElementTxn.h
$CMD $OLDBASE/DeleteRangeTxn.h libeditor/base/DeleteRangeTxn.h
$CMD $OLDBASE/DeleteTextTxn.h libeditor/base/DeleteTextTxn.h
$CMD $OLDBASE/EditAggregateTxn.h libeditor/base/EditAggregateTxn.h
$CMD $OLDBASE/EditTxn.h libeditor/base/EditTxn.h
$CMD $OLDBASE/IMETextTxn.cpp libeditor/base/IMETextTxn.cpp
$CMD $OLDBASE/InsertElementTxn.h libeditor/base/InsertElementTxn.h
$CMD $OLDBASE/InsertTextTxn.h libeditor/base/InsertTextTxn.h
$CMD $OLDBASE/JoinElementTxn.h libeditor/base/JoinElementTxn.h
$CMD $OLDBASE/nsEditorCommands.h libeditor/base/nsEditorCommands.h
$CMD $OLDBASE/nsEditorFactory.h libeditor/base/nsEditorFactory.h
$CMD $OLDBASE/nsEditor.h libeditor/base/nsEditor.h
$CMD $OLDBASE/nsEditorService.h libeditor/base/nsEditorService.h
$CMD $OLDBASE/nsEditorUtils.h libeditor/base/nsEditorUtils.h
$CMD $OLDBASE/nsEditRules.h libeditor/base/nsEditRules.h
$CMD $OLDBASE/nsIAbsorbingTransaction.h libeditor/base/nsIAbsorbingTransaction.h
$CMD $OLDBASE/nsIEditorSupport.h libeditor/base/nsIEditorSupport.h
$CMD $OLDBASE/nsSelectionState.h libeditor/base/nsSelectionState.h
$CMD $OLDBASE/nsStyleSheetTxns.h libeditor/base/nsStyleSheetTxns.h
$CMD $OLDBASE/PlaceholderTxn.h libeditor/base/PlaceholderTxn.h
$CMD $OLDBASE/SetDocTitleTxn.h libeditor/base/SetDocTitleTxn.h
$CMD $OLDBASE/SplitElementTxn.h libeditor/base/SplitElementTxn.h
$CMD $OLDBASE/TransactionFactory.h libeditor/base/TransactionFactory.h

# ******************
# * libeditor/text
# ******************
$CMD $OLDBASE/nsAOLCiter.h libeditor/text/nsAOLCiter.h
$CMD $OLDBASE/nsEditorEventListeners.h libeditor/text/nsEditorEventListeners.h
$CMD $OLDBASE/nsInternetCiter.h libeditor/text/nsInternetCiter.h
$CMD $OLDBASE/nsPlaintextEditor.h libeditor/text/nsPlaintextEditor.h
$CMD $OLDBASE/nsTextEditRules.h libeditor/text/nsTextEditRules.h
$CMD $OLDBASE/nsTextEditRulesBidi.h libeditor/text/nsTextEditRulesBidi.h
$CMD $OLDBASE/nsWrapUtils.h libeditor/text/nsWrapUtils.h
$CMD $OLDBASE/nsAOLCiter.cpp libeditor/text/nsAOLCiter.cpp
$CMD $OLDBASE/nsEditorEventListeners.cpp libeditor/text/nsEditorEventListeners.cpp
$CMD $OLDBASE/nsInternetCiter.cpp libeditor/text/nsInternetCiter.cpp
$CMD $OLDBASE/nsPlaintextDataTransfer.cpp libeditor/text/nsPlaintextDataTransfer.cpp
$CMD $OLDBASE/nsPlaintextEditor.cpp libeditor/text/nsPlaintextEditor.cpp
$CMD $OLDBASE/nsTextEditRules.cpp libeditor/text/nsTextEditRules.cpp
$CMD $OLDBASE/nsWrapUtils.cpp libeditor/text/nsWrapUtils.cpp
$CMD $OLDBASE/nsTextEditUtils.h libeditor/text/nsTextEditUtils.h
$CMD $OLDBASE/nsTextEditUtils.cpp libeditor/text/nsTextEditUtils.cpp

# ******************
# * libeditor/html
# ******************
$CMD $OLDBASE/nsEditorTxnLog.h libeditor/html/nsEditorTxnLog.h
$CMD $OLDBASE/nsEditProperty.h libeditor/html/nsEditProperty.h
$CMD $OLDBASE/nsHTMLEditor.h libeditor/html/nsHTMLEditor.h
$CMD $OLDBASE/nsHTMLEditorLog.h libeditor/html/nsHTMLEditorLog.h
$CMD $OLDBASE/nsHTMLEditRules.h libeditor/html/nsHTMLEditRules.h
$CMD $OLDBASE/nsHTMLEditUtils.h libeditor/html/nsHTMLEditUtils.h
$CMD $OLDBASE/nsIHTMLEditRules.h libeditor/html/nsIHTMLEditRules.h
$CMD $OLDBASE/nsHTMLURIRefObject.h libeditor/html/nsHTMLURIRefObject.h
$CMD $OLDBASE/nsHTMLURIRefObject.cpp libeditor/html/nsHTMLURIRefObject.cpp
$CMD $OLDBASE/TextEditorTest.h libeditor/html/TextEditorTest.h
$CMD $OLDBASE/TypeInState.h libeditor/html/TypeInState.h
$CMD $OLDBASE/nsEditorTxnLog.cpp libeditor/html/nsEditorTxnLog.cpp
$CMD $OLDBASE/nsEditProperty.cpp libeditor/html/nsEditProperty.cpp
$CMD $OLDBASE/nsHTMLDataTransfer.cpp libeditor/html/nsHTMLDataTransfer.cpp
$CMD $OLDBASE/nsHTMLEditor.cpp libeditor/html/nsHTMLEditor.cpp
$CMD $OLDBASE/nsHTMLEditorLog.cpp libeditor/html/nsHTMLEditorLog.cpp
$CMD $OLDBASE/nsHTMLEditorStyle.cpp libeditor/html/nsHTMLEditorStyle.cpp
$CMD $OLDBASE/nsHTMLEditRules.cpp libeditor/html/nsHTMLEditRules.cpp
$CMD $OLDBASE/nsHTMLEditUtils.cpp libeditor/html/nsHTMLEditUtils.cpp
$CMD $OLDBASE/nsWSRunObject.h libeditor/html/nsWSRunObject.h
$CMD $OLDBASE/nsWSRunObject.cpp libeditor/html/nsWSRunObject.cpp
$CMD $OLDBASE/nsTableEditor.cpp libeditor/html/nsTableEditor.cpp
$CMD $OLDBASE/TextEditorTest.cpp libeditor/html/TextEditorTest.cpp
$CMD $OLDBASE/TypeInState.cpp libeditor/html/TypeInState.cpp

# ******************
# * libeditor/build
# ******************
$CMD $OLDBASE/nsEditorRegistration.cpp libeditor/build/nsEditorRegistration.cpp
$CMD $OLDBASE/nsTextEditorReg.cpp libeditor/build/nsTextEditorReg.cpp
# ******************
# * composer
# ******************

mkdir -p composer/src

$CMD $OLDBASE/nsComposerCommands.h composer/src/nsComposerCommands.h
$CMD $OLDBASE/nsComposerCommands.cpp composer/src/nsComposerCommands.cpp
$CMD $OLDBASE/nsComposerController.cpp composer/src/nsComposerController.cpp
$CMD $OLDBASE/nsComposerController.h composer/src/nsComposerController.h
$CMD $OLDBASE/nsEditorShell.h composer/src/nsEditorShell.h
$CMD $OLDBASE/nsEditorParserObserver.h composer/src/nsEditorParserObserver.h
$CMD $OLDBASE/nsEditorShellFactory.h composer/src/nsEditorShellFactory.h
$CMD $OLDBASE/nsEditorShellMouseListener.h composer/src/nsEditorShellMouseListener.h
$CMD $OLDBASE/nsInterfaceState.h composer/src/nsInterfaceState.h
$CMD $OLDBASE/nsEditorParserObserver.cpp composer/src/nsEditorParserObserver.cpp
$CMD $OLDBASE/nsEditorShell.cpp composer/src/nsEditorShell.cpp
$CMD $OLDBASE/nsEditorShellMouseListener.cpp composer/src/nsEditorShellMouseListener.cpp
$CMD $OLDBASE/nsInterfaceState.cpp composer/src/nsInterfaceState.cpp

# *************************************************************
# *
# * Now copy the resources to their new location:
# * need to rewrite this to go file by file when we go "live".
# * But we're not actually doing this now.
# *
# *************************************************************

if (0) then
  mv ui oldui
  mkdir -p composer/resources/app/
  mkdir -p composer/resources/dialogs

  mv jar.mn ojar.mn
  $CMD $dir/ojar.mn composer/jar.mn

  $CMD $dir/oldui/composer/content composer/resources/app/content
  $CMD $dir/oldui/composer/locale composer/resources/app/locale
  $CMD $dir/oldui/dialogs composer/resources/dialogs
endif

# ********************************************************
# *
# * Now copy new src files into the tree:
# *
# ********************************************************

if (! $?golive) then
  set newfiledir = /builds/reorgnew

  cp $newfiledir/Makefile.in Makefile.in
  cp $newfiledir/libeditor/Makefile.in libeditor/Makefile.in
  cp $newfiledir/libeditor/base/Makefile.in libeditor/base/Makefile.in
  cp $newfiledir/libeditor/text/Makefile.in libeditor/text/Makefile.in
  cp $newfiledir/libeditor/html/Makefile.in libeditor/html/Makefile.in
  cp $newfiledir/libeditor/build/Makefile.in libeditor/build/Makefile.in
  cp $newfiledir/composer/Makefile.in composer/Makefile.in
  cp $newfiledir/composer/src/Makefile.in composer/src/Makefile.in
endif


