wx2hg.sh revision cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "%Z%%M% %I% %E% SMI"
#
#
# Convert a wx-based workspace to Mercurial.
#
usage="wx2hg [-u] [-r hg_rev] [-t hg_ws] codemgr_ws"
#
# If "yes", then give some hints about cleanup and rerunning after a
# failure.
#
function has_hg_twin {
}
function clone_twin {
ws="$2"
rev="$3"
echo "Teamware parent $1 has an hg twin"
echo "Cloning $twin"
echo "to $ws"
set -x
set +x
for dir in $clonedirs; do
done
}
function fail {
print -u2 "Please run"
print -u2 "before retrying."
fi
exit 1
}
function warn {
}
function note {
}
#
# Command-line processing, sanity checks, and setup.
#
[[ -n $(whence workspace) ]] ||
fail "workspace command not found; please check PATH."
# do a wx update?
#
# Mercurial workspace to populate. Default is to create, in the same
# directory as the Teamware workspace, a new Mercurial workspace cloned
# from the hg_twin of the Teamware parent.
#
hg_ws=""
#
# Revision in the Mercurial workspace to apply the changes to.
# Default is to get the most recent revision (tip), thus avoiding
# the need for a merge unless overridden by the caller using -r.
#
hg_rev="tip"
while getopts r:t:u opt; do
esac
done
if [[ $# -ne 1 ]]; then
exit 1
fi
CODEMGR_WS="$1"
export CODEMGR_WS
if [[ -n "$hg_ws" ]]; then
fi
fi
cd "$CODEMGR_WS"
[[ -n "$codemgr_parent" ]] || \
fail "$CODEMGR_WS is not a Teamware workspace or does not have a parent."
#
# Do this check before time-consuming operations like creating
# the target repo.
#
his=$(find Codemgr_wsdata -name history -mtime -1)
if [[ -z "$his" ]]; then
warn "history file is more than one day old; do you need to" \
"bringover from $codemgr_parent?"
fi
# Less time-consuming than cloning
if [[ ! -d wx ]]; then
print "Initializing wx..."
else
if [[ "$do_update" = yes ]]; then
print "Updating wx state..."
fi
fi
active_files=$(wx list)
if [[ ! -z "$out_files" ]]; then
fail "wx2hg will only migrate checked-in files;" \
"please check in these files with wx ci and try again"
fi
# more time-consuming than wx update and wx outchk
if [[ -z "$hg_ws" ]]; then
fi
if [[ -d "$hg_ws" ]]; then
else
if has_hg_twin "$codemgr_parent"; then
else
fail "$codemgr_parent is not recognized as a gate;" \
"please provide a Mercurial workspace (-t hg_ws)" \
"that matches it."
fi
fi
# Make sure hg_ws is an absolute path
#
# Do renames first, because they'll be listed with the new name by "wx
# list". There's a conflict if the new name already exists or if the
# old name does not exist. We can theoretically recover from the
# former (move the existing file out of the way, or pick a different
# new name), but not the latter. For now, just error out and let the
# user fix up the workspace so that there isn't a conflict.
#
# usage: do_rename oldname newname
function do_rename {
typeset old=$1
typeset new=$2
set -x
set +x
}
if [[ -s "$renamelist" ]]; then
cd "$hg_ws"
while :; do
done
) || exit 1
fi
#
# usage: name_in_parent fname
# If fname had been renamed, echo the old name. Otherwise echo the
# given name.
#
function name_in_parent {
print "$old"
return
fi
done
fi
print "$1"
}
#
# Now do content changes. There's a likely conflict if the file in
# Mercurial is different from the file in the Teamware parent.
#
for f in $active_files; do
#
# Get the name that the file appears in the parent as.
#
# We need unexpanded SCCS keywords for both parent and child
if [[ -f "$codemgr_parent/$oldname" ]]; then
else
rm -f $parentfile
fi
if [[ ! -r "$parentfile" ]]; then
print "new file: $f"
set -x
set +x
print "skipping $f (unchanged)."
continue
fi
else
diff -u "$parentfile" "$hg_ws/$f"
echo ""
fail "For file:\n\n\t$f\n\nthe teamware parent:" \
"\n\n\t$codemgr_parent" \
"\n\ndoesn't match its mercurial twin;" \
"specify the matching revision in mercurial\nwith" \
"-r hg_rev, or resynchronize them.\n"
fi
done
if [[ "$hg_rev" != "tip" ]]; then
fi
rm -f "$parentfile" "$patchfile" "$renamelist" "$childfile"
exit 0