├── post-process_files ├── gitignore-build ├── gitignore-src-sage-ext-interpreters ├── gitignore-src ├── gitignore-src-c_lib ├── gitignore-root ├── gitignore-src-doc ├── gitignore-src-sage ├── sage-build ├── docbuild1.patch ├── singular1.patch ├── gcc1.patch ├── makefile1.patch ├── sage1.patch ├── ntl1.patch ├── prereq-install1.patch ├── setup1.patch ├── sage-starts1.patch ├── csage1.patch ├── sage-envpy1.patch ├── sage_data1.patch ├── sage_artifacts1.patch ├── sage-spkg1.patch ├── sagenb1.patch ├── makefile2.patch ├── devel_doctests1.patch ├── sage-spkg2.patch ├── whitespace1.patch ├── sage-env1.patch ├── install1.patch ├── hg1.patch └── deps1.patch ├── .gitignore ├── fast-export ├── .gitignore ├── Makefile ├── hg-reset.sh ├── README ├── hg-fast-export.sh ├── hg2git.py ├── hg-reset.py ├── svn-fast-export.c ├── svn-fast-export.py ├── svn-archive.c └── hg-fast-export.py ├── failed_doctests.txt ├── configuration.sh ├── workflow-sep.rst ├── post-process.sh ├── README.rst ├── combinat.rst ├── consolidate-repos.sh └── git-filter-branch /post-process_files/gitignore-build: -------------------------------------------------------------------------------- 1 | /Makefile 2 | -------------------------------------------------------------------------------- /post-process_files/gitignore-src-sage-ext-interpreters: -------------------------------------------------------------------------------- 1 | * 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.pyc 3 | */.#* 4 | */#* 5 | /sagedev/venv 6 | -------------------------------------------------------------------------------- /post-process_files/gitignore-src: -------------------------------------------------------------------------------- 1 | /build 2 | /.cython_version 3 | -------------------------------------------------------------------------------- /post-process_files/gitignore-src-c_lib: -------------------------------------------------------------------------------- 1 | *.so 2 | *.os 3 | .sconsign.dblite 4 | -------------------------------------------------------------------------------- /fast-export/.gitignore: -------------------------------------------------------------------------------- 1 | svn-archive 2 | svn-fast-export 3 | *.pyc 4 | .dotest 5 | -------------------------------------------------------------------------------- /post-process_files/gitignore-root: -------------------------------------------------------------------------------- 1 | /local 2 | /__SAGE_TARBALLS__ 3 | /.BUILDSTART 4 | /logs 5 | *.pyc 6 | -------------------------------------------------------------------------------- /post-process_files/gitignore-src-doc: -------------------------------------------------------------------------------- 1 | /output 2 | /en/reference/sage 3 | /en/reference/sagenb 4 | /en/reference/*/sage 5 | /en/reference/*/sagenb 6 | -------------------------------------------------------------------------------- /post-process_files/gitignore-src-sage: -------------------------------------------------------------------------------- 1 | *.c 2 | *.cpp 3 | /libs/pari/gen.h 4 | /modular/arithgroup/farey_symbol.h 5 | /rings/real_mpfi.h 6 | /symbolic/pynac.h 7 | -------------------------------------------------------------------------------- /failed_doctests.txt: -------------------------------------------------------------------------------- 1 | sage -t src/sage/tests/cmdline.py # 1 doctest failed 2 | sage -t src/sage/all.py # 1 doctest failed 3 | 4 | # fix new option to use git instead of mecurial 5 | sage -t src/sage/doctest/control.py # 2 doctests failed 6 | 7 | # fixed upstream 8 | sage -t local/lib/python2.7/site-packages/sagenb-0.10.4-py2.7.egg/sagenb/misc/misc.py # 4 doctests failed 9 | -------------------------------------------------------------------------------- /fast-export/Makefile: -------------------------------------------------------------------------------- 1 | SVN ?= /usr/local/svn 2 | APR_INCLUDES ?= /usr/include/apr-1.0 3 | CFLAGS += -I${APR_INCLUDES} -I${SVN}/include/subversion-1 -pipe -O2 -std=c99 4 | LDFLAGS += -L${SVN}/lib -lsvn_fs-1 -lsvn_repos-1 5 | 6 | all: svn-fast-export svn-archive 7 | 8 | svn-fast-export: svn-fast-export.c 9 | svn-archive: svn-archive.c 10 | 11 | .PHONY: clean 12 | 13 | clean: 14 | rm -rf svn-fast-export svn-archive 15 | -------------------------------------------------------------------------------- /post-process_files/sage-build: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | if [ -z "$SAGE_SRC" ]; then 4 | echo 5 | echo "SAGE_SRC undefined ... exiting" 6 | return 1 7 | fi 8 | 9 | if [ "$1" = "-b" ]; then 10 | DO_BUILD_ALL=1 11 | shift 12 | else 13 | DO_BUILD_ALL=0 14 | fi 15 | 16 | if [ $DO_BUILD_ALL = 1 ]; then 17 | echo "*** TOUCHING ALL CYTHON (.pyx) FILES ***" 18 | find "$SAGE_SRC"/sage -name "*.pyx" | xargs touch 2>/dev/null 19 | fi 20 | 21 | # exit on failures 22 | set -e 23 | 24 | # build c_lib 25 | cd "$SAGE_SRC"/c_lib 26 | scons -Q install 27 | 28 | # build sage library 29 | cd "$SAGE_SRC" 30 | python setup.py install 31 | -------------------------------------------------------------------------------- /post-process_files/docbuild1.patch: -------------------------------------------------------------------------------- 1 | From fb3c98e77096a5f4b53cdb5e6e70d0bce19d52c4 Mon Sep 17 00:00:00 2001 2 | From: "R. Andrew Ohana" 3 | Date: Tue, 19 Mar 2013 10:41:59 -0700 4 | Subject: [PATCH] (FIXUP) correct path for docbuilder 5 | 6 | --- 7 | 8 | diff --git a/__SAGE_SCRIPTS_DIR__/sage b/__SAGE_SCRIPTS_DIR__/sage 9 | index 08df18d..ee161a6 100755 10 | --- a/src/bin/sage 11 | +++ b/src/bin/sage 12 | @@ -921,7 +921,7 @@ fi 13 | 14 | if [ "$1" = "-docbuild" -o "$1" = "--docbuild" ]; then 15 | shift 16 | - exec python "$SAGE_ROOT/devel/sage/doc/common/builder.py" "$@" 17 | + exec python "$SAGE_SRC/doc/common/builder.py" "$@" 18 | fi 19 | 20 | if [ "$1" = '-gdb' -o "$1" = "--gdb" ]; then 21 | -- 22 | 1.8.1.5 23 | 24 | -------------------------------------------------------------------------------- /post-process_files/singular1.patch: -------------------------------------------------------------------------------- 1 | From 2e5a8651ad497b383ff3272ac4a4aa062b6a3f27 Mon Sep 17 00:00:00 2001 2 | From: "R. Andrew Ohana" 3 | Date: Thu, 21 Mar 2013 15:09:07 -0700 4 | Subject: [PATCH] (FIXUP) singular: move shared 5 | 6 | --- 7 | 8 | diff --git a/__SAGE_BUILD__/pkgs/singular/spkg-install b/__SAGE_BUILD__/pkgs/singular/spkg-install 9 | index 4e2ca47..fea3bcf 100755 10 | --- a/__SAGE_BUILD__/pkgs/singular/spkg-install 11 | +++ b/__SAGE_BUILD__/pkgs/singular/spkg-install 12 | @@ -5,7 +5,7 @@ 13 | ########################################### 14 | 15 | SRC=`pwd`/src 16 | -SHARED=`pwd`/shared 17 | +SHARED="$SRC/shared" 18 | 19 | if [ "$SAGE_LOCAL" = "" ]; then 20 | echo >&2 "SAGE_LOCAL undefined ... exiting"; 21 | -- 22 | 1.8.1.5 23 | 24 | -------------------------------------------------------------------------------- /post-process_files/gcc1.patch: -------------------------------------------------------------------------------- 1 | From 7e5cb5f480e55257610ae43e2750607920779ae1 Mon Sep 17 00:00:00 2001 2 | From: Julian Rueth 3 | Date: Thu, 28 Mar 2013 07:01:08 +0100 4 | Subject: [PATCH] fixed gcc compile error 5 | 6 | --- 7 | build/pkgs/gcc/spkg-install | 2 +- 8 | 1 file changed, 1 insertion(+), 1 deletion(-) 9 | 10 | diff --git a/build/pkgs/gcc/spkg-install b/build/pkgs/gcc/spkg-install 11 | index 68ae02d..78eb9b4 100755 12 | --- a/build/pkgs/gcc/spkg-install 13 | +++ b/build/pkgs/gcc/spkg-install 14 | @@ -93,5 +93,5 @@ $MAKE install 15 | 16 | 17 | # Force re-installation of mpir, mpfr and mpc with the GCC we just built. 18 | -cd "$SAGE_ROOT/spkg/installed" 19 | +cd "$SAGE_SPKG_INST" 20 | rm -f mpir-* mpfr-* mpc-* 21 | -- 22 | 1.8.2.200.g7632cd2 23 | 24 | -------------------------------------------------------------------------------- /post-process_files/makefile1.patch: -------------------------------------------------------------------------------- 1 | From de7022642dc5536d29bba134943cb6aafa915f12 Mon Sep 17 00:00:00 2001 2 | From: "R. Andrew Ohana" 3 | Date: Sat, 23 Mar 2013 14:07:02 -0700 4 | Subject: [PATCH] (FIXUP) Makefile: correct TESTDIRS 5 | 6 | --- 7 | 8 | diff --git a/Makefile b/Makefile 9 | index 241f9ab..6a5bbb9 100644 10 | --- a/Makefile 11 | +++ b/Makefile 12 | @@ -101,7 +101,7 @@ text-collapse: 13 | TESTPRELIMS = local/bin/sage-starts 14 | # The [a-z][a-z] matches all directories whose names consist of two 15 | # lower-case letters, to match the language directories. 16 | -TESTDIRS = devel/sage/doc/common devel/sage/doc/[a-z][a-z] devel/sage/sage 17 | +TESTDIRS = __SAGE_SRC__/doc/common __SAGE_SRC__/doc/[a-z][a-z] __SAGE_SRC__/sage 18 | 19 | test: all # i.e. build and doc 20 | $(TESTPRELIMS) 21 | -- 22 | 1.8.1.5 23 | 24 | -------------------------------------------------------------------------------- /post-process_files/sage1.patch: -------------------------------------------------------------------------------- 1 | From 9b59d4f48031310a1697ee67c1fa76f3e445e266 Mon Sep 17 00:00:00 2001 2 | From: "R. Andrew Ohana" 3 | Date: Sun, 17 Mar 2013 01:58:55 -0700 4 | Subject: [PATCH] (FIXUP) sage: fix pipestatus location 5 | 6 | --- 7 | 8 | diff --git a/__SAGE_SCRIPTS_DIR__/sage b/__SAGE_SCRIPTS_DIR__/sage 9 | index d1e6759..e2968f3 100755 10 | --- a/__SAGE_SCRIPTS_DIR__/sage 11 | +++ b/__SAGE_SCRIPTS_DIR__/sage 12 | @@ -808,7 +808,7 @@ install() { 13 | PKG_NAME=`echo "$PKG" | sed -e "s/\.spkg$//"` 14 | PKG_NAME=`basename "$PKG_NAME"` 15 | 16 | - "$SAGE_ROOT"/spkg/pipestatus \ 17 | + "$SAGE_ROOT"/__SAGE_BUILD__/pipestatus \ 18 | "sage-spkg $OPTINFO $OPTF $OPTS $OPTC '$PKG' 2>&1" \ 19 | "(trap '' SIGINT; tee -a '$SAGE_ROOT/install.log' '$SAGE_LOGS/$PKG_NAME.log')" 20 | # Do not try to install further packages if one failed 21 | -- 22 | 1.8.1.5 23 | 24 | -------------------------------------------------------------------------------- /post-process_files/ntl1.patch: -------------------------------------------------------------------------------- 1 | From 3b32f945d5cddd129eb7b3c8b5f4b4a3c41adcec Mon Sep 17 00:00:00 2001 2 | From: "R. Andrew Ohana" 3 | Date: Thu, 21 Mar 2013 15:04:50 -0700 4 | Subject: [PATCH] (FIXUP) ntl: move libtool 5 | 6 | --- 7 | 8 | diff --git a/__SAGE_BUILD__/pkgs/ntl/spkg-install b/__SAGE_BUILD__/pkgs/ntl/spkg-install 9 | index 2c069fe..56d65e5 100755 10 | --- a/__SAGE_BUILD__/pkgs/ntl/spkg-install 11 | +++ b/__SAGE_BUILD__/pkgs/ntl/spkg-install 12 | @@ -25,7 +25,7 @@ ntl_libtool() 13 | { 14 | echo "Generating libtool." 15 | 16 | - cd "$CUR/libtool" 17 | + cd "$CUR/__SAGE_SRC__/libtool" 18 | 19 | ./configure 20 | 21 | @@ -81,7 +81,7 @@ ntl_configure() 22 | CXX="$CXX" CXXFLAGS="$CXXFLAGS $SHAREDFLAGS" \ 23 | LDFLAGS="$LDFLAGS" LIBTOOL_LINK_FLAGS="$LIBTOOL_LINK_FLAGS" \ 24 | NTL_GMP_LIP=on NTL_STD_CXX=on \ 25 | - LIBTOOL=../../libtool/libtool 26 | + LIBTOOL=../libtool/libtool 27 | 28 | if [ $? -ne 0 ]; then 29 | echo >&2 "Unable to configure NTL." 30 | -- 31 | 1.8.1.5 32 | 33 | -------------------------------------------------------------------------------- /configuration.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | WORKFLOW_DIR=$(readlink -f "$0") 4 | WORKFLOW_DIR=${WORKFLOW_DIR%/*} 5 | 6 | SAGE_BUILD=build 7 | SAGE_SRC=src 8 | SAGE_TARBALLS=upstream 9 | SAGE_LOGS_DIR=logs/pkgs 10 | SAGE_PKGS=$SAGE_BUILD/pkgs 11 | SAGE_SCRIPTS_REL=bin 12 | SAGE_SCRIPTS_DIR=$SAGE_SRC/$SAGE_SCRIPTS_REL 13 | SAGE_MACAPP=$SAGE_SRC/mac-app 14 | SAGE_EXTREL=ext 15 | SAGE_EXTDIR=$SAGE_SRC/$SAGE_EXTREL 16 | SAGE_INSTALLED="\$SAGE_LOCAL/var/lib/sage/installed" 17 | SAGE_ARTIFACTS=$SAGE_BUILD/artifacts 18 | 19 | SAGE_CONSTANTS=$(cat < 3 | Date: Sun, 17 Mar 2013 00:55:41 -0700 4 | Subject: [PATCH] (FIXUP) update prereq-install 5 | 6 | --- 7 | 8 | diff --git a/__SAGE_BUILD__/base/prereq-1.1-install b/__SAGE_BUILD__/base/prereq-1.1-install 9 | index 3123e66..d321c50 100755 10 | --- a/__SAGE_BUILD__/base/prereq-1.1-install 11 | +++ b/__SAGE_BUILD__/base/prereq-1.1-install 12 | @@ -5,7 +5,7 @@ 13 | 14 | TARGET=prereq-1.1 15 | if [ "x$SAGE_BUILD_DIR" = x ]; then 16 | - SAGE_BUILD_DIR="$SAGE_ROOT/spkg/build" 17 | + SAGE_BUILD_DIR="$SAGE_ROOT/__SAGE_ARTIFACTS__" 18 | fi 19 | mkdir -p "$SAGE_BUILD_DIR" 20 | if [ $? -ne 0 ]; then 21 | @@ -128,7 +128,7 @@ fi 22 | # does not update the base packages and we cannot retro-actively change 23 | # that in earlier versions. So the only thing to do is to skip this 24 | # test. 25 | -prereq_tarball="$SAGE_ROOT/spkg/base/$TARGET.tar.gz" 26 | +prereq_tarball="$SAGE_ROOT/__SAGE_TARBALLS__/$TARGET.tar.gz" 27 | if [ -f "$prereq_tarball" ]; then 28 | gzip -cd "$prereq_tarball" | tar xf - --no-same-owner 29 | if [ $? -ne 0 ]; then 30 | -- 31 | 1.8.1.5 32 | 33 | -------------------------------------------------------------------------------- /post-process_files/setup1.patch: -------------------------------------------------------------------------------- 1 | From 911b94392e152c69451ee2a54f3472d87120369f Mon Sep 17 00:00:00 2001 2 | From: "R. Andrew Ohana" 3 | Date: Tue, 19 Mar 2013 10:42:39 -0700 4 | Subject: [PATCH] (TEMPORARY) remove symlinks for sage library 5 | 6 | --- 7 | 8 | diff --git a/__SAGE_SRC__/setup.py b/__SAGE_SRC__/setup.py 9 | index b72d2f6..a1bd53e 100644 10 | --- a/__SAGE_SRC__/setup.py 11 | +++ b/__SAGE_SRC__/setup.py 12 | @@ -38,18 +38,6 @@ except KeyError: 13 | 14 | SAGE_INC = os.path.join(SAGE_LOCAL,'include') 15 | 16 | -SITE_PACKAGES = '%s/lib/python%s/site-packages/'%(SAGE_LOCAL,platform.python_version().rsplit('.', 1)[0]) 17 | -if not os.path.exists(SITE_PACKAGES): 18 | - raise RuntimeError, "Unable to find site-packages directory (see setup.py file in sage python code)." 19 | - 20 | -if not os.path.exists('build/sage'): 21 | - os.makedirs('build/sage') 22 | - 23 | -sage_link = SITE_PACKAGES + '/sage' 24 | -if not os.path.islink(sage_link) or not os.path.exists(sage_link): 25 | - os.system('rm -rf "%s"'%sage_link) 26 | - os.system('cd %s; ln -sf ../../../../devel/sage/build/sage .'%SITE_PACKAGES) 27 | - 28 | # search for dependencies and add to gcc -I 29 | include_dirs = [SAGE_INC, 30 | os.path.join(SAGE_INC, 'csage'), 31 | -- 32 | 1.8.1.5 33 | 34 | -------------------------------------------------------------------------------- /post-process_files/sage-starts1.patch: -------------------------------------------------------------------------------- 1 | From 4109caa838ab0e6cef60a1ca2391216a812c374a Mon Sep 17 00:00:00 2001 2 | From: "R. Andrew Ohana" 3 | Date: Sun, 17 Mar 2013 01:01:23 -0700 4 | Subject: [PATCH] (FIXUP) update sage-starts 5 | 6 | --- 7 | 8 | diff --git a/__SAGE_SCRIPTS_DIR__/sage-starts b/__SAGE_SCRIPTS_DIR__/sage-starts 9 | index d9f034a..f9781a3 100755 10 | --- a/__SAGE_SCRIPTS_DIR__/sage-starts 11 | +++ b/__SAGE_SCRIPTS_DIR__/sage-starts 12 | @@ -9,18 +9,18 @@ fi 13 | 14 | echo 15 | echo "Testing that Sage starts..." 16 | -echo "[`date +'%Y-%m-%d %H:%M:%S'`] `cat VERSION.txt 2>/dev/null`" | tee -a start.log 17 | +echo "[`date +'%Y-%m-%d %H:%M:%S'`] `cat VERSION.txt 2>/dev/null`" | tee -a logs/start.log 18 | # This script is run by the top-level Makefile, so may be run by a 19 | # sysadmin. We use --nodotsage so we don't force a .sage directory 20 | # in the sysadmin's HOME directory. 21 | cmd='sage.all._write_started_file(); print "Yes, Sage starts."' 22 | -spkg/pipestatus "./sage --nodotsage -c '$cmd' 2>&1" "tee -a start.log" 23 | +__SAGE_BUILD__/pipestatus "./sage --nodotsage -c '$cmd' 2>&1" "tee -a logs/start.log" 24 | 25 | if [ $? -ne 0 ]; then 26 | echo >&2 "Sage failed to start up." 27 | echo >&2 "Please email sage-devel (http://groups.google.com/group/sage-devel)" 28 | echo >&2 "explaining the problem and send the log file" 29 | - echo >&2 " `pwd`/start.log" 30 | + echo >&2 " `pwd`/logs/start.log" 31 | echo >&2 "Describe your computer, operating system, etc." 32 | rm -f local/etc/sage-started.txt 33 | exit 1 34 | -- 35 | 1.8.1.5 36 | 37 | -------------------------------------------------------------------------------- /post-process_files/csage1.patch: -------------------------------------------------------------------------------- 1 | From 0d8964fa2f962fb2d5b9aef46d2d5b81fad2f7c5 Mon Sep 17 00:00:00 2001 2 | From: "R. Andrew Ohana" 3 | Date: Sun, 17 Mar 2013 01:11:35 -0700 4 | Subject: [PATCH] (FIXUP) copy csage, including headers 5 | 6 | --- 7 | 8 | diff --git a/__SAGE_SRC__/c_lib/SConstruct b/__SAGE_SRC__/c_lib/SConstruct 9 | index 11e5bc0..8f6d65b 100644 10 | --- a/__SAGE_SRC__/c_lib/SConstruct 11 | +++ b/__SAGE_SRC__/c_lib/SConstruct 12 | @@ -131,17 +131,15 @@ cFiles = Split( "convert.c interrupt.c memory.c mpn_pylong.c mpz_pylong.c") 13 | Split( "mpz_longlong.c stdsage.c gmp_globals.c" ) 14 | cppFiles = Split( "ZZ_pylong.cpp ntl_wrap.cpp" ) 15 | srcFiles = cFiles + cppFiles 16 | +incFiles = Split( "ccobject.h convert.h ginac_wrap.h gmp_globals.h" ) + \ 17 | + Split( "interrupt.h memory.h mpn_pylong.h mpz_longlong.h" ) + \ 18 | + Split( "mpz_pylong.h ntl_wrap.h pb_wrap.h stdsage.h ZZ_pylong.h" ) 19 | 20 | lib = env.SharedLibrary( "csage", [ "src/" + x for x in srcFiles ], 21 | LIBS=['ntl', 'pari', 'gmp', 'python$PYV'], 22 | LIBPATH=['$SAGE_LOCAL/lib','$SAGE_LOCAL/lib/python$PYV/config/'], 23 | CPPPATH=includes ) 24 | env.Install("$SAGE_LOCAL/lib", lib) 25 | +env.Install("$SAGE_LOCAL/include/csage", [ os.path.join('include',x) for x in incFiles ]) 26 | 27 | -#Here we only copy the files over if we are on Cygwin. Otherwise, the 28 | -#library will be handled by the symlinks created in 29 | -#$SAGE_ROOT/devel/sage/spkg-install 30 | -if os.environ['UNAME'] == 'CYGWIN': 31 | - env.Alias("install", "$SAGE_LOCAL/lib") 32 | -else: 33 | - env.Alias("install", [lib]) 34 | +env.Alias("install", "$SAGE_LOCAL") 35 | -- 36 | 1.8.1.5 37 | 38 | -------------------------------------------------------------------------------- /fast-export/hg-reset.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Copyright (c) 2007, 2008 Rocco Rutte and others. 4 | # License: MIT 5 | 6 | ROOT="`dirname $0`" 7 | REPO="" 8 | PFX="hg2git" 9 | SFX_MARKS="marks" 10 | SFX_MAPPING="mapping" 11 | SFX_HEADS="heads" 12 | SFX_STATE="state" 13 | QUIET="" 14 | PYTHON=${PYTHON:-python} 15 | 16 | USAGE="[-r ] -R " 17 | LONG_USAGE="Print SHA1s of latest changes per branch up to useful 18 | to reset import and restart at . 19 | If is omitted, use last hg repository as obtained from state file, 20 | GIT_DIR/$PFX-$SFX_STATE by default. 21 | 22 | Options: 23 | -R Hg revision to reset to 24 | -r Mercurial repository to use 25 | " 26 | 27 | . "$(git --exec-path)/git-sh-setup" 28 | cd_to_toplevel 29 | 30 | while case "$#" in 0) break ;; esac 31 | do 32 | case "$1" in 33 | -r|--r|--re|--rep|--repo) 34 | shift 35 | REPO="$1" 36 | ;; 37 | -*) 38 | # pass any other options down to hg2git.py 39 | break 40 | ;; 41 | *) 42 | break 43 | ;; 44 | esac 45 | shift 46 | done 47 | 48 | # for convenience: get default repo from state file 49 | if [ x"$REPO" = x -a -f "$GIT_DIR/$PFX-$SFX_STATE" ] ; then 50 | REPO="`egrep '^:repo ' "$GIT_DIR/$PFX-$SFX_STATE" | cut -d ' ' -f 2`" 51 | echo "Using last hg repository \"$REPO\"" 52 | fi 53 | 54 | # make sure we have a marks cache 55 | if [ ! -f "$GIT_DIR/$PFX-$SFX_MARKS" ] ; then 56 | touch "$GIT_DIR/$PFX-$SFX_MARKS" 57 | fi 58 | 59 | GIT_DIR="$GIT_DIR" $PYTHON "$ROOT/hg-reset.py" \ 60 | --repo "$REPO" \ 61 | --marks "$GIT_DIR/$PFX-$SFX_MARKS" \ 62 | --mapping "$GIT_DIR/$PFX-$SFX_MAPPING" \ 63 | --heads "$GIT_DIR/$PFX-$SFX_HEADS" \ 64 | --status "$GIT_DIR/$PFX-$SFX_STATE" \ 65 | "$@" 66 | 67 | exit $? 68 | -------------------------------------------------------------------------------- /post-process_files/sage-envpy1.patch: -------------------------------------------------------------------------------- 1 | From 8b9c87b67c1a5bd616858775427f3c9c0a77589b Mon Sep 17 00:00:00 2001 2 | From: "R. Andrew Ohana" 3 | Date: Sat, 23 Mar 2013 14:38:44 -0700 4 | Subject: [PATCH] (FIXUP) correct values in sage/env.py 5 | 6 | --- 7 | 8 | diff --git a/__SAGE_SRC__/sage/env.py b/__SAGE_SRC__/sage/env.py 9 | index d16f778..e6e5364 100644 10 | --- a/__SAGE_SRC__/sage/env.py 11 | +++ b/__SAGE_SRC__/sage/env.py 12 | @@ -37,17 +37,14 @@ SAGE_ENV = { 13 | 'SAGE_ROOT' : None, 14 | 'SAGE_LOCAL' : opj('$SAGE_ROOT', 'local'), 15 | 'SAGE_SHARE' : opj('$SAGE_LOCAL', 'share'), 16 | - # for backwards compatibility we include SAGE_DATA 17 | - 'SAGE_DATA' : '$SAGE_SHARE', 18 | 'SAGE_EXTCODE' : opj('$SAGE_SHARE', 'sage', 'ext'), 19 | - 'SAGE_PACKAGES' : opj('$SAGE_ROOT', 'spkg'), 20 | - 'SAGE_LOGS' : opj('$SAGE_ROOT', 'spkg', 'logs'), 21 | - 'SAGE_SPKG_INST' : opj('$SAGE_ROOT', 'spkg', 'installed'), 22 | - 'SAGE_DOC' : opj('$SAGE_ROOT', 'devel', 'sage', 'doc'), 23 | + 'SAGE_LOGS' : opj('$SAGE_ROOT', 'logs', 'pkgs'), 24 | + 'SAGE_SPKG_INST' : opj('$SAGE_LOCAL', 'var', 'lib', 'sage', 'installed'), 25 | + 'SAGE_DOC' : opj('$SAGE_SRC', 'doc'), 26 | 'DOT_SAGE' : opj(os.environ.get('HOME','$SAGE_ROOT'), '.sage'), 27 | # SAGE_LIB is the site-packages directory if the sage library 28 | # has been installed, otherwise it is the same of SAGE_SRC 29 | - 'SAGE_SRC' : opj('$SAGE_ROOT', 'devel', 'sage'), 30 | + 'SAGE_SRC' : opj('$SAGE_ROOT', '__SAGE_SRC__'), 31 | 'SAGE_LIB' : os.path.dirname(os.path.dirname(__file__)), 32 | 33 | # misc 34 | -- 35 | 1.8.1.5 36 | 37 | -------------------------------------------------------------------------------- /post-process_files/sage_data1.patch: -------------------------------------------------------------------------------- 1 | From 389950fbaf1ebae595fd1bdcd4255a44ac7b837b Mon Sep 17 00:00:00 2001 2 | From: "R. Andrew Ohana" 3 | Date: Sat, 23 Mar 2013 14:38:06 -0700 4 | Subject: [PATCH] (FIXUP) remove SAGE_DATA 5 | 6 | --- 7 | 8 | diff --git a/__SAGE_BUILD__/install b/__SAGE_BUILD__/install 9 | index 6cd4429..441ed98 100755 10 | --- a/__SAGE_BUILD__/install 11 | +++ b/__SAGE_BUILD__/install 12 | @@ -86,11 +86,6 @@ if [ -d "$SAGE_ROOT/data" ] && [ ! -h "$SAGE_ROOT/data" ]; then 13 | rm -rf "$SAGE_ROOT/data" 14 | fi 15 | 16 | -# Symlink old SAGE_DATA to SAGE_SHARE for optional/experimental 17 | -# packages that haven't yet been updated. 18 | -rm -f "$SAGE_ROOT/data" 19 | -ln -s local/share "$SAGE_ROOT/data" 20 | - 21 | ############################################################################### 22 | # Determine whether to install GCC (gcc, g++, gfortran). 23 | ############################################################################### 24 | diff --git a/__SAGE_SCRIPTS_DIR__/sage-env b/__SAGE_SCRIPTS_DIR__/sage-env 25 | index 2b2cd7a..3479b5a 100644 26 | --- a/__SAGE_SCRIPTS_DIR__/sage-env 27 | +++ b/__SAGE_SCRIPTS_DIR__/sage-env 28 | @@ -246,10 +246,6 @@ export SAGE_SRC="$SAGE_ROOT/src" 29 | export SAGE_DOC="$SAGE_SRC/doc" 30 | export PATH="$SAGE_SRC/bin:$SAGE_LOCAL/bin:$PATH" 31 | 32 | -# this is to be compatible with optional packages that haven't 33 | -# been updated to not use SAGE_DATA 34 | -export SAGE_DATA="$SAGE_SHARE" 35 | - 36 | # We offer a toolchain option, so if $SAGE_LOCAL/toolchain/toolchain-env exists source it. 37 | # Since the user might do something crazy we do not do any checks, but hope for the best. 38 | if [ -f $SAGE_LOCAL/toolchain/toolchain-env ]; then 39 | diff --git a/__SAGE_SCRIPTS_DIR__/sage-spkg b/__SAGE_SCRIPTS_DIR__/sage-spkg 40 | index 85ad4b7..edc5593 100755 41 | --- a/__SAGE_SCRIPTS_DIR__/sage-spkg 42 | +++ b/__SAGE_SCRIPTS_DIR__/sage-spkg 43 | @@ -16,7 +16,6 @@ 44 | # 45 | # SAGE_ROOT -- root directory of sage install 46 | # SAGE_LOCAL -- $SAGE_ROOT/local 47 | -# SAGE_DATA -- $SAGE_ROOT/data 48 | # LIBRARY_PATH, PYTHONPATH, LD_LIBRARY_PATH, DYLD_LIBRARY_PATH 49 | # CC, CXX, CFLAGS, CXXFLAGS, LDFLAGS, MAKE 50 | # 51 | -- 52 | 1.8.1.5 53 | 54 | -------------------------------------------------------------------------------- /post-process_files/sage_artifacts1.patch: -------------------------------------------------------------------------------- 1 | From b09daf7e960ea830bd9a2e2db1c0a3a5b45a5783 Mon Sep 17 00:00:00 2001 2 | From: "R. Andrew Ohana" 3 | Date: Wed, 20 Mar 2013 17:11:39 -0700 4 | Subject: [PATCH] (FIXUP) do not create spkg/build anymore 5 | 6 | --- 7 | 8 | diff --git a/__SAGE_SCRIPTS_DIR__/testcc.sh b/__SAGE_SCRIPTS_DIR__/testcc.sh 9 | index e80ecfb..e8bdf0c 100755 10 | --- a/__SAGE_SCRIPTS_DIR__/testcc.sh 11 | +++ b/__SAGE_SCRIPTS_DIR__/testcc.sh 12 | @@ -70,13 +70,13 @@ if [ -z "$SAGE_ROOT" ]; then 13 | exit 1 14 | fi 15 | 16 | -mkdir -p "$SAGE_ROOT/spkg/build" 17 | +mkdir -p "$SAGE_ROOT/__SAGE_ARTIFACTS__" 18 | if [ $? -ne 0 ]; then 19 | echo "Error while trying to create the build directory." 20 | exit 1 21 | fi 22 | 23 | -cd "$SAGE_ROOT/spkg/build" 24 | +cd "$SAGE_ROOT/__SAGE_ARTIFACTS__" 25 | if [ $? -ne 0 ]; then 26 | echo "Error while trying to change into the build directory." 27 | exit 1 28 | diff --git a/__SAGE_SCRIPTS_DIR__/testcflags.sh b/__SAGE_SCRIPTS_DIR__/testcflags.sh 29 | index 5f8fc0c..916276e 100755 30 | --- a/__SAGE_SCRIPTS_DIR__/testcflags.sh 31 | +++ b/__SAGE_SCRIPTS_DIR__/testcflags.sh 32 | @@ -82,13 +82,13 @@ if [ -z "$SAGE_ROOT" ]; then 33 | exit 1 34 | fi 35 | 36 | -mkdir -p "$SAGE_ROOT/spkg/build" 37 | +mkdir -p "$SAGE_ROOT/__SAGE_ARTIFACTS__" 38 | if [ $? -ne 0 ]; then 39 | echo "Error while trying to create the build directory." 40 | exit 1 41 | fi 42 | 43 | -cd "$SAGE_ROOT/spkg/build" 44 | +cd "$SAGE_ROOT/__SAGE_ARTIFACTS__" 45 | if [ $? -ne 0 ]; then 46 | echo "Error while trying to change into the build directory." 47 | exit 1 48 | diff --git a/__SAGE_SCRIPTS_DIR__/testcxx.sh b/__SAGE_SCRIPTS_DIR__/testcxx.sh 49 | index 4270ba0..6c98c67 100755 50 | --- a/__SAGE_SCRIPTS_DIR__/testcxx.sh 51 | +++ b/__SAGE_SCRIPTS_DIR__/testcxx.sh 52 | @@ -70,13 +70,13 @@ if [ -z "$SAGE_ROOT" ]; then 53 | exit 1 54 | fi 55 | 56 | -mkdir -p "$SAGE_ROOT/spkg/build" 57 | +mkdir -p "$SAGE_ROOT/__SAGE_ARTIFACTS__" 58 | if [ $? -ne 0 ]; then 59 | echo "Error while trying to create the build directory." 60 | exit 1 61 | fi 62 | 63 | -cd "$SAGE_ROOT/spkg/build" 64 | +cd "$SAGE_ROOT/__SAGE_ARTIFACTS__" 65 | if [ $? -ne 0 ]; then 66 | echo "Error while trying to change into the build directory." 67 | exit 1 68 | -- 69 | 1.8.1.5 70 | 71 | -------------------------------------------------------------------------------- /workflow-sep.rst: -------------------------------------------------------------------------------- 1 | .. warning:: This is a work in progress! 2 | 3 | ============ 4 | Workflow SEP 5 | ============ 6 | 7 | We propose to improve the workflow of Sage development by moving away 8 | from using patch files to communicate changes to the Sage library and 9 | ancillary structures, and instead start to use the modern DVCS 10 | (distributed version control system) method of lightweight branching 11 | and merging. We also propose various other improvements of developers' 12 | situation when writing code for Sage. 13 | 14 | Primary goals: 15 | 16 | * Switch from patches to branches 17 | 18 | - Consolidate *all* Sage repositories into a single repository, 19 | including SPKG installer/patches repositories for all standard and 20 | optional SPKGs 21 | 22 | + The src/ directory of current SPKGs will be separated from the 23 | rest of the SPKG (which is under version control) and placed in 24 | a different location. 25 | 26 | - Switch to git for version control 27 | 28 | - Implement and use something similar to ccache for Cython, so that 29 | building will be faster when switching branches 30 | 31 | * Implement a better review system on Trac 32 | 33 | - Make Trac aware of users' personal repositories and read new commits 34 | from them into its own overarching repository on demand 35 | 36 | - Implement "attaching" of branches to a ticket 37 | 38 | - Make it easy to view source code, commits, changesets, and hopefully 39 | even diffs between arbitrary pairs of commits on Trac 40 | 41 | - Customize Trac to allow for line-by-line comments on changesets 42 | 43 | + Also allow for line-by-line comments on patch files that currently 44 | exist on Trac 45 | 46 | * Make a script, ``sage dev``, which completely wraps some limited git 47 | functionality necessary to allow developers to use our new workflow 48 | without being git experts 49 | 50 | - It will know about Trac, and handle any branching or merging 51 | required 52 | 53 | - User is hand-held through everything they need to do - i.e. a 54 | wizard for development 55 | 56 | * Implement "live development" from sagenb.org or other public 57 | notebook servers 58 | 59 | - TODO 60 | 61 | See also our `brainstorming page`_ on the wiki page for Review Days 2, 62 | which was where most of these ideas came together. 63 | 64 | .. _brainstorming page: 65 | http://wiki.sagemath.org/review2/Projects/SystemProposals 66 | -------------------------------------------------------------------------------- /post-process_files/sage-spkg1.patch: -------------------------------------------------------------------------------- 1 | From d8666d8a526c59b6aa268f1905f04ee10bbbd803 Mon Sep 17 00:00:00 2001 2 | From: "R. Andrew Ohana" 3 | Date: Sun, 17 Mar 2013 01:22:21 -0700 4 | Subject: [PATCH] (FIXUP) sage-spkg: support legacy spkgs 5 | 6 | --- 7 | 8 | diff --git a/__SAGE_SCRIPTS_DIR__/sage-spkg b/__SAGE_SCRIPTS_DIR__/sage-spkg 9 | index 321ecc8..2c9eabd 100755 10 | --- a/__SAGE_SCRIPTS_DIR__/sage-spkg 11 | +++ b/__SAGE_SCRIPTS_DIR__/sage-spkg 12 | @@ -15,7 +15,6 @@ 13 | # variables are defined: 14 | # 15 | # SAGE_ROOT -- root directory of sage install 16 | -# SAGE_PACKAGES -- $SAGE_ROOT/spkg 17 | # SAGE_LOCAL -- $SAGE_ROOT/local 18 | # SAGE_DATA -- $SAGE_ROOT/data 19 | # LIBRARY_PATH, PYTHONPATH, LD_LIBRARY_PATH, DYLD_LIBRARY_PATH 20 | @@ -93,7 +92,7 @@ fi 21 | # The following sets environment variables for building packages. 22 | # Since this is sourced, it returns a non-zero value on errors rather 23 | # than exiting. Using dot suggested by W. Cheung. 24 | -. "$SAGE_ROOT/spkg/bin/sage-env" 25 | +. "${0%spkg}env" 26 | 27 | if [ $? -ne 0 ]; then 28 | echo >&2 "Error setting environment variables by sourcing '$SAGE_ROOT/spkg/bin/sage-env';" 29 | @@ -102,7 +101,7 @@ if [ $? -ne 0 ]; then 30 | fi 31 | 32 | if [ -z "$SAGE_BUILD_DIR" ]; then 33 | - export SAGE_BUILD_DIR="$SAGE_PACKAGES/build" 34 | + export SAGE_BUILD_DIR="$SAGE_ROOT/__SAGE_ARTIFACTS__" 35 | fi 36 | 37 | mkdir -p "$SAGE_SPKG_INST" 38 | @@ -222,11 +221,11 @@ elif [ -z "$PKG_HAS_PATH" ]; then 39 | # If PKG_SRC is not an existing file and doesn't contain a slash, 40 | # we are in case 2a or 3. Try to find a package in spkg/standard 41 | # or spkg/optional (or other possible directories under spkg). 42 | - cd "$SAGE_PACKAGES" 43 | - for spkg in `ls -1t */${PKG_NAME}.spkg */${PKG_NAME}-*.spkg 2>/dev/null`; do 44 | + cd "$SAGE_ROOT/__SAGE_TARBALLS__" 45 | + for spkg in `ls -1t ${PKG_NAME}.spkg ${PKG_NAME}-*.spkg 2>/dev/null`; do 46 | if [ -f "$spkg" ]; then 47 | # Found a good package 48 | - echo "Found package $PKG_NAME in spkg/$spkg" 49 | + echo "Found package $PKG_NAME in __SAGE_TARBALLS__/$spkg" 50 | PKG_SRC="`pwd`/$spkg" 51 | PKG_NAME=`basename "$spkg" | sed 's/\.spkg$//'` 52 | break 53 | @@ -253,8 +252,8 @@ if [ ! -f "$PKG_SRC" ]; then 54 | else 55 | echo "Attempting to get on-line info for package $PKG_NAME" 56 | fi 57 | - mkdir -p "$SAGE_PACKAGES/optional" 58 | - cd "$SAGE_PACKAGES/optional" 59 | + mkdir -p "$SAGE_ROOT/__SAGE_TARBALLS__" 60 | + cd "$SAGE_ROOT/__SAGE_TARBALLS__" 61 | 62 | # Reduce everything to case 4: full URL. 63 | if [ -n "$PKG_HAS_PATH" ]; then 64 | -- 65 | 1.8.1.5 66 | 67 | -------------------------------------------------------------------------------- /fast-export/README: -------------------------------------------------------------------------------- 1 | hg-fast-export.(sh|py) - mercurial to git converter using git-fast-import 2 | 3 | Legal 4 | ===== 5 | 6 | Most hg-* scripts are licensed under the MIT license[0] and were written 7 | by Rocco Rutte with hints and help from the git list and 8 | #mercurial on freenode. hg-reset.py is licensed under GPLv2 since it 9 | copies some code from the mercurial sources. 10 | 11 | The current maintainer is Frej Drejhammar . 12 | 13 | Usage 14 | ===== 15 | 16 | Using hg-fast-export is quite simple for a mercurial repository : 17 | 18 | mkdir repo-git # or whatever 19 | cd repo-git 20 | git init 21 | hg-fast-export.sh -r 22 | 23 | Incremental imports to track hg repos is supported, too. 24 | 25 | Using hg-reset it is quite simple within a git repository that is 26 | hg-fast-export'ed from mercurial: 27 | 28 | hg-reset.sh -R 29 | 30 | will give hints on which branches need adjustment for starting over 31 | again. 32 | 33 | As mercurial appears to be much less picky about the syntax of the 34 | author information than git, an author mapping file can be given to 35 | hg-fast-export to fix up malformed author strings. The file is 36 | specified using the -A option. The file should contain lines of the 37 | form "FromAuthor=ToAuthor". The example authors.map below will 38 | translate "User " to "User ". 39 | 40 | -- Start of authors.map -- 41 | User =User 42 | -- End of authors.map -- 43 | 44 | Notes/Limitations 45 | ================= 46 | 47 | hg-fast-export supports multiple branches but only named branches with 48 | exaclty one head each. Otherwise commits to the tip of these heads 49 | within branch will get flattened into merge commits. 50 | 51 | As each git-fast-import run creates a new pack file, it may be 52 | required to repack the repository quite often for incremental imports 53 | (especially when importing a small number of changesets per 54 | incremental import). 55 | 56 | The way the hg API and remote access protocol is designed it is not 57 | possible to use hg-fast-export on remote repositories 58 | (http/ssh). First clone the repository, then convert it. 59 | 60 | Design 61 | ====== 62 | 63 | hg-fast-export.py was designed in a way that doesn't require a 2-pass 64 | mechanism or any prior repository analysis: if just feeds what it 65 | finds into git-fast-import. This also implies that it heavily relies 66 | on strictly linear ordering of changesets from hg, i.e. its 67 | append-only storage model so that changesets hg-fast-export already 68 | saw never get modified. 69 | 70 | Submitting Patches 71 | ================== 72 | 73 | Please use the issue-tracker at github 74 | https://github.com/frej/fast-export to report bugs and submit 75 | patches. 76 | 77 | Footnotes 78 | ========= 79 | 80 | [0] http://www.opensource.org/licenses/mit-license.php 81 | -------------------------------------------------------------------------------- /post-process.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | . ${0%post-process.sh}configuration.sh 4 | 5 | if [ $# -gt 1 ]; then 6 | SAGE_ROOT="$1" 7 | else 8 | SAGE_ROOT="$(pwd)" 9 | fi 10 | SAGE_ROOT=$(readlink -f "$SAGE_ROOT") 11 | 12 | cd "$SAGE_ROOT" 13 | 14 | # remove .hg* files 15 | git rm $(find -name '.hg*') 16 | git commit -m "[CLEANUP] Mercurial-related data" 17 | 18 | # final fix of file locations 19 | git mv $SAGE_BUILD/standard/deps $SAGE_BUILD/deps 20 | git commit -m "[REORG] Final fix of file locations" 21 | 22 | # remove unused scripts 23 | git rm $(find -name sage-push) 24 | git rm $(find -name sage-pull) 25 | git rm $(find $SAGE_SRC -name spkg-install) 26 | git rm $(find $SAGE_SRC -name spkg-dist) 27 | git rm $(find $SAGE_SRC -name spkg-delauto) 28 | for file in $(cat < $OUTDIR/.gitignore 68 | } 69 | 70 | add_gitignore build 71 | add_gitignore root 72 | add_gitignore src 73 | add_gitignore src-c_lib 74 | add_gitignore src-doc 75 | add_gitignore src-sage 76 | add_gitignore src-sage-ext-interpreters 77 | 78 | git add -f $(find -name '.gitignore') 79 | git commit -m '[CLEANUP] Add gitignores' 80 | 81 | # apply patchs 82 | apply_patch () { 83 | cat_workflow_file post-process_files/$1.patch | git am 84 | } 85 | 86 | #apply_patch sage-env1 87 | cat_workflow_file post-process_files/sage-build > "$SAGE_SCRIPTS_DIR"/sage-build 88 | chmod 755 "$SAGE_SCRIPTS_DIR"/sage-build 89 | git add "$SAGE_SCRIPTS_DIR"/sage-build 90 | git commit -m '(FIXUP) new sage-build script' 91 | #apply_patch install1 92 | #apply_patch prereq-install1 93 | #apply_patch deps1 94 | #apply_patch sage-spkg1 95 | #apply_patch sage-spkg2 96 | #apply_patch sage-starts1 97 | #apply_patch csage1 98 | #apply_patch sage1 99 | #apply_patch docbuild1 100 | #apply_patch sage_artifacts1 101 | #apply_patch ntl1 102 | #apply_patch singular1 103 | #apply_patch sagenb1 104 | #apply_patch hg1 105 | #apply_patch gcc1 106 | #apply_patch makefile1 107 | #apply_patch whitespace1 108 | #apply_patch devel_doctests1 109 | #apply_patch makefile2 110 | #apply_patch sage_data1 111 | #apply_patch sage-envpy1 112 | #apply_patch long_doctests1 113 | #apply_patch setup1 114 | #apply_patch gcc1 115 | -------------------------------------------------------------------------------- /post-process_files/sagenb1.patch: -------------------------------------------------------------------------------- 1 | From 9cfd5223e08abcd7b4d7bec9ddf6af5d5a7e3ac3 Mon Sep 17 00:00:00 2001 2 | From: "R. Andrew Ohana" 3 | Date: Thu, 21 Mar 2013 15:23:16 -0700 4 | Subject: [PATCH] (FIXUP) sagenb: install into site-packages 5 | 6 | --- 7 | 8 | diff --git a/__SAGE_BUILD__/pkgs/sagenb/spkg-install b/__SAGE_BUILD__/pkgs/sagenb/spkg-install 9 | index 8ae2b35..e3abdae 100755 10 | --- a/__SAGE_BUILD__/pkgs/sagenb/spkg-install 11 | +++ b/__SAGE_BUILD__/pkgs/sagenb/spkg-install 12 | @@ -43,56 +43,5 @@ done 13 | BASENAME=$(ls -1 src | grep sagenb-) 14 | BASENAME=${BASENAME%.tar.gz} 15 | 16 | -# Install sagenb into $SAGE_ROOT/devel/ 17 | -# 18 | -# TODO: let sagenb sit in site_packages like any other component of Sage other 19 | -# than the Sage library; if the user wants to develop sagenb, they should set 20 | -# it up in an accessible directory themselves: 21 | -#easy_install -H None -f src "sagenb" || die "Error installing sagenb !" 22 | - 23 | -# Extract sagenb into $SAGE_ROOT/devel and set up the symlink 24 | -mkdir -p "$SAGE_ROOT/devel" 25 | -cd "$SAGE_ROOT/devel" 26 | -if [ -d "$SAGE_ROOT/devel/sagenb-main" ]; then 27 | - echo "Moving old SageNB package to '$SAGE_ROOT/devel/sagenb-main-old'..." 28 | - rm -rf "$SAGE_ROOT/devel/sagenb-main-old" 29 | - mv "$SAGE_ROOT/devel/sagenb-main" "$SAGE_ROOT/devel/sagenb-main-old" || 30 | - die "Error moving the old 'sagenb-main' directory." 31 | -fi 32 | -tar xzf "$CUR/src/$BASENAME.tar.gz" || die "Error: cannot extract $BASENAME.tar.gz" 33 | -mv $BASENAME sagenb-main 34 | -rm -f "$SAGE_ROOT/devel/sagenb" 35 | -ln -s sagenb-main "$SAGE_ROOT/devel/sagenb" 36 | - 37 | -# Install sagenb git repo, if it has been packaged 38 | -if [ -d "$CUR/src/sagenb.git" ]; then 39 | - mv "$CUR/src/sagenb.git" ./sagenb/.git 40 | -fi 41 | - 42 | -# Install sagenb into Sage's Python 43 | -# Note: We use --egg-path for relocatability 44 | -cd sagenb 45 | -python setup.py develop --egg-path '../../../../devel/sagenb' || 46 | - die "Error installing sagenb via setup.py develop" 47 | - 48 | -# Fix some relocatability issues - see #10176, possibly other tickets 49 | -cd "$SAGE_ROOT/local/lib/python/site-packages" 50 | -# Use >/dev/null instead of grep -q (which doesn't work on Solaris) 51 | -if ! grep sagenb easy-install.pth > /dev/null ; then 52 | - # Ugly work-around, we haven't found the real cause yet (see #10176): 53 | - echo "No sagenb path found in 'easy-install.pth'"'!' 54 | - echo "Adding relative sagenb path to 'easy-install.pth'..." 55 | - sed -e '$ i \../../../../devel/sagenb' easy-install.pth > easy-install.pth.$$ || 56 | - die "Error adding relative sagenb path to 'easy-install.pth'." 57 | -else 58 | - echo "Making sagenb path in 'easy-install.pth' relative..." 59 | - sed 's/^.*sagenb.*$/..\/..\/..\/..\/devel\/sagenb/' easy-install.pth > easy-install.pth.$$ || 60 | - die "Error patching 'easy-install.pth' to have relative path to SageNB." 61 | -fi 62 | -mv -f easy-install.pth.$$ easy-install.pth || 63 | - die "Error overwriting original 'easy-install.pth'." 64 | - 65 | -# Remove old reference manual to fix upgrading from sage-5.1 or 66 | -# earlier. Some old .rst files might try to import modules which no 67 | -# longer exist, see #13405. 68 | -rm -rf "$SAGE_ROOT/devel/sage/doc/en/reference/sagenb" 69 | +# Install sagenb into site-packages 70 | +easy_install -H None -f src "sagenb" || die "Error installing sagenb !" 71 | -- 72 | 1.8.1.5 73 | 74 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | sage-workflow 2 | ============= 3 | 4 | This is a repository for various stuff we're working on for the 5 | Workflow SEP (Sage Enhancement Proposal). 6 | 7 | 8 | consolidate-repos.sh 9 | -------------------- 10 | 11 | This is a script which will ultimately take a (sufficiently recent) 12 | Sage release source tarball and convert it into another tarball. The 13 | new tarball will be similar to the original, i.e. it will be a source 14 | tarball which you will extract, enter the extracted directory, do 15 | ``make``, wait a long time, and then end up with a working copy of 16 | Sage. 17 | 18 | The difference will be that now there will be a single, consolidated 19 | git repo sitting in the top level directory. The repo will contain 20 | within it the Sage library, the Sage scripts, the Sage root scripts 21 | (i.e. the stuff other than SPKGs which you usually see when you 22 | extract a source tarball), the Sage external system code (i.e. what is 23 | currently in ``data/extcode``). 24 | 25 | There will also be no SPKGs in the new tarball. The script will have 26 | disassembled each SPKG ``foo-x.y.z.spkg``, repacking the src/ 27 | directory into a new tarball ``upstream/foo-x.y.z.tar.bz2`` and 28 | merging the internal Mercurial repository into the single consolidated 29 | git repo, moving it into the subdirectory ``packages/``, specifically 30 | so that its files appear in ``packages/foo/``. 31 | 32 | Thus, in this variant of Sage, when installing a package, instead of 33 | extracting an SPKG file into a build directory for building, the 34 | spkg-install script / patches / etc. and the source tarball will be 35 | separately copied (resp. extracted) into the build directory. 36 | Installation of actual SPKG files will be emulated - when you run 37 | ``sage -i foo.spkg``, the script will disassemble the SPKG as 38 | described above, and then install it in its new way. 39 | 40 | Besides this, Sage will be generally modified to work with the new 41 | paths which all the above necessitate, or, in simple cases, to just 42 | copy the files from the new consolidated repository into their old 43 | locations whenever you run ``sage -b``. 44 | 45 | 46 | sagedev.py 47 | ---------- 48 | 49 | There used to be a sagedev development tool in this repository. Work on this 50 | has been moved to http://trac.sagemath.org/ticket/14482. 51 | 52 | 53 | issue_export.py 54 | --------------- 55 | 56 | A file to assist in moving tickets from trac to GitHub. 57 | Run it with ``./run issue_export.py`` -- the ``run`` file 58 | constructs a ``virtualenv`` directory so that it can 59 | install some dependencies. 60 | 61 | 62 | directory structure 63 | ------------------- 64 | 65 | The proposed directory structure of sage root is:: 66 | 67 | sage_root/ 68 | sage # the binary 69 | Makefile # top level Makefile 70 | (configure) # perhaps, eventually 71 | ... # other standard top level files (README, etc.) 72 | build/ 73 | core/ # sage's build system 74 | pkgs/ # install, patch, and metadata from spkgs 75 | ... 76 | src/ 77 | sage/ # sage library, i.e. devel/sage-main/sage 78 | ext/ # sage_extcode 79 | (macapp/) # would no longer have to awkwardly be in extcode 80 | scripts/ # sage_scripts 81 | ... 82 | upstream/ # (stripped) tarballs of upstream sources (not tracked) 83 | local/ # installed binaries and compile artifacts (not tracked) 84 | -------------------------------------------------------------------------------- /fast-export/hg-fast-export.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Copyright (c) 2007, 2008 Rocco Rutte and others. 4 | # License: MIT 5 | 6 | ROOT="`dirname $0`" 7 | REPO="" 8 | PFX="hg2git" 9 | SFX_MAPPING="mapping" 10 | SFX_MARKS="marks" 11 | SFX_HEADS="heads" 12 | SFX_STATE="state" 13 | GFI_OPTS="" 14 | PYTHON=${PYTHON:-python} 15 | 16 | USAGE="[--quiet] [-r ] [--force] [-m ] [-s] [-A ] [-M ] [-o ]" 17 | LONG_USAGE="Import hg repository up to either tip or 18 | If is omitted, use last hg repository as obtained from state file, 19 | GIT_DIR/$PFX-$SFX_STATE by default. 20 | 21 | Note: The argument order matters. 22 | 23 | Options: 24 | -m Maximum revision to import 25 | --quiet Passed to git-fast-import(1) 26 | -s Enable parsing Signed-off-by lines 27 | -A Read author map from file 28 | (Same as in git-svnimport(1) and git-cvsimport(1)) 29 | -r Mercurial repository to import 30 | -M Set the default branch name (default to 'master') 31 | -o Use as branch namespace to track upstream (eg 'origin') 32 | --force Ignore validation errors when converting, and pass --force 33 | to git-fast-import(1) 34 | " 35 | 36 | . "$(git --exec-path)/git-sh-setup" 37 | cd_to_toplevel 38 | 39 | while case "$#" in 0) break ;; esac 40 | do 41 | case "$1" in 42 | -r|--r|--re|--rep|--repo) 43 | shift 44 | REPO="$1" 45 | ;; 46 | --q|--qu|--qui|--quie|--quiet) 47 | GFI_OPTS="$GFI_OPTS --quiet" 48 | ;; 49 | --force) 50 | # pass --force to git-fast-import and hg-fast-export.py 51 | GFI_OPTS="$GFI_OPTS --force" 52 | break 53 | ;; 54 | -*) 55 | # pass any other options down to hg2git.py 56 | break 57 | ;; 58 | *) 59 | break 60 | ;; 61 | esac 62 | shift 63 | done 64 | 65 | # for convenience: get default repo from state file 66 | if [ x"$REPO" = x -a -f "$GIT_DIR/$PFX-$SFX_STATE" ] ; then 67 | REPO="`egrep '^:repo ' "$GIT_DIR/$PFX-$SFX_STATE" | cut -d ' ' -f 2`" 68 | echo "Using last hg repository \"$REPO\"" 69 | fi 70 | 71 | # make sure we have a marks cache 72 | if [ ! -f "$GIT_DIR/$PFX-$SFX_MARKS" ] ; then 73 | touch "$GIT_DIR/$PFX-$SFX_MARKS" 74 | fi 75 | 76 | # cleanup on exit 77 | trap 'rm -f "$GIT_DIR/$PFX-$SFX_MARKS.old" "$GIT_DIR/$PFX-$SFX_MARKS.tmp"' 0 78 | 79 | GIT_DIR="$GIT_DIR" $PYTHON "$ROOT/hg-fast-export.py" \ 80 | --repo "$REPO" \ 81 | --marks "$GIT_DIR/$PFX-$SFX_MARKS" \ 82 | --mapping "$GIT_DIR/$PFX-$SFX_MAPPING" \ 83 | --heads "$GIT_DIR/$PFX-$SFX_HEADS" \ 84 | --status "$GIT_DIR/$PFX-$SFX_STATE" \ 85 | "$@" \ 86 | | git fast-import $GFI_OPTS --export-marks="$GIT_DIR/$PFX-$SFX_MARKS.tmp" || exit 1 87 | 88 | # move recent marks cache out of the way... 89 | if [ -f "$GIT_DIR/$PFX-$SFX_MARKS" ] ; then 90 | mv "$GIT_DIR/$PFX-$SFX_MARKS" "$GIT_DIR/$PFX-$SFX_MARKS.old" 91 | else 92 | touch "$GIT_DIR/$PFX-$SFX_MARKS.old" 93 | fi 94 | 95 | # ...to create a new merged one 96 | cat "$GIT_DIR/$PFX-$SFX_MARKS.old" "$GIT_DIR/$PFX-$SFX_MARKS.tmp" \ 97 | | uniq > "$GIT_DIR/$PFX-$SFX_MARKS" 98 | 99 | # save SHA1s of current heads for incremental imports 100 | # and connectivity (plus sanity checking) 101 | for head in `git branch | sed 's#^..##'` ; do 102 | id="`git rev-parse $head`" 103 | echo ":$head $id" 104 | done > "$GIT_DIR/$PFX-$SFX_HEADS" 105 | 106 | # check diff with color: 107 | # ( for i in `find . -type f | grep -v '\.git'` ; do diff -u $i $REPO/$i ; done | cdiff ) | less -r 108 | -------------------------------------------------------------------------------- /post-process_files/makefile2.patch: -------------------------------------------------------------------------------- 1 | From 7f26a4f14df3adef0d1499f5fb9542b91aef6fc2 Mon Sep 17 00:00:00 2001 2 | From: "R. Andrew Ohana" 3 | Date: Sat, 23 Mar 2013 14:12:45 -0700 4 | Subject: [PATCH] (FIXUP) Makefile: put logs in logs directory 5 | 6 | --- 7 | 8 | diff --git a/Makefile b/Makefile 9 | index 7dfa378..58c4f9f 100644 10 | --- a/Makefile 11 | +++ b/Makefile 12 | @@ -17,7 +17,7 @@ build: 13 | cd build && \ 14 | "../$(PIPE)" \ 15 | "env SAGE_PARALLEL_SPKG_BUILD='$(SAGE_PARALLEL_SPKG_BUILD)' ./install all 2>&1" \ 16 | - "tee -a ../install.log" 17 | + "tee -a ../logs/install.log" 18 | ./sage -b 19 | 20 | # ssl: build Sage, and also install pyOpenSSL. This is necessary for 21 | @@ -49,16 +49,16 @@ start: build 22 | doc: doc-html 23 | 24 | doc-html: build 25 | - $(PIPE) "./sage --docbuild --no-pdf-links all html $(SAGE_DOCBUILD_OPTS) 2>&1" "tee -a dochtml.log" 26 | + $(PIPE) "./sage --docbuild --no-pdf-links all html $(SAGE_DOCBUILD_OPTS) 2>&1" "tee -a logs/dochtml.log" 27 | 28 | doc-html-mathjax: build 29 | - $(PIPE) "./sage --docbuild --no-pdf-links all html -j $(SAGE_DOCBUILD_OPTS) 2>&1" "tee -a dochtml.log" 30 | + $(PIPE) "./sage --docbuild --no-pdf-links all html -j $(SAGE_DOCBUILD_OPTS) 2>&1" "tee -a logs/dochtml.log" 31 | 32 | # Keep target 'doc-html-jsmath' for backwards compatibility. 33 | doc-html-jsmath: doc-html-mathjax 34 | 35 | doc-pdf: build 36 | - $(PIPE) "./sage --docbuild all pdf $(SAGE_DOCBUILD_OPTS) 2>&1" "tee -a docpdf.log" 37 | + $(PIPE) "./sage --docbuild all pdf $(SAGE_DOCBUILD_OPTS) 2>&1" "tee -a logs/docpdf.log" 38 | 39 | doc-clean: 40 | @echo "Deleting devel/sage/doc/output..." 41 | @@ -107,37 +107,37 @@ TESTDIRS = src/doc/common src/doc/[a-z][a-z] src/sage 42 | 43 | test: all # i.e. build and doc 44 | $(TESTPRELIMS) 45 | - $(PIPE) "./sage -t --sagenb $(TESTDIRS) 2>&1" "tee -a test.log" 46 | + $(PIPE) "./sage -t --sagenb $(TESTDIRS) 2>&1" "tee -a logs/test.log" 47 | 48 | check: test 49 | 50 | testall: all # i.e. build and doc 51 | $(TESTPRELIMS) 52 | - $(PIPE) "./sage -t --sagenb --optional $(TESTDIRS) 2>&1" "tee -a testall.log" 53 | + $(PIPE) "./sage -t --sagenb --optional $(TESTDIRS) 2>&1" "tee -a logs/testall.log" 54 | 55 | testlong: all # i.e. build and doc 56 | $(TESTPRELIMS) 57 | - $(PIPE) "./sage -t --sagenb --long $(TESTDIRS) 2>&1" "tee -a testlong.log" 58 | + $(PIPE) "./sage -t --sagenb --long $(TESTDIRS) 2>&1" "tee -a logs/testlong.log" 59 | 60 | testalllong: all # i.e. build and doc 61 | $(TESTPRELIMS) 62 | - $(PIPE) "./sage -t --sagenb --optional --long $(TESTDIRS) 2>&1" "tee -a testalllong.log" 63 | + $(PIPE) "./sage -t --sagenb --optional --long $(TESTDIRS) 2>&1" "tee -a logs/testalllong.log" 64 | 65 | ptest: all # i.e. build and doc 66 | $(TESTPRELIMS) 67 | - $(PIPE) "./sage -tp --sagenb $(TESTDIRS) 2>&1" "tee -a ptest.log" 68 | + $(PIPE) "./sage -tp --sagenb $(TESTDIRS) 2>&1" "tee -a logs/ptest.log" 69 | 70 | ptestall: all # i.e. build and doc 71 | $(TESTPRELIMS) 72 | - $(PIPE) "./sage -tp --sagenb --optional $(TESTDIRS) 2>&1" "tee -a ptestall.log" 73 | + $(PIPE) "./sage -tp --sagenb --optional $(TESTDIRS) 2>&1" "tee -a logs/ptestall.log" 74 | 75 | ptestlong: all # i.e. build and doc 76 | $(TESTPRELIMS) 77 | - $(PIPE) "./sage -tp --sagenb --long $(TESTDIRS) 2>&1" "tee -a ptestlong.log" 78 | + $(PIPE) "./sage -tp --sagenb --long $(TESTDIRS) 2>&1" "tee -a logs/ptestlong.log" 79 | 80 | ptestalllong: all # i.e. build and doc 81 | $(TESTPRELIMS) 82 | - $(PIPE) "./sage -tp --sagenb --optional --long $(TESTDIRS) 2>&1" "tee -a ptestalllong.log" 83 | + $(PIPE) "./sage -tp --sagenb --optional --long $(TESTDIRS) 2>&1" "tee -a logs/ptestalllong.log" 84 | 85 | 86 | testoptional: testall # just an alias 87 | -- 88 | 1.8.1.5 89 | 90 | -------------------------------------------------------------------------------- /post-process_files/devel_doctests1.patch: -------------------------------------------------------------------------------- 1 | From 56c2ac081ada4f09dae665d3c9f86e8dbd725688 Mon Sep 17 00:00:00 2001 2 | From: "R. Andrew Ohana" 3 | Date: Sun, 24 Mar 2013 14:34:10 -0700 4 | Subject: [PATCH] (FIXUP) don't reference devel/sage in doctests 5 | 6 | --- 7 | 8 | diff --git a/__SAGE_SRC__/doc/common/builder.py b/__SAGE_SRC__/doc/common/builder.py 9 | index 87cd074..ce051bf 100644 10 | --- a/__SAGE_SRC__/doc/common/builder.py 11 | +++ b/__SAGE_SRC__/doc/common/builder.py 12 | @@ -139,7 +139,7 @@ class DocBuilder(object): 13 | sage: import os, sys; sys.path.append(os.environ['SAGE_DOC']+'/common/'); import builder 14 | sage: b = builder.DocBuilder('tutorial') 15 | sage: b._output_dir('html') 16 | - '.../devel/sage/doc/output/html/en/tutorial' 17 | + '.../doc/output/html/en/tutorial' 18 | """ 19 | d = os.path.join(SAGE_DOC, "output", type, self.lang, self.name) 20 | mkdir(d) 21 | @@ -156,7 +156,7 @@ class DocBuilder(object): 22 | sage: import os, sys; sys.path.append(os.environ['SAGE_DOC']+'/common/'); import builder 23 | sage: b = builder.DocBuilder('tutorial') 24 | sage: b._doctrees_dir() 25 | - '.../devel/sage/doc/output/doctrees/en/tutorial' 26 | + '.../doc/output/doctrees/en/tutorial' 27 | """ 28 | d = os.path.join(SAGE_DOC, "output", 'doctrees', self.lang, self.name) 29 | mkdir(d) 30 | @@ -442,7 +442,7 @@ class ReferenceBuilder(AllBuilder): 31 | sage: import os, sys; sys.path.append(os.environ['SAGE_DOC']+'/common/'); import builder 32 | sage: b = builder.ReferenceBuilder('reference') 33 | sage: b._output_dir('html') 34 | - '.../devel/sage/doc/output/html/en/reference' 35 | + '.../doc/output/html/en/reference' 36 | """ 37 | d = os.path.join(SAGE_DOC, "output", type, lang, self.name) 38 | mkdir(d) 39 | @@ -907,7 +907,7 @@ class ReferenceSubBuilder(DocBuilder): 40 | sage: import os, sys; sys.path.append(os.environ['SAGE_DOC']+'/common/'); import builder 41 | sage: import builder 42 | sage: builder.ReferenceSubBuilder("reference").auto_rest_filename("sage.combinat.partition") 43 | - '.../devel/sage/doc/en/reference/sage/combinat/partition.rst' 44 | + '.../doc/en/reference/sage/combinat/partition.rst' 45 | """ 46 | return self.dir + os.path.sep + module_name.replace('.',os.path.sep) + '.rst' 47 | 48 | diff --git a/__SAGE_SRC__/sage/misc/cython.py b/__SAGE_SRC__/sage/misc/cython.py 49 | index 36ff57e..5faeef4 100644 50 | --- a/__SAGE_SRC__/sage/misc/cython.py 51 | +++ b/__SAGE_SRC__/sage/misc/cython.py 52 | @@ -212,9 +212,9 @@ def pyx_preparse(s): 53 | '.../include', 54 | '.../include/python2.7', 55 | '.../lib/python/site-packages/numpy/core/include', 56 | - '.../devel/sage/sage/ext', 57 | - '.../devel/sage', 58 | - '.../devel/sage/sage/gsl'], 59 | + '.../sage/ext', 60 | + '...', 61 | + '.../sage/gsl'], 62 | 'c', 63 | [], ['-w', '-O2']) 64 | sage: s, libs, inc, lang, f, args = pyx_preparse("# clang c++\n #clib foo\n # cinclude bar\n") 65 | @@ -240,9 +240,9 @@ def pyx_preparse(s): 66 | '.../include', 67 | '.../include/python2.7', 68 | '.../lib/python/site-packages/numpy/core/include', 69 | - '.../devel/sage/sage/ext', 70 | - '.../devel/sage', 71 | - '.../devel/sage/sage/gsl'] 72 | + '.../sage/ext', 73 | + '...', 74 | + '.../sage/gsl'] 75 | 76 | sage: s, libs, inc, lang, f, args = pyx_preparse("# cargs -O3 -ggdb\n") 77 | sage: args 78 | -- 79 | 1.8.1.5 80 | 81 | -------------------------------------------------------------------------------- /fast-export/hg2git.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # Copyright (c) 2007, 2008 Rocco Rutte and others. 4 | # License: MIT 5 | 6 | from mercurial import hg,util,ui,templatefilters 7 | import re 8 | import os 9 | import sys 10 | 11 | # default git branch name 12 | cfg_master='master' 13 | # default origin name 14 | origin_name='' 15 | # silly regex to see if user field has email address 16 | user_re=re.compile('([^<]+) (<[^>]*>)$') 17 | # silly regex to clean out user names 18 | user_clean_re=re.compile('^["]([^"]+)["]$') 19 | 20 | def set_default_branch(name): 21 | global cfg_master 22 | cfg_master = name 23 | 24 | def set_origin_name(name): 25 | global origin_name 26 | origin_name = name 27 | 28 | def setup_repo(url): 29 | try: 30 | myui=ui.ui(interactive=False) 31 | except TypeError: 32 | myui=ui.ui() 33 | myui.setconfig('ui', 'interactive', 'off') 34 | return myui,hg.repository(myui,url) 35 | 36 | def fixup_user(user,authors): 37 | user=user.strip("\"") 38 | if authors!=None: 39 | # if we have an authors table, try to get mapping 40 | # by defaulting to the current value of 'user' 41 | user=authors.get(user,user) 42 | name,mail,m='','',user_re.match(user) 43 | if m==None: 44 | # if we don't have 'Name ' syntax, extract name 45 | # and mail from hg helpers. this seems to work pretty well. 46 | # if email doesn't contain @, replace it with devnull@localhost 47 | name=templatefilters.person(user) 48 | mail='<%s>' % util.email(user) 49 | if '@' not in mail: 50 | mail = '' 51 | name = 'Nomail Name' 52 | else: 53 | # if we have 'Name ' syntax, everything is fine :) 54 | name,mail=m.group(1),m.group(2) 55 | 56 | # remove any silly quoting from username 57 | m2=user_clean_re.match(name) 58 | if m2!=None: 59 | name=m2.group(1) 60 | return '%s %s' % (name,mail) 61 | 62 | def get_branch(name): 63 | # 'HEAD' is the result of a bug in mutt's cvs->hg conversion, 64 | # other CVS imports may need it, too 65 | if name=='HEAD' or name=='default' or name=='': 66 | name=cfg_master 67 | if origin_name: 68 | return origin_name + '/' + name 69 | return name 70 | 71 | def get_changeset(ui,repo,revision,authors={}): 72 | node=repo.lookup(revision) 73 | (manifest,user,(time,timezone),files,desc,extra)=repo.changelog.read(node) 74 | tz="%+03d%02d" % (-timezone / 3600, ((-timezone % 3600) / 60)) 75 | branch=get_branch(extra.get('branch','master')) 76 | return (node,manifest,fixup_user(user,authors),(time,tz),files,desc,branch,extra) 77 | 78 | def mangle_key(key): 79 | return key 80 | 81 | def load_cache(filename,get_key=mangle_key): 82 | cache={} 83 | if not os.path.exists(filename): 84 | return cache 85 | f=open(filename,'r') 86 | l=0 87 | for line in f.readlines(): 88 | l+=1 89 | fields=line.split(' ') 90 | if fields==None or not len(fields)==2 or fields[0][0]!=':': 91 | sys.stderr.write('Invalid file format in [%s], line %d\n' % (filename,l)) 92 | continue 93 | # put key:value in cache, key without ^: 94 | cache[get_key(fields[0][1:])]=fields[1].split('\n')[0] 95 | f.close() 96 | return cache 97 | 98 | def save_cache(filename,cache): 99 | f=open(filename,'w+') 100 | map(lambda x: f.write(':%s %s\n' % (str(x),str(cache.get(x)))),cache.keys()) 101 | f.close() 102 | 103 | def get_git_sha1(name,type='heads'): 104 | try: 105 | # use git-rev-parse to support packed refs 106 | cmd="git rev-parse --verify refs/%s/%s 2>%s" % (type,name,os.devnull) 107 | p=os.popen(cmd) 108 | l=p.readline() 109 | p.close() 110 | if l == None or len(l) == 0: 111 | return None 112 | return l[0:40] 113 | except IOError: 114 | return None 115 | -------------------------------------------------------------------------------- /combinat.rst: -------------------------------------------------------------------------------- 1 | .. Original authors: Florent Hivert and Nicolas Thiéry 2 | 3 | What is this Sage-Combinat queue madness about??? 4 | ================================================= 5 | 6 | Sage-Combinat is a software project whose mission is: "to improve the 7 | open source mathematical system Sage as an extensible toolbox for 8 | computer exploration in (algebraic) combinatorics, and foster code 9 | sharing between researchers in this area". 10 | 11 | In practice it's a community of a dozen regular contributers, 20 12 | occasional ones and, maybe, 30 users. They collaborate together on a 13 | collection of experimental patches (i.e. extensions) on top of 14 | Sage. Each one describes a relatively atomic modification which may 15 | span several files; it may fix a bug, implement a new feature, improve 16 | some documentation. The intent is that most of those extensions get 17 | integrated into Sage as soon as they are mature enough, with a typical 18 | life-cycle ranging from a few days to a couple months. In average 20 19 | extensions are merged in each version of Sage (42 in Sage 5.0!), and 20 | more than 200 are under development. 21 | 22 | 23 | Why do we want to share our experimental code 24 | ============================================= 25 | 26 | Here are our goals in using the Sage-Combinat queue for sharing patches: 27 | 28 | - Preintegration 29 | It is very common that an advanced feature needs some infrastructure 30 | support. For example, advanced Hopf algebras or representation theory 31 | features needs basic linear algebra stuff (eg: tensor product) which them 32 | self needs support from categories which them self may need support for 33 | optimized dynamic classes. Having a central repository for experimental 34 | code allows us for sharing several layer of dependant patch. In our 35 | (Nicolas and Florent) experience it is fairly common that during research, 36 | we end up improving dependant patches with more than four layers of 37 | dependencies. 38 | 39 | - Pair programming (or more than pair!) 40 | Many Sage-Combinat patches have several authors. We need an easy way to 41 | exchange patches (note that this is not specific to the Sage-Combinat 42 | project). 43 | 44 | - Easy review even with many dependencies 45 | As said in preintegration, we can have several layer of dependant 46 | patches. We need some tool to apply a bunch of patches (not necessarily in 47 | a stable/needs-review status), experiment with the code and launch the 48 | tests. 49 | 50 | - Maturation 51 | Due to the kind of computation we need (gluing algebra and combinatorics 52 | together), we have to be extra careful on the interface. Therefore, it is 53 | very common that we wait for a feature to be used several time before 54 | entering Sage. This is particularly true for infrastructure stuff. 55 | 56 | - Overview of what's developed by who 57 | Having a centralized place where all de development is seen is a good tool 58 | for team coordination and code management. It also helps early detection of 59 | patch conflicts. 60 | 61 | - Sharing code with beginner colleagues 62 | The queue is also an easy way to distribute experimental code to non 63 | developer colleagues. The two commands:: 64 | 65 | sage -combinat install / sage -combinat update 66 | 67 | need no mercurial or developer skills 68 | 69 | 70 | 71 | What are our constraints 72 | ======================== 73 | 74 | - Vital necessity of supporting several versions of Sage at once 75 | For the convenience of the user, it is usually possible to use the 76 | sage-combinat patches with older versions of sage. The intent is only 77 | to temporarily support one or two older versions of sage (that is 78 | about one month old). Typical use case: a developer urgently needs the 79 | latest version of a patch for a software demonstration at a 80 | conference, but can't instantly upgrade because of a slow internet 81 | connection. There is no guarantee whatsoever; on occasion we do not 82 | support this when this causes technical difficulties. 83 | 84 | - By nature, our calculations are transversal. Thus it would be hard 85 | to split Sage-Combinat in smaller chunks by subareas. 86 | 87 | 88 | 89 | Some random questions 90 | ===================== 91 | 92 | - linear order versus DAG (directed acyclic graph) of dependencies: what's 93 | easier to maintain ? 94 | 95 | 96 | 97 | Foreseeable future 98 | ================== 99 | 100 | - More contributers 101 | - Less overlap between patches as development goes from core to 102 | peripheral features 103 | -------------------------------------------------------------------------------- /post-process_files/sage-spkg2.patch: -------------------------------------------------------------------------------- 1 | From fa558b4f998b2578762ed65d65a7a19ef6a455ce Mon Sep 17 00:00:00 2001 2 | From: "R. Andrew Ohana" 3 | Date: Wed, 20 Mar 2013 16:42:24 -0700 4 | Subject: [PATCH] (FIXUP) sage-spkg: support local scripts 5 | 6 | --- 7 | 8 | diff --git a/__SAGE_SCRIPTS_DIR__/sage-spkg b/__SAGE_SCRIPTS_DIR__/sage-spkg 9 | index 8ea2fe8..7c08edd 100755 10 | --- a/__SAGE_SCRIPTS_DIR__/sage-spkg 11 | +++ b/__SAGE_SCRIPTS_DIR__/sage-spkg 12 | @@ -219,18 +219,42 @@ if [ -f "$PKG_SRC" ]; then 13 | fi 14 | elif [ -z "$PKG_HAS_PATH" ]; then 15 | # If PKG_SRC is not an existing file and doesn't contain a slash, 16 | - # we are in case 2a or 3. Try to find a package in spkg/standard 17 | - # or spkg/optional (or other possible directories under spkg). 18 | - cd "$SAGE_ROOT/__SAGE_TARBALLS__" 19 | - for spkg in `ls -1t ${PKG_NAME}.spkg ${PKG_NAME}-*.spkg 2>/dev/null`; do 20 | - if [ -f "$spkg" ]; then 21 | - # Found a good package 22 | - echo "Found package $PKG_NAME in __SAGE_TARBALLS__/$spkg" 23 | - PKG_SRC="`pwd`/$spkg" 24 | - PKG_NAME=`basename "$spkg" | sed 's/\.spkg$//'` 25 | - break 26 | - fi 27 | - done 28 | + # we are in case 2a or 3. If version in 2a matches the version in 29 | + # __SAGE_PKGS__ or we are in case 3 use the local scripts, otherwise 30 | + # we try to find a package in __SAGE_TARBALLS__ 31 | + PKG_VER="${PKG_NAME#${PKG_BASE}}" 32 | + PKG_VER="${PKG_VER#-}" 33 | + PKG_SCRIPTS="$SAGE_ROOT/__SAGE_PKGS__/$PKG_BASE" 34 | + LOCAL_PKG_VER=`cat $PKG_SCRIPTS/package-version.txt` 35 | + if [ -z "$PKG_VER" -o "$PKG_VER" == "$LOCAL_PKG_VER" ]; then 36 | + PKG_VER="$LOCAL_PKG_VER" 37 | + PKG_NAME="${PKG_BASE}-${PKG_VER}" 38 | + USE_LOCAL_SCRIPTS=yes 39 | + PKG_NAME_UPSTREAM="${PKG_BASE}-`echo $PKG_VER | sed 's/\.p[0-9][0-9]*$//'`" 40 | + echo "Using local scripts to install $PKG_NAME" 41 | + 42 | + # see if we can the source tarball locally 43 | + cd "$SAGE_ROOT/__SAGE_TARBALLS__" 44 | + for tarball in `ls -1t ${PKG_NAME_UPSTREAM}.tar* 2>/dev/null`; do 45 | + if [ -f "$tarball" ]; then 46 | + # Found a good tarball 47 | + echo "Found local sources at __SAGE_TARBALLS__/$tarball" 48 | + PKG_SRC="`pwd`/$tarball" 49 | + break 50 | + fi 51 | + done 52 | + else 53 | + cd "$SAGE_ROOT/__SAGE_TARBALLS__" 54 | + for spkg in `ls -1t ${PKG_NAME}.spkg ${PKG_NAME}-*.spkg 2>/dev/null`; do 55 | + if [ -f "$spkg" ]; then 56 | + # Found a good package 57 | + echo "Found package $PKG_NAME in __SAGE_TARBALLS__/$spkg" 58 | + PKG_SRC="`pwd`/$spkg" 59 | + PKG_NAME=`basename "$spkg" | sed 's/\.spkg$//'` 60 | + break 61 | + fi 62 | + done 63 | + fi 64 | fi 65 | 66 | # Check whether the package is already installed. We do this before 67 | @@ -347,10 +371,14 @@ uncompress_spkg() 68 | } 69 | 70 | if [ $INFO -ne 0 ]; then 71 | - uncompress_spkg "$PKG_SRC" | tar Oxf - "$PKG_NAME/SPKG.txt" 72 | - if [ $? -ne 0 ]; then 73 | - echo >&2 "No file SPKG.txt in $PKG_NAME" 74 | - exit 1 75 | + if [ "$USE_LOCAL_SCRIPTS" == yes ]; then 76 | + cat "$PKG_SCRIPTS/SPKG.txt" 77 | + else 78 | + uncompress_spkg "$PKG_SRC" | tar Oxf - "$PKG_NAME/SPKG.txt" 79 | + if [ $? -ne 0 ]; then 80 | + echo >&2 "No file SPKG.txt in $PKG_NAME" 81 | + exit 1 82 | + fi 83 | fi 84 | exit 0 85 | fi 86 | @@ -391,15 +419,28 @@ if [ -e "$PKG_NAME" ]; then 87 | exit 1 88 | fi 89 | 90 | -echo "Extracting package $PKG_SRC" 91 | -ls -l "$PKG_SRC" 92 | +if [ "$USE_LOCAL_SCRIPTS" == yes ]; then 93 | + echo "Setting up build directory for $PKG_NAME" 94 | + cp -Rp "$PKG_SCRIPTS" "$PKG_NAME" 95 | + cd "$PKG_NAME" 96 | +else 97 | + echo "Extracting package $PKG_SRC" 98 | + ls -l "$PKG_SRC" 99 | +fi 100 | 101 | -uncompress_spkg "$PKG_SRC" | tar x${UNTAR_VERBOSE}f - --no-same-owner 102 | -if [ $? -ne 0 ]; then 103 | - echo >&2 "Error: failed to extract $PKG_SRC" 104 | - exit 1 105 | + uncompress_spkg "$PKG_SRC" | tar x${UNTAR_VERBOSE}f - --no-same-owner 106 | + if [ $? -ne 0 ]; then 107 | + echo >&2 "Error: failed to extract $PKG_SRC" 108 | + exit 1 109 | + fi 110 | + 111 | +if [ "$USE_LOCAL_SCRIPTS" == yes ]; then 112 | + mv "$PKG_NAME_UPSTREAM" src 113 | + cd .. 114 | + echo "Finished set up" 115 | +else 116 | + echo "Finished extraction" 117 | fi 118 | -echo "Finished extraction" 119 | 120 | ################################################################## 121 | # The package has been extracted, prepare for installation 122 | -- 123 | 1.8.1.5 124 | 125 | -------------------------------------------------------------------------------- /fast-export/hg-reset.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # Copyright (c) 2007, 2008 Rocco Rutte and others. 4 | # License: GPLv2 5 | 6 | from mercurial import node 7 | from hg2git import setup_repo,load_cache,get_changeset,get_git_sha1 8 | from optparse import OptionParser 9 | import sys 10 | 11 | def heads(ui,repo,start=None,stop=None,max=None): 12 | # this is copied from mercurial/revlog.py and differs only in 13 | # accepting a max argument for xrange(startrev+1,...) defaulting 14 | # to the original repo.changelog.count() 15 | if start is None: 16 | start = node.nullid 17 | if stop is None: 18 | stop = [] 19 | if max is None: 20 | max = repo.changelog.count() 21 | stoprevs = dict.fromkeys([repo.changelog.rev(n) for n in stop]) 22 | startrev = repo.changelog.rev(start) 23 | reachable = {startrev: 1} 24 | heads = {startrev: 1} 25 | 26 | parentrevs = repo.changelog.parentrevs 27 | for r in xrange(startrev + 1, max): 28 | for p in parentrevs(r): 29 | if p in reachable: 30 | if r not in stoprevs: 31 | reachable[r] = 1 32 | heads[r] = 1 33 | if p in heads and p not in stoprevs: 34 | del heads[p] 35 | 36 | return [(repo.changelog.node(r),str(r)) for r in heads] 37 | 38 | def get_branches(ui,repo,heads_cache,marks_cache,mapping_cache,max): 39 | h=heads(ui,repo,max=max) 40 | stale=dict.fromkeys(heads_cache) 41 | changed=[] 42 | unchanged=[] 43 | for node,rev in h: 44 | _,_,user,(_,_),_,desc,branch,_=get_changeset(ui,repo,rev) 45 | del stale[branch] 46 | git_sha1=get_git_sha1(branch) 47 | cache_sha1=marks_cache.get(str(int(rev)+1)) 48 | if git_sha1!=None and git_sha1==cache_sha1: 49 | unchanged.append([branch,cache_sha1,rev,desc.split('\n')[0],user]) 50 | else: 51 | changed.append([branch,cache_sha1,rev,desc.split('\n')[0],user]) 52 | changed.sort() 53 | unchanged.sort() 54 | return stale,changed,unchanged 55 | 56 | def get_tags(ui,repo,marks_cache,mapping_cache,max): 57 | l=repo.tagslist() 58 | good,bad=[],[] 59 | for tag,node in l: 60 | if tag=='tip': continue 61 | rev=int(mapping_cache[node.encode('hex_codec')]) 62 | cache_sha1=marks_cache.get(str(int(rev)+1)) 63 | _,_,user,(_,_),_,desc,branch,_=get_changeset(ui,repo,rev) 64 | if int(rev)>int(max): 65 | bad.append([tag,branch,cache_sha1,rev,desc.split('\n')[0],user]) 66 | else: 67 | good.append([tag,branch,cache_sha1,rev,desc.split('\n')[0],user]) 68 | good.sort() 69 | bad.sort() 70 | return good,bad 71 | 72 | def mangle_mark(mark): 73 | return str(int(mark)-1) 74 | 75 | if __name__=='__main__': 76 | def bail(parser,opt): 77 | sys.stderr.write('Error: No option %s given\n' % opt) 78 | parser.print_help() 79 | sys.exit(2) 80 | 81 | parser=OptionParser() 82 | 83 | parser.add_option("--marks",dest="marksfile", 84 | help="File to read git-fast-import's marks from") 85 | parser.add_option("--heads",dest="headsfile", 86 | help="File to read last run's git heads from") 87 | parser.add_option("--status",dest="statusfile", 88 | help="File to read status from") 89 | parser.add_option("-r","--repo",dest="repourl", 90 | help="URL of repo to import") 91 | parser.add_option("-R","--revision",type=int,dest="revision", 92 | help="Revision to reset to") 93 | 94 | (options,args)=parser.parse_args() 95 | 96 | if options.marksfile==None: bail(parser,'--marks option') 97 | if options.headsfile==None: bail(parser,'--heads option') 98 | if options.statusfile==None: bail(parser,'--status option') 99 | if options.repourl==None: bail(parser,'--repo option') 100 | if options.revision==None: bail(parser,'-R/--revision') 101 | 102 | heads_cache=load_cache(options.headsfile) 103 | marks_cache=load_cache(options.marksfile,mangle_mark) 104 | state_cache=load_cache(options.statusfile) 105 | 106 | l=int(state_cache.get('tip',options.revision)) 107 | if options.revision+1>l: 108 | sys.stderr.write('Revision is beyond last revision imported: %d>%d\n' % (options.revision,l)) 109 | sys.exit(1) 110 | 111 | ui,repo=setup_repo(options.repourl) 112 | 113 | stale,changed,unchanged=get_branches(ui,repo,heads_cache,marks_cache,mapping_cache,options.revision+1) 114 | good,bad=get_tags(ui,repo,marks_cache,mapping_cache,options.revision+1) 115 | 116 | print "Possibly stale branches:" 117 | map(lambda b: sys.stdout.write('\t%s\n' % b),stale.keys()) 118 | 119 | print "Possibly stale tags:" 120 | map(lambda b: sys.stdout.write('\t%s on %s (r%s)\n' % (b[0],b[1],b[3])),bad) 121 | 122 | print "Unchanged branches:" 123 | map(lambda b: sys.stdout.write('\t%s (r%s)\n' % (b[0],b[2])),unchanged) 124 | 125 | print "Unchanged tags:" 126 | map(lambda b: sys.stdout.write('\t%s on %s (r%s)\n' % (b[0],b[1],b[3])),good) 127 | 128 | print "Reset branches in '%s' to:" % options.headsfile 129 | map(lambda b: sys.stdout.write('\t:%s %s\n\t\t(r%s: %s: %s)\n' % (b[0],b[1],b[2],b[4],b[3])),changed) 130 | 131 | print "Reset ':tip' in '%s' to '%d'" % (options.statusfile,options.revision) 132 | -------------------------------------------------------------------------------- /fast-export/svn-fast-export.c: -------------------------------------------------------------------------------- 1 | /* 2 | * svn-fast-export.c 3 | * ---------- 4 | * Walk through each revision of a local Subversion repository and export it 5 | * in a stream that git-fast-import can consume. 6 | * 7 | * Author: Chris Lee 8 | * License: MIT 9 | */ 10 | 11 | #define _XOPEN_SOURCE 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #ifndef PATH_MAX 18 | #define PATH_MAX 4096 19 | #endif 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #undef SVN_ERR 31 | #define SVN_ERR(expr) SVN_INT_ERR(expr) 32 | #define apr_sane_push(arr, contents) *(char **)apr_array_push(arr) = contents 33 | 34 | #define TRUNK "/trunk/" 35 | 36 | time_t get_epoch(char *svn_date) 37 | { 38 | struct tm tm = {0}; 39 | char *date = malloc(strlen(svn_date) * sizeof(char *)); 40 | strncpy(date, svn_date, strlen(svn_date) - 8); 41 | strptime(date, "%Y-%m-%dT%H:%M:%S", &tm); 42 | free(date); 43 | return mktime(&tm); 44 | } 45 | 46 | int dump_blob(svn_fs_root_t *root, char *full_path, apr_pool_t *pool) 47 | { 48 | apr_size_t len; 49 | svn_stream_t *stream, *outstream; 50 | svn_filesize_t stream_length; 51 | 52 | SVN_ERR(svn_fs_file_length(&stream_length, root, full_path, pool)); 53 | SVN_ERR(svn_fs_file_contents(&stream, root, full_path, pool)); 54 | 55 | fprintf(stdout, "data %lu\n", stream_length); 56 | fflush(stdout); 57 | 58 | SVN_ERR(svn_stream_for_stdout(&outstream, pool)); 59 | SVN_ERR(svn_stream_copy(stream, outstream, pool)); 60 | 61 | fprintf(stdout, "\n"); 62 | fflush(stdout); 63 | 64 | return 0; 65 | } 66 | 67 | int export_revision(svn_revnum_t rev, svn_fs_t *fs, apr_pool_t *pool) 68 | { 69 | unsigned int mark; 70 | const void *key; 71 | void *val; 72 | char *path, *file_change; 73 | apr_pool_t *revpool; 74 | apr_hash_t *changes, *props; 75 | apr_hash_index_t *i; 76 | apr_array_header_t *file_changes; 77 | svn_string_t *author, *committer, *svndate, *svnlog; 78 | svn_boolean_t is_dir; 79 | svn_fs_root_t *fs_root; 80 | svn_fs_path_change_t *change; 81 | 82 | fprintf(stderr, "Exporting revision %ld... ", rev); 83 | 84 | SVN_ERR(svn_fs_revision_root(&fs_root, fs, rev, pool)); 85 | SVN_ERR(svn_fs_paths_changed(&changes, fs_root, pool)); 86 | SVN_ERR(svn_fs_revision_proplist(&props, fs, rev, pool)); 87 | 88 | revpool = svn_pool_create(pool); 89 | 90 | file_changes = apr_array_make(pool, apr_hash_count(changes), sizeof(char *)); 91 | mark = 1; 92 | for (i = apr_hash_first(pool, changes); i; i = apr_hash_next(i)) { 93 | svn_pool_clear(revpool); 94 | apr_hash_this(i, &key, NULL, &val); 95 | path = (char *)key; 96 | change = (svn_fs_path_change_t *)val; 97 | 98 | SVN_ERR(svn_fs_is_dir(&is_dir, fs_root, path, revpool)); 99 | 100 | if (is_dir || strncmp(TRUNK, path, strlen(TRUNK))) { 101 | continue; 102 | } 103 | 104 | if (change->change_kind == svn_fs_path_change_delete) { 105 | apr_sane_push(file_changes, (char *)svn_string_createf(pool, "D %s", path + strlen(TRUNK))->data); 106 | } else { 107 | apr_sane_push(file_changes, (char *)svn_string_createf(pool, "M 644 :%u %s", mark, path + strlen(TRUNK))->data); 108 | fprintf(stdout, "blob\nmark :%u\n", mark++); 109 | dump_blob(fs_root, (char *)path, revpool); 110 | } 111 | } 112 | 113 | if (file_changes->nelts == 0) { 114 | fprintf(stderr, "skipping.\n"); 115 | svn_pool_destroy(revpool); 116 | return 0; 117 | } 118 | 119 | author = apr_hash_get(props, "svn:author", APR_HASH_KEY_STRING); 120 | if (svn_string_isempty(author)) 121 | author = svn_string_create("nobody", pool); 122 | svndate = apr_hash_get(props, "svn:date", APR_HASH_KEY_STRING); 123 | svnlog = apr_hash_get(props, "svn:log", APR_HASH_KEY_STRING); 124 | 125 | fprintf(stdout, "commit refs/heads/master\n"); 126 | fprintf(stdout, "committer %s <%s@localhost> %ld -0000\n", author->data, author->data, get_epoch((char *)svndate->data)); 127 | fprintf(stdout, "data %d\n", svnlog->len); 128 | fputs(svnlog->data, stdout); 129 | fprintf(stdout, "\n"); 130 | fputs(apr_array_pstrcat(pool, file_changes, '\n'), stdout); 131 | fprintf(stdout, "\n\n"); 132 | fflush(stdout); 133 | 134 | svn_pool_destroy(revpool); 135 | 136 | fprintf(stderr, "done!\n"); 137 | 138 | return 0; 139 | } 140 | 141 | int crawl_revisions(char *repos_path) 142 | { 143 | apr_pool_t *pool, *subpool; 144 | svn_fs_t *fs; 145 | svn_repos_t *repos; 146 | svn_revnum_t youngest_rev, min_rev, max_rev, rev; 147 | 148 | pool = svn_pool_create(NULL); 149 | 150 | SVN_ERR(svn_fs_initialize(pool)); 151 | SVN_ERR(svn_repos_open(&repos, repos_path, pool)); 152 | if ((fs = svn_repos_fs(repos)) == NULL) 153 | return -1; 154 | SVN_ERR(svn_fs_youngest_rev(&youngest_rev, fs, pool)); 155 | 156 | min_rev = 1; 157 | max_rev = youngest_rev; 158 | 159 | subpool = svn_pool_create(pool); 160 | for (rev = min_rev; rev <= max_rev; rev++) { 161 | svn_pool_clear(subpool); 162 | export_revision(rev, fs, subpool); 163 | } 164 | 165 | svn_pool_destroy(pool); 166 | 167 | return 0; 168 | } 169 | 170 | int main(int argc, char *argv[]) 171 | { 172 | if (argc != 2) { 173 | fprintf(stderr, "usage: %s REPOS_PATH\n", argv[0]); 174 | return -1; 175 | } 176 | 177 | if (apr_initialize() != APR_SUCCESS) { 178 | fprintf(stderr, "You lose at apr_initialize().\n"); 179 | return -1; 180 | } 181 | 182 | crawl_revisions(argv[1]); 183 | 184 | apr_terminate(); 185 | 186 | return 0; 187 | } 188 | -------------------------------------------------------------------------------- /post-process_files/whitespace1.patch: -------------------------------------------------------------------------------- 1 | From 2bae083fadde7964d69b694bb122298a39a25846 Mon Sep 17 00:00:00 2001 2 | From: "R. Andrew Ohana" 3 | Date: Fri, 22 Mar 2013 14:18:53 -0700 4 | Subject: [PATCH] (FIXUP) correct doctests for stripspaced repository 5 | 6 | --- 7 | 8 | diff --git a/__SAGE_SRC__/sage/combinat/ncsf_qsym/tutorial.py b/__SAGE_SRC__/sage/combinat/ncsf_qsym/tutorial.py 9 | index f224eee..d5b03a8 100644 10 | --- a/__SAGE_SRC__/sage/combinat/ncsf_qsym/tutorial.py 11 | +++ b/__SAGE_SRC__/sage/combinat/ncsf_qsym/tutorial.py 12 | @@ -138,7 +138,7 @@ related to the monomial symmetric functions by `m_\lambda = 13 | \sum_{sort(c) = \lambda} M_c`:: 14 | 15 | sage: SymmetricFunctions(QQ).inject_shorthands() 16 | - doctest:1075: RuntimeWarning: redefining global value `e` 17 | + doctest:1074: RuntimeWarning: redefining global value `e` 18 | sage: m[2,1] 19 | m[2, 1] 20 | sage: M(m[2,1]) 21 | diff --git a/__SAGE_SRC__/sage/ext/gen_interpreters.py b/__SAGE_SRC__/sage/ext/gen_interpreters.py 22 | index 35f5d10..95c1a21 100644 23 | --- a/__SAGE_SRC__/sage/ext/gen_interpreters.py 24 | +++ b/__SAGE_SRC__/sage/ext/gen_interpreters.py 25 | @@ -2249,7 +2249,7 @@ class RDFInterpreter(StackInterpreter): 26 | sage: instrs['add'] 27 | add: SS->S = 'o0 = i0 + i1;' 28 | sage: instrs['py_call'] 29 | - py_call: *->S = ' \nPyObject *py_arg...goto error;\n}\n' 30 | + py_call: *->S = '\nPyObject *py_arg...goto error;\n}\n' 31 | 32 | Make sure that pow behaves reasonably:: 33 | 34 | diff --git a/__SAGE_SRC__/sage/geometry/polyhedron/plot.py b/__SAGE_SRC__/sage/geometry/polyhedron/plot.py 35 | index 71017f8..ec1f3ac 100644 36 | --- a/__SAGE_SRC__/sage/geometry/polyhedron/plot.py 37 | +++ b/__SAGE_SRC__/sage/geometry/polyhedron/plot.py 38 | @@ -956,7 +956,7 @@ class Projection(SageObject): 39 | sage: cube = polytopes.n_cube(3) 40 | sage: cube_proj = cube.projection() 41 | sage: wire = cube_proj.render_wireframe_3d() 42 | - sage: print wire.tachyon().split('\n')[77] # for testing 43 | + sage: print wire.tachyon().split('\n')[76] # for testing 44 | FCylinder base -1.0 1.0 -1.0 apex -1.0 -1.0 -1.0 rad 0.005 texture... 45 | """ 46 | wireframe = []; 47 | diff --git a/__SAGE_SRC__/sage/misc/abstract_method.py b/__SAGE_SRC__/sage/misc/abstract_method.py 48 | index ca8a600..955f2bd 100644 49 | --- a/__SAGE_SRC__/sage/misc/abstract_method.py 50 | +++ b/__SAGE_SRC__/sage/misc/abstract_method.py 51 | @@ -194,8 +194,7 @@ class AbstractMethod(object): 52 | sage: src[0] 53 | 'def banner():\n' 54 | sage: lines 55 | - 77 56 | - 57 | + 74 58 | """ 59 | from sage.misc.sageinspect import sage_getsourcelines 60 | return sage_getsourcelines(self._f) 61 | diff --git a/__SAGE_SRC__/sage/misc/lazy_attribute.py b/__SAGE_SRC__/sage/misc/lazy_attribute.py 62 | index 3cb6bf0..d9fc2d6 100644 63 | --- a/__SAGE_SRC__/sage/misc/lazy_attribute.py 64 | +++ b/__SAGE_SRC__/sage/misc/lazy_attribute.py 65 | @@ -495,8 +495,7 @@ class lazy_attribute(object): 66 | sage: src[0] 67 | 'def banner():\n' 68 | sage: lines 69 | - 77 70 | - 71 | + 74 72 | """ 73 | from sage.misc.sageinspect import sage_getsourcelines 74 | return sage_getsourcelines(self.f) 75 | diff --git a/__SAGE_SRC__/sage/misc/sagedoc.py b/__SAGE_SRC__/sage/misc/sagedoc.py 76 | index 9061569..56b282c 100644 77 | --- a/__SAGE_SRC__/sage/misc/sagedoc.py 78 | +++ b/__SAGE_SRC__/sage/misc/sagedoc.py 79 | @@ -407,9 +407,9 @@ def format(s, embedded=False): 80 | EXAMPLES:: 81 | 82 | sage: from sage.misc.sagedoc import format 83 | - sage: identity_matrix(2).rook_vector.__doc__[115:184] 84 | + sage: identity_matrix(2).rook_vector.__doc__[107:176] 85 | 'Let `A` be a general `m` by `n`\n (0,1)-matrix with `m \\le n`. ' 86 | - sage: format(identity_matrix(2).rook_vector.__doc__[115:184]) 87 | + sage: format(identity_matrix(2).rook_vector.__doc__[107:176]) 88 | 'Let A be a general m by n\n (0,1)-matrix with m <= n.\n' 89 | 90 | If the first line of the string is 'nodetex', remove 'nodetex' but 91 | diff --git a/__SAGE_SRC__/sage/misc/sageinspect.py b/__SAGE_SRC__/sage/misc/sageinspect.py 92 | index 3a51b0f..a65ad03 100644 93 | --- a/__SAGE_SRC__/sage/misc/sageinspect.py 94 | +++ b/__SAGE_SRC__/sage/misc/sageinspect.py 95 | @@ -1675,7 +1675,7 @@ def sage_getsourcelines(obj, is_binary=False): 96 | 97 | sage: from sage.misc.sageinspect import sage_getsourcelines 98 | sage: sage_getsourcelines(matrix, True)[1] 99 | - 731 100 | + 726 101 | sage: sage_getsourcelines(matrix, False)[0][0][6:] 102 | 'MatrixFactory(object):\n' 103 | 104 | diff --git a/__SAGE_SRC__/sage/plot/plot3d/shapes.pyx b/__SAGE_SRC__/sage/plot/plot3d/shapes.pyx 105 | index 588bd91..0d7d6e2 100644 106 | --- a/__SAGE_SRC__/sage/plot/plot3d/shapes.pyx 107 | +++ b/__SAGE_SRC__/sage/plot/plot3d/shapes.pyx 108 | @@ -342,11 +342,11 @@ cdef class Cylinder(ParametricSurface): 109 | sage: from sage.plot.plot3d.shapes import Cylinder 110 | sage: C = Cylinder(1/2, 4, closed=False) 111 | sage: C.tachyon_repr(C.default_render_params()) 112 | - 'FCylinder \n Base 0 0 0\n Apex 0 0 4.0\n Rad 0.5\n texture... ' 113 | + 'FCylinder\n Base 0 0 0\n Apex 0 0 4.0\n Rad 0.5\n texture... ' 114 | sage: C = Cylinder(1, 2) 115 | sage: C.tachyon_repr(C.default_render_params()) 116 | ['Ring Center 0 0 0 Normal 0 0 1 Inner 0 Outer 1.0 texture...', 117 | - 'FCylinder \n Base 0 0 0\n Apex 0 0 2.0\n Rad 1.0\n texture... ', 118 | + 'FCylinder\n Base 0 0 0\n Apex 0 0 2.0\n Rad 1.0\n texture... ', 119 | 'Ring Center 0 0 2.0 Normal 0 0 1 Inner 0 Outer 1.0 texture...'] 120 | """ 121 | transform = render_params.transform 122 | -- 123 | 1.8.1.5 124 | 125 | -------------------------------------------------------------------------------- /fast-export/svn-fast-export.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # 3 | # svn-fast-export.py 4 | # ---------- 5 | # Walk through each revision of a local Subversion repository and export it 6 | # in a stream that git-fast-import can consume. 7 | # 8 | # Author: Chris Lee 9 | # License: MIT 10 | 11 | trunk_path = '/trunk/' 12 | branches_path = '/branches/' 13 | tags_path = '/tags/' 14 | 15 | first_rev = 1 16 | final_rev = 0 17 | 18 | import sys, os.path 19 | from optparse import OptionParser 20 | from time import mktime, strptime 21 | from svn.fs import svn_fs_file_length, svn_fs_file_contents, svn_fs_is_dir, svn_fs_revision_root, svn_fs_youngest_rev, svn_fs_revision_proplist, svn_fs_paths_changed 22 | from svn.core import svn_pool_create, svn_pool_clear, svn_pool_destroy, svn_stream_for_stdout, svn_stream_copy, svn_stream_close, run_app 23 | from svn.repos import svn_repos_open, svn_repos_fs 24 | 25 | ct_short = ['M', 'A', 'D', 'R', 'X'] 26 | 27 | def dump_file_blob(root, full_path, pool): 28 | stream_length = svn_fs_file_length(root, full_path, pool) 29 | stream = svn_fs_file_contents(root, full_path, pool) 30 | sys.stdout.write("data %s\n" % stream_length) 31 | sys.stdout.flush() 32 | ostream = svn_stream_for_stdout(pool) 33 | svn_stream_copy(stream, ostream, pool) 34 | svn_stream_close(ostream) 35 | sys.stdout.write("\n") 36 | 37 | 38 | def export_revision(rev, repo, fs, pool): 39 | sys.stderr.write("Exporting revision %s... " % rev) 40 | 41 | revpool = svn_pool_create(pool) 42 | svn_pool_clear(revpool) 43 | 44 | # Open a root object representing the youngest (HEAD) revision. 45 | root = svn_fs_revision_root(fs, rev, revpool) 46 | 47 | # And the list of what changed in this revision. 48 | changes = svn_fs_paths_changed(root, revpool) 49 | 50 | i = 1 51 | marks = {} 52 | file_changes = [] 53 | 54 | for path, change_type in changes.iteritems(): 55 | c_t = ct_short[change_type.change_kind] 56 | if svn_fs_is_dir(root, path, revpool): 57 | continue 58 | 59 | if not path.startswith(trunk_path): 60 | # We don't handle branches. Or tags. Yet. 61 | pass 62 | else: 63 | if c_t == 'D': 64 | file_changes.append("D %s" % path.replace(trunk_path, '')) 65 | else: 66 | marks[i] = path.replace(trunk_path, '') 67 | file_changes.append("M 644 :%s %s" % (i, marks[i])) 68 | sys.stdout.write("blob\nmark :%s\n" % i) 69 | dump_file_blob(root, path, revpool) 70 | i += 1 71 | 72 | # Get the commit author and message 73 | props = svn_fs_revision_proplist(fs, rev, revpool) 74 | 75 | # Do the recursive crawl. 76 | if props.has_key('svn:author'): 77 | author = "%s <%s@localhost>" % (props['svn:author'], props['svn:author']) 78 | else: 79 | author = 'nobody ' 80 | 81 | if len(file_changes) == 0: 82 | svn_pool_destroy(revpool) 83 | sys.stderr.write("skipping.\n") 84 | return 85 | 86 | svndate = props['svn:date'][0:-8] 87 | commit_time = mktime(strptime(svndate, '%Y-%m-%dT%H:%M:%S')) 88 | sys.stdout.write("commit refs/heads/master\n") 89 | sys.stdout.write("committer %s %s -0000\n" % (author, int(commit_time))) 90 | sys.stdout.write("data %s\n" % len(props['svn:log'])) 91 | sys.stdout.write(props['svn:log']) 92 | sys.stdout.write("\n") 93 | sys.stdout.write('\n'.join(file_changes)) 94 | sys.stdout.write("\n\n") 95 | 96 | svn_pool_destroy(revpool) 97 | 98 | sys.stderr.write("done!\n") 99 | 100 | #if rev % 1000 == 0: 101 | # sys.stderr.write("gc: %s objects\n" % len(gc.get_objects())) 102 | # sleep(5) 103 | 104 | 105 | def crawl_revisions(pool, repos_path): 106 | """Open the repository at REPOS_PATH, and recursively crawl all its 107 | revisions.""" 108 | global final_rev 109 | 110 | # Open the repository at REPOS_PATH, and get a reference to its 111 | # versioning filesystem. 112 | repos_obj = svn_repos_open(repos_path, pool) 113 | fs_obj = svn_repos_fs(repos_obj) 114 | 115 | # Query the current youngest revision. 116 | youngest_rev = svn_fs_youngest_rev(fs_obj, pool) 117 | 118 | 119 | first_rev = 1 120 | if final_rev == 0: 121 | final_rev = youngest_rev 122 | for rev in xrange(first_rev, final_rev + 1): 123 | export_revision(rev, repos_obj, fs_obj, pool) 124 | 125 | 126 | if __name__ == '__main__': 127 | usage = '%prog [options] REPOS_PATH' 128 | parser = OptionParser() 129 | parser.set_usage(usage) 130 | parser.add_option('-f', '--final-rev', help='Final revision to import', 131 | dest='final_rev', metavar='FINAL_REV', type='int') 132 | parser.add_option('-t', '--trunk-path', help='Path in repo to /trunk', 133 | dest='trunk_path', metavar='TRUNK_PATH') 134 | parser.add_option('-b', '--branches-path', help='Path in repo to /branches', 135 | dest='branches_path', metavar='BRANCHES_PATH') 136 | parser.add_option('-T', '--tags-path', help='Path in repo to /tags', 137 | dest='tags_path', metavar='TAGS_PATH') 138 | (options, args) = parser.parse_args() 139 | 140 | if options.trunk_path != None: 141 | trunk_path = options.trunk_path 142 | if options.branches_path != None: 143 | branches_path = options.branches_path 144 | if options.tags_path != None: 145 | tags_path = options.tags_path 146 | if options.final_rev != None: 147 | final_rev = options.final_rev 148 | 149 | if len(args) != 1: 150 | parser.print_help() 151 | sys.exit(2) 152 | 153 | # Canonicalize (enough for Subversion, at least) the repository path. 154 | repos_path = os.path.normpath(args[0]) 155 | if repos_path == '.': 156 | repos_path = '' 157 | 158 | # Call the app-wrapper, which takes care of APR initialization/shutdown 159 | # and the creation and cleanup of our top-level memory pool. 160 | run_app(crawl_revisions, repos_path) 161 | -------------------------------------------------------------------------------- /fast-export/svn-archive.c: -------------------------------------------------------------------------------- 1 | /* 2 | * svn-archive.c 3 | * ---------- 4 | * Walk through a given revision of a local Subversion repository and export 5 | * all of the contents as a tarfile. 6 | * 7 | * Author: Chris Lee 8 | * License: MIT 9 | */ 10 | 11 | #define _XOPEN_SOURCE 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #ifndef PATH_MAX 18 | #define PATH_MAX 4096 19 | #endif 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #undef SVN_ERR 32 | #define SVN_ERR(expr) SVN_INT_ERR(expr) 33 | #define apr_sane_push(arr, contents) *(char **)apr_array_push(arr) = contents 34 | 35 | #define TRUNK "/trunk" 36 | 37 | static time_t archive_time; 38 | 39 | time_t get_epoch(char *svn_date) 40 | { 41 | struct tm tm = {0}; 42 | char *date = malloc(strlen(svn_date) * sizeof(char *)); 43 | strncpy(date, svn_date, strlen(svn_date) - 8); 44 | strptime(date, "%Y-%m-%dT%H:%M:%S", &tm); 45 | free(date); 46 | return mktime(&tm); 47 | } 48 | 49 | int tar_header(apr_pool_t *pool, char *path, char *node, size_t f_size) 50 | { 51 | char buf[512]; 52 | unsigned int i, checksum; 53 | svn_boolean_t is_dir; 54 | 55 | memset(buf, 0, sizeof(buf)); 56 | 57 | if ((strlen(path) == 0) && (strlen(node) == 0)) { 58 | return 0; 59 | } 60 | 61 | if (strlen(node) == 0) { 62 | is_dir = 1; 63 | } else { 64 | is_dir = 0; 65 | } 66 | 67 | if (strlen(path) == 0) { 68 | strncpy(buf, apr_psprintf(pool, "%s", node), 99); 69 | } else if (strlen(path) + strlen(node) < 100) { 70 | strncpy(buf, apr_psprintf(pool, "%s/%s", path+1, node), 99); 71 | } else { 72 | fprintf(stderr, "really long file path...\n"); 73 | strncpy(&buf[0], node, 99); 74 | strncpy(&buf[345], path+1, 154); 75 | } 76 | 77 | strncpy(&buf[100], apr_psprintf(pool, "%07o", (is_dir ? 0755 : 0644)), 7); 78 | strncpy(&buf[108], apr_psprintf(pool, "%07o", 1000), 7); 79 | strncpy(&buf[116], apr_psprintf(pool, "%07o", 1000), 7); 80 | strncpy(&buf[124], apr_psprintf(pool, "%011lo", f_size), 11); 81 | strncpy(&buf[136], apr_psprintf(pool, "%011lo", archive_time), 11); 82 | strncpy(&buf[156], (is_dir ? "5" : "0"), 1); 83 | strncpy(&buf[257], "ustar ", 8); 84 | strncpy(&buf[265], "clee", 31); 85 | strncpy(&buf[297], "clee", 31); 86 | // strncpy(&buf[329], apr_psprintf(pool, "%07o", 0), 7); 87 | // strncpy(&buf[337], apr_psprintf(pool, "%07o", 0), 7); 88 | 89 | strncpy(&buf[148], " ", 8); 90 | checksum = 0; 91 | for (i = 0; i < sizeof(buf); i++) { 92 | checksum += buf[i]; 93 | } 94 | strncpy(&buf[148], apr_psprintf(pool, "%07o", checksum & 0x1fffff), 7); 95 | 96 | fwrite(buf, sizeof(char), sizeof(buf), stdout); 97 | 98 | return 0; 99 | } 100 | 101 | int tar_footer() 102 | { 103 | char block[1024]; 104 | memset(block, 0, sizeof(block)); 105 | fwrite(block, sizeof(char), sizeof(block), stdout); 106 | } 107 | 108 | int dump_blob(svn_fs_root_t *root, char *prefix, char *path, char *node, apr_pool_t *pool) 109 | { 110 | char *full_path, buf[512]; 111 | apr_size_t len; 112 | svn_stream_t *stream; 113 | svn_filesize_t stream_length; 114 | 115 | full_path = apr_psprintf(pool, "%s%s/%s", prefix, path, node); 116 | 117 | SVN_ERR(svn_fs_file_length(&stream_length, root, full_path, pool)); 118 | SVN_ERR(svn_fs_file_contents(&stream, root, full_path, pool)); 119 | 120 | tar_header(pool, path, node, stream_length); 121 | 122 | do { 123 | len = sizeof(buf); 124 | memset(buf, '\0', sizeof(buf)); 125 | SVN_ERR(svn_stream_read(stream, buf, &len)); 126 | fwrite(buf, sizeof(char), sizeof(buf), stdout); 127 | } while (len == sizeof(buf)); 128 | 129 | return 0; 130 | } 131 | 132 | int dump_tree(svn_fs_root_t *root, char *prefix, char *path, apr_pool_t *pool) 133 | { 134 | const void *key; 135 | void *val; 136 | char *node, *subpath, *full_path; 137 | 138 | apr_pool_t *subpool; 139 | apr_hash_t *dir_entries; 140 | apr_hash_index_t *i; 141 | 142 | svn_boolean_t is_dir; 143 | 144 | tar_header(pool, path, "", 0); 145 | 146 | SVN_ERR(svn_fs_dir_entries(&dir_entries, root, apr_psprintf(pool, "%s/%s", prefix, path), pool)); 147 | 148 | subpool = svn_pool_create(pool); 149 | 150 | for (i = apr_hash_first(pool, dir_entries); i; i = apr_hash_next(i)) { 151 | svn_pool_clear(subpool); 152 | apr_hash_this(i, &key, NULL, &val); 153 | node = (char *)key; 154 | 155 | subpath = apr_psprintf(subpool, "%s/%s", path, node); 156 | full_path = apr_psprintf(subpool, "%s%s", prefix, subpath); 157 | 158 | svn_fs_is_dir(&is_dir, root, full_path, subpool); 159 | 160 | if (is_dir) { 161 | dump_tree(root, prefix, subpath, subpool); 162 | } else { 163 | dump_blob(root, prefix, path, node, subpool); 164 | } 165 | } 166 | 167 | svn_pool_destroy(subpool); 168 | 169 | return 0; 170 | } 171 | 172 | int crawl_filesystem(char *repos_path, char *root_path, apr_pool_t *pool) 173 | { 174 | char *path; 175 | 176 | apr_hash_t *props; 177 | apr_hash_index_t *i; 178 | 179 | svn_repos_t *repos; 180 | svn_fs_t *fs; 181 | svn_string_t *svndate; 182 | svn_revnum_t youngest_rev, export_rev; 183 | svn_fs_root_t *fs_root; 184 | 185 | SVN_ERR(svn_fs_initialize(pool)); 186 | SVN_ERR(svn_repos_open(&repos, repos_path, pool)); 187 | if ((fs = svn_repos_fs(repos)) == NULL) 188 | return -1; 189 | SVN_ERR(svn_fs_youngest_rev(&youngest_rev, fs, pool)); 190 | 191 | export_rev = youngest_rev; 192 | 193 | SVN_ERR(svn_fs_revision_root(&fs_root, fs, export_rev, pool)); 194 | SVN_ERR(svn_fs_revision_proplist(&props, fs, export_rev, pool)); 195 | 196 | svndate = apr_hash_get(props, "svn:date", APR_HASH_KEY_STRING); 197 | archive_time = get_epoch((char *)svndate->data); 198 | 199 | fprintf(stderr, "Exporting archive of r%ld... \n", export_rev); 200 | 201 | dump_tree(fs_root, root_path, "", pool); 202 | 203 | tar_footer(); 204 | 205 | fprintf(stderr, "done!\n"); 206 | 207 | return 0; 208 | } 209 | 210 | int main(int argc, char *argv[]) 211 | { 212 | apr_pool_t *pool; 213 | apr_getopt_t *options; 214 | 215 | apr_getopt_option_t long_options[] = { 216 | { "help", 'h', 0 }, 217 | { "prefix", 'p', 0 }, 218 | { "basename", 'b', 0 }, 219 | { "revision", 'r', 0 }, 220 | { NULL, 0, 0 } 221 | }; 222 | 223 | if (argc < 2) { 224 | fprintf(stderr, "usage: %s REPOS_PATH [prefix]\n", argv[0]); 225 | return -1; 226 | } 227 | 228 | if (apr_initialize() != APR_SUCCESS) { 229 | fprintf(stderr, "You lose at apr_initialize().\n"); 230 | return -1; 231 | } 232 | 233 | pool = svn_pool_create(NULL); 234 | 235 | crawl_filesystem(argv[1], (argc == 3 ? argv[2] : TRUNK), pool); 236 | 237 | apr_terminate(); 238 | 239 | return 0; 240 | } 241 | -------------------------------------------------------------------------------- /post-process_files/sage-env1.patch: -------------------------------------------------------------------------------- 1 | From 55d157975c73952d5f5049740bd62ee7700abec3 Mon Sep 17 00:00:00 2001 2 | From: "R. Andrew Ohana" 3 | Date: Wed, 27 Feb 2013 22:34:35 -0800 4 | Subject: [PATCH] (FIXUP) make sage-env and basic startup not depend on the 5 | spkg directory 6 | 7 | --- 8 | 9 | diff --git a/sage b/sage 10 | index 6597c54..4ca06c1 100755 11 | --- a/sage 12 | +++ b/sage 13 | @@ -124,11 +124,10 @@ fi 14 | export SAGE_ROOT 15 | 16 | # Run the actual Sage script 17 | -if [ -x "$SAGE_ROOT/spkg/bin/sage" ]; then 18 | - "$SAGE_ROOT/spkg/bin/sage" "$@" 19 | -elif [ -x "$SAGE_ROOT/local/bin/sage-sage" ]; then # Support sage-4.x 20 | - export CUR=`pwd` 21 | - "$SAGE_ROOT/local/bin/sage-sage" "$@" 22 | +if [ -x "$SAGE_ROOT/local/bin/sage" ]; then 23 | + "$SAGE_ROOT/local/bin/sage" "$@" 24 | +elif [ -x "$SAGE_ROOT/__SAGE_SCRIPTS_DIR__/sage" ]; then # For errors pre-installation 25 | + "$SAGE_ROOT/__SAGE_SCRIPTS_DIR__/sage" "$@" 26 | else 27 | echo >&2 "$0: no Sage installation found in \$SAGE_ROOT=$SAGE_ROOT" 28 | exit 1 29 | diff --git a/__SAGE_SCRIPTS_DIR__/sage b/__SAGE_SCRIPTS_DIR__/sage 30 | index 142b9de..d304a92 100755 31 | --- a/__SAGE_SCRIPTS_DIR__/sage 32 | +++ b/__SAGE_SCRIPTS_DIR__/sage 33 | @@ -247,7 +247,7 @@ if [ "$1" = '--nodotsage' ]; then 34 | fi 35 | 36 | # Make sure this doesn't produce output (in case we use this in scripts). 37 | -. "$SAGE_ROOT/spkg/bin/sage-env" >&2 38 | +. "$0-env" >&2 39 | if [ $? -ne 0 ]; then 40 | echo >&2 "Error setting environment variables by sourcing '$SAGE_ROOT/spkg/bin/sage-env';" 41 | echo >&2 "possibly contact sage-devel (see http://groups.google.com/group/sage-devel)." 42 | diff --git a/__SAGE_SCRIPTS_DIR__/sage-env b/__SAGE_SCRIPTS_DIR__/sage-env 43 | index 6af257c..f551d0d 100644 44 | --- a/__SAGE_SCRIPTS_DIR__/sage-env 45 | +++ b/__SAGE_SCRIPTS_DIR__/sage-env 46 | @@ -7,7 +7,7 @@ 47 | # NOTES: 48 | # - You must *source* this script instead of executing. 49 | # - Use "return" instead of "exit" to signal a failure. Since this 50 | -# file is sourced, an "exit" here will actually exit spkg/bin/sage, 51 | +# file is sourced, an "exit" here will actually exit __SAGE_SCRIPTS_DIR__/sage, 52 | # which is probably not intended. 53 | # - All environment variables set here should be *exported*, otherwise 54 | # they won't be available in child programs. 55 | @@ -17,7 +17,7 @@ 56 | # If you want to set all environment variables for your shell like 57 | # they are during the build of Sage packages, type 58 | # 59 | -# . spkg/bin/sage-env 60 | +# . __SAGE_SCRIPTS_DIR__/sage-env 61 | # 62 | # from the SAGE_ROOT directory. 63 | # 64 | @@ -114,9 +114,9 @@ resolvelinks() { 65 | # or a guessed value based on pwd. 66 | if [ -n "$SAGE_ROOT" ]; then 67 | NEW_SAGE_ROOT="$SAGE_ROOT" 68 | -elif [ -f sage -a -d spkg ]; then 69 | +elif [ -f sage -a -d __SAGE_BUILD__ ]; then 70 | NEW_SAGE_ROOT="." 71 | -elif [ -f ../../sage -a -d ../../spkg ]; then 72 | +elif [ -f ../../sage -a -d ../../__SAGE_BUILD__ ]; then 73 | NEW_SAGE_ROOT="../.." 74 | else 75 | # No idea what SAGE_ROOT should be... 76 | @@ -129,7 +129,7 @@ fi 77 | NEW_SAGE_ROOT=`cd "$NEW_SAGE_ROOT" && pwd -P` 78 | 79 | # Sanity check NEW_SAGE_ROOT 80 | -if [ -f "$NEW_SAGE_ROOT/sage" -a -d "$NEW_SAGE_ROOT/spkg" ]; then 81 | +if [ -f "$NEW_SAGE_ROOT/sage" -a -d "$NEW_SAGE_ROOT/__SAGE_BUILD__" ]; then 82 | : 83 | else 84 | echo >&2 "Error: SAGE_ROOT is set to a bad value:" 85 | @@ -154,7 +154,7 @@ fi 86 | # "version number" of sage-env. If a different version of sage-env was 87 | # sourced earlier (when upgrading), we still source the new version. 88 | # The sage-env version should be increased whenever a newer sage-env is 89 | -# required for upgrading. Note that spkg/standard/deps might also need 90 | +# required for upgrading. Note that __SAGE_BUILD__/deps might also need 91 | # to be changed: the packages which need the new sage-env must depend on 92 | # SAGE_ROOT_REPO (the root repo contains sage-env). 93 | # 94 | @@ -172,6 +172,28 @@ export SAGE_ENV_SOURCED=$SAGE_ENV_VERSION 95 | export SAGE_ROOT="$NEW_SAGE_ROOT" 96 | 97 | 98 | +# sage-env must know where the Sage's script files are 99 | +if [ -z "$SAGE_SCRIPTS_DIR" ]; then 100 | + if [ -f "`dirname $0`/sage-env" ]; then 101 | + SAGE_SCRIPTS_DIR=`dirname $0` 102 | + elif [ -f "$SAGE_ROOT/local/bin/sage-env" ]; then 103 | + SAGE_SCRIPTS_DIR="$SAGE_ROOT/local/bin" 104 | + elif [ -f "$SAGE_ROOT/__SAGE_SCRIPTS_DIR__/sage-env" ]; then 105 | + SAGE_SCRIPTS_DIR="$SAGE_ROOT/__SAGE_SCRIPTS_DIR__" 106 | + else 107 | + echo >&2 "Error: You must set the SAGE_SCRIPTS_DIR environment variable to run this" 108 | + return 1 109 | + fi 110 | +elif [ ! -f "$SAGE_SCRIPTS_DIR/sage-env" ]; then 111 | + echo >&2 "Error: SAGE_SCRIPTS_DIR is set to a bad value:" 112 | + echo >&2 "SAGE_SCRIPTS_DIR=$SAGE_SCRIPTS_DIR" 113 | + echo >&2 "You must correct it or erase it and rerun this script" 114 | + return 1 115 | +fi 116 | + 117 | +# Make SAGE_SCRIPTS_DIR absolute 118 | +export SAGE_SCRIPTS_DIR="`cd "$SAGE_SCRIPTS_DIR" && pwd -P`" 119 | + 120 | # Call with: contains_spaces X${VAR}X 121 | # i.e., WITHOUT quotes but some character(s) around the environment variable to test. 122 | # (This function does return false for empty/unset variables.) 123 | @@ -224,11 +246,11 @@ fi 124 | export SAGE_LOCAL="$SAGE_ROOT/local" 125 | export SAGE_SHARE="$SAGE_LOCAL/share" 126 | export SAGE_EXTCODE="$SAGE_SHARE/sage/ext" 127 | -export SAGE_PACKAGES="$SAGE_ROOT/spkg" 128 | -export SAGE_SPKG_INST="$SAGE_ROOT/spkg/installed" 129 | -export SAGE_LOGS="$SAGE_ROOT/spkg/logs" 130 | -export SAGE_DOC="$SAGE_ROOT/devel/sage/doc" 131 | -export PATH="$SAGE_PACKAGES/bin:$SAGE_LOCAL/bin:$PATH" 132 | +export SAGE_SPKG_INST="__SAGE_INSTALLED__" 133 | +export SAGE_LOGS="$SAGE_ROOT/__SAGE_LOGS_DIR__" 134 | +export SAGE_SRC="$SAGE_ROOT/__SAGE_SRC__" 135 | +export SAGE_DOC="$SAGE_SRC/doc" 136 | +export PATH="$SAGE_SRC/__SAGE_SCRIPTS_REL__:$SAGE_LOCAL/bin:$PATH" 137 | 138 | # this is to be compatible with optional packages that haven't 139 | # been updated to not use SAGE_DATA 140 | @@ -279,7 +301,7 @@ HGENCODING="utf8" && export HGENCODING 141 | 142 | # Make Mercurial not use any user defaults (like enabling the pager extension) 143 | # This is needed in order to use mercurial in scripts. When running hg 144 | -# directly through "sage -hg", we will disable HGPLAIN in spkg/bin/sage. 145 | +# directly through "sage -hg", we will disable HGPLAIN in __SAGE_SCRIPTS_DIR__/sage. 146 | # See Trac Ticket #12058 147 | HGPLAIN="yes" && export HGPLAIN 148 | 149 | @@ -303,7 +325,7 @@ fi 150 | 151 | if [ "$DOT_SAGE" = "" ]; then 152 | # It is *not* an error if this directory does not exist, it will 153 | - # be created in spkg/bin/sage or devel/sage/sage/misc/misc.py. 154 | + # be created in __SAGE_SCRIPTS_DIR__/sage or __SAGE_SRC__/sage/misc/misc.py. 155 | # This also works if $HOME/.sage is a symbolic link to a 156 | # non-existing directory. 157 | DOT_SAGE=`resolvelinks "$HOME/.sage"` 158 | @@ -420,7 +442,7 @@ export PKG_CONFIG_PATH 159 | # Whenever a flag like SAGE64 has been set once, it needs to be 160 | # restored in every run of sage, as mixing 64-bit and 32-bit code is 161 | # bad idea at best. This script takes care of that. 162 | -. "$SAGE_ROOT/spkg/bin/sage-arch-env" 163 | +. "$SAGE_SCRIPTS_DIR/sage-arch-env" 164 | 165 | ############ compilation flags 166 | 167 | -- 168 | 1.8.1.5 169 | 170 | -------------------------------------------------------------------------------- /post-process_files/install1.patch: -------------------------------------------------------------------------------- 1 | From fe83cbc0b6ad476df64d2eb3b093e151ae3ebac7 Mon Sep 17 00:00:00 2001 2 | From: "R. Andrew Ohana" 3 | Date: Sun, 17 Mar 2013 00:45:21 -0700 4 | Subject: [PATCH] (FIXUP) move __SAGE_BUILD__/install to git layout 5 | 6 | --- 7 | 8 | diff --git a/Makefile b/Makefile 9 | index 160945f..5a615c8 100644 10 | --- a/Makefile 11 | +++ b/Makefile 12 | @@ -7,13 +7,14 @@ 13 | # See below for targets to build the documentation in other formats, 14 | # to run various types of test suites, and to remove parts of the build etc. 15 | 16 | -PIPE = spkg/pipestatus 17 | +PIPE = __SAGE_BUILD__/pipestatus 18 | 19 | 20 | all: start doc # indirectly depends on build 21 | 22 | build: 23 | - cd spkg && \ 24 | + @mkdir -p __SAGE_LOGS_DIR__ 25 | + cd __SAGE_BUILD__ && \ 26 | "../$(PIPE)" \ 27 | "env SAGE_PARALLEL_SPKG_BUILD='$(SAGE_PARALLEL_SPKG_BUILD)' ./install all 2>&1" \ 28 | "tee -a ../install.log" 29 | diff --git a/__SAGE_BUILD__/install b/__SAGE_BUILD__/install 30 | index 58b0a8a..44d272e 100755 31 | --- a/__SAGE_BUILD__/install 32 | +++ b/__SAGE_BUILD__/install 33 | @@ -4,15 +4,19 @@ 34 | # Set various environment variables 35 | ######################################################################## 36 | 37 | -# Assume current directory is SAGE_ROOT/spkg 38 | -SAGE_ROOT=`cd .. && pwd -P` 39 | -SAGE_LOCAL="$SAGE_ROOT/local" 40 | -SAGE_SHARE="$SAGE_LOCAL/share" 41 | -SAGE_LOGS="$SAGE_ROOT/spkg/logs" 42 | -SAGE_SPKG_INST="$SAGE_ROOT/spkg/installed" 43 | -PATH="$SAGE_ROOT/spkg/bin:$SAGE_LOCAL/bin:$PATH" 44 | -PYTHONPATH="$SAGE_LOCAL" 45 | -export SAGE_ROOT SAGE_LOCAL SAGE_LOGS SAGE_SPKG_INST PATH PYTHONPATH 46 | +# Assume current directory is SAGE_ROOT/__SAGE_BUILD__ 47 | +SAGE_ROOT="`cd .. && pwd -P`" 48 | +if [ -z "$MAKEFLAGS" ]; then 49 | + unset MAKEFLAGS 50 | +fi 51 | +. "$SAGE_ROOT/src/bin/sage-env" 52 | +PYTHONPATH="$SAGE_LOCAL/lib/python" 53 | +if [ -n "$SAGE_PATH" ]; then 54 | + PYTHONPATH="$SAGE_PATH:$PYTHONPATH" 55 | +fi 56 | +PYTHONHOME="$SAGE_LOCAL" 57 | +export PYTHONPATH PYTHONHOME 58 | 59 | # Storing the start time of the build process. The time is stored in 60 | # seconds since 1970-01-01 in a hidden file called 61 | @@ -39,15 +43,8 @@ EOF 62 | exit 2 63 | fi 64 | 65 | -# If spkg/bin/sage-env doesn't exist, we are surely upgrading (sage-env 66 | -# was moved to spkg/bin in sage-5.0). Manually set SAGE_UPGRADING=yes, 67 | -# as old versions of sage-upgrade didn't do this. 68 | -if [ ! -f "$SAGE_ROOT/spkg/bin/sage-env" ]; then 69 | - SAGE_UPGRADING=yes 70 | -fi 71 | - 72 | if [ "$SAGE_UPGRADING" = yes ]; then 73 | - # We're doing an upgrade. Let spkg/Makefile call sage-spkg with 74 | + # We're doing an upgrade. Let __SAGE_BUILD__/Makefile call sage-spkg with 75 | # "-f" to force rebuilding dependent packages, too: 76 | export SAGE_SPKG_OPTS="-f" 77 | 78 | @@ -135,7 +132,7 @@ sleep 5 79 | fi 80 | 81 | # Determine various compilers. These variables should not be exported, 82 | -# they are only used in this spkg/install script to determine whether to 83 | +# they are only used in this __SAGE_BUILD__/install script to determine whether to 84 | # install GCC. The "real" $CC, $CXX,... variables for building Sage are 85 | # set in sage-env. 86 | 87 | @@ -262,7 +259,7 @@ cat >"$SAGE_LOCAL/bin/sage_fortran" <Makefile 105 | @@ -293,7 +290,7 @@ exec 3>Makefile 106 | cat >&3 </dev/null` 127 | - do 128 | - ANS=`echo "$FILE" | sed 's|.*/||; s|\.spkg||'` 129 | - if [ -n "$ANS" ]; then 130 | - echo "$ANS" 131 | - return 0 132 | - fi 133 | - done 134 | - 135 | - echo >&2 "Cannot determine latest version of $PKG." 136 | - echo "$PKG" 137 | - return 1 138 | + if [ -f "$SAGE_ROOT/__SAGE_PKGS__/$PKG/package-version.txt" ]; then 139 | + echo -n $PKG- 140 | + cat "$SAGE_ROOT/__SAGE_PKGS__/$PKG/package-version.txt" 141 | + else 142 | + echo >&2 "Cannot determine latest version of $PKG." 143 | + echo "$PKG" 144 | + return 1 145 | + fi 146 | } 147 | 148 | cat >&3 <&3 172 | 173 | -# Copy spkg/standard/deps 174 | +# Copy __SAGE_BUILD__/deps 175 | cat >&3 <&3 186 | +cat "$SAGE_ROOT/__SAGE_BUILD__/deps" >&3 187 | 188 | # Close the Makefile 189 | exec 3>&- 190 | @@ -492,16 +477,9 @@ INST="`echo ${SAGE_SPKG_INST:-installed} | sed 's/ /\\\\ /g'`" 191 | # * If "make" doesn't understand the -q option (although we require 192 | # GNU make, which supports it), it should exit with a non-zero status 193 | # which is not a problem. 194 | -# * Only do this check if spkg/bin/sage-spkg exists, as that means we 195 | -# are running sage-5.x and sage-spkg understands MAKEFLAGS. 196 | -# If we are upgrading, we might have a pre-4.8 version of sage-spkg 197 | -# which doesn't check MAKEFLAGS. 198 | -# See Trac #12248 and also #12016. 199 | -if [ -f "$SAGE_ROOT/spkg/bin/sage-spkg" ]; then 200 | - if $MAKE -q INST="$INST" "$@"; then 201 | - echo "Nothing to (re)build / all up-to-date." 202 | - exit 0 203 | - fi 204 | +if $MAKE -q INST="$INST" "$@"; then 205 | + echo "Nothing to (re)build / all up-to-date." 206 | + exit 0 207 | fi 208 | 209 | # Dump environment for debugging purposes: 210 | @@ -530,7 +508,7 @@ EOF 211 | 212 | package: $base_f 213 | log file: $f 214 | -build directory: ${SAGE_BUILD_DIR:-$SAGE_ROOT/spkg/build}/$base_f 215 | +build directory: ${SAGE_BUILD_DIR:-$SAGE_ROOT/__SAGE_ARTIFACTS__}/$base_f 216 | EOF 217 | fi 218 | done 219 | -- 220 | 1.8.1.5 221 | 222 | -------------------------------------------------------------------------------- /post-process_files/hg1.patch: -------------------------------------------------------------------------------- 1 | From 54c6f79f57a4a1784df8fa21dc2d7f84b3433d2c Mon Sep 17 00:00:00 2001 2 | From: "R. Andrew Ohana" 3 | Date: Thu, 21 Mar 2013 15:17:57 -0700 4 | Subject: [PATCH] (FIXUP) remove mecurial dependency 5 | 6 | --- 7 | 8 | diff --git a/__SAGE_BUILD__/deps b/__SAGE_BUILD__/deps 9 | index c00df7a..efaacfd 100644 10 | --- a/__SAGE_BUILD__/deps 11 | +++ b/__SAGE_BUILD__/deps 12 | @@ -74,7 +74,6 @@ all-sage: \ 13 | $(INST)/$(M4RIE) \ 14 | $(INST)/$(MATPLOTLIB) \ 15 | $(INST)/$(MAXIMA) \ 16 | - $(INST)/$(MERCURIAL) \ 17 | $(INST)/$(MPC) \ 18 | $(INST)/$(MPFI) \ 19 | $(INST)/$(MPFR) \ 20 | @@ -314,9 +313,6 @@ $(INST)/$(RUBIKS): 21 | $(INST)/$(SQLITE): $(INST)/$(READLINE) 22 | +$(PIPE) "$(SAGE_SPKG) $(SQLITE) 2>&1" "tee -a $(SAGE_LOGS)/$(SQLITE).log" 23 | 24 | -$(INST)/$(MERCURIAL): $(INST)/$(PYTHON) 25 | - +$(PIPE) "$(SAGE_SPKG) $(MERCURIAL) 2>&1" "tee -a $(SAGE_LOGS)/$(MERCURIAL).log" 26 | - 27 | # To build SageTeX, you just need Python, but to test (SAGE_CHECK=yes) 28 | # SageTeX, you actually need to run sage, produce plots,... 29 | $(INST)/$(SAGETEX): $(INST)/$(PYTHON) \ 30 | @@ -451,7 +447,6 @@ sage: \ 31 | $(INST)/$(LINBOX) \ 32 | $(INST)/$(M4RI) \ 33 | $(INST)/$(M4RIE) \ 34 | - $(INST)/$(MERCURIAL) \ 35 | $(INST)/$(MPC) \ 36 | $(INST)/$(MPFI) \ 37 | $(INST)/$(MPFR) \ 38 | diff --git a/__SAGE_BUILD__/install b/__SAGE_BUILD__/install 39 | index f2aec2e..5062657 100755 40 | --- a/__SAGE_BUILD__/install 41 | +++ b/__SAGE_BUILD__/install 42 | @@ -389,7 +389,6 @@ M4RI=`newest_version libm4ri` 43 | M4RIE=`newest_version libm4rie` 44 | MATPLOTLIB=`newest_version matplotlib` 45 | MAXIMA=`newest_version maxima` 46 | -MERCURIAL=`newest_version mercurial` 47 | MPC=`newest_version mpc` 48 | MPFI=`newest_version mpfi` 49 | MPFR=`newest_version mpfr` 50 | diff --git a/__SAGE_SCRIPTS_DIR__/sage b/__SAGE_SCRIPTS_DIR__/sage 51 | index 49560e0..474cb36 100755 52 | --- a/__SAGE_SCRIPTS_DIR__/sage 53 | +++ b/__SAGE_SCRIPTS_DIR__/sage 54 | @@ -85,7 +85,6 @@ usage_advanced() { 55 | echo " -gap [...] -- run Sage's Gap with given arguments" 56 | echo " -gdb -- run Sage under the control of gdb" 57 | echo " -gp [...] -- run Sage's PARI/GP calculator with given arguments" 58 | - echo " -hg [...] -- run Sage's Mercurial with given arguments" 59 | echo " -ipython [...] -- run Sage's IPython using the default environment (not" 60 | echo " Sage), passing additional options to IPython" 61 | echo " -kash [...] -- run Sage's Kash with given arguments" 62 | @@ -144,12 +143,9 @@ usage_advanced() { 63 | echo " -ba [branch] -- same as -b and rebuild all Cython code" 64 | echo " -ba-force [branch] -- same as -ba, but don't query before rebuilding" 65 | echo " -br [branch] -- switch to, build, and run Sage given branch" 66 | - echo " -branch -- print the current Sage branch" 67 | echo " -bt [...] -- build and test, options like -t below" 68 | echo " -btp [...] -- build and test parallel, options like -tp below" 69 | echo " -btnew [...] -- build and test modified files, options like -tnew" 70 | - echo " -clone [new branch] -- clone a new branch of the Sage library from the" 71 | - echo " current branch" 72 | echo " -fixdoctests -- create .out that would pass the doctests" 73 | echo " and output a patch" 74 | echo " -startuptime [module] -- display how long each component of Sage takes to" 75 | @@ -339,12 +335,6 @@ if [ "$1" = '-root' -o "$1" = '--root' ]; then 76 | exit 0 77 | fi 78 | 79 | -if [ "$1" = '-branch' -o "$1" = '--branch' ]; then 80 | - cd "$SAGE_ROOT/devel/sage" 81 | - pwd -P | sed 's|.*/||; s|^sage-||' 82 | - exit $? 83 | -fi 84 | - 85 | ##################################################################### 86 | # Run Sage's versions of the standard Algebra/Geometry etc. software 87 | ##################################################################### 88 | @@ -557,14 +547,6 @@ EOF 89 | exit $status 90 | fi 91 | 92 | -if [ "$1" = '-hg' -o "$1" = '--hg' ]; then 93 | - shift 94 | - # Disable HGPLAIN, so we use all user defaults 95 | - # (both in $SAGE_LOCAL/etc/mercurial and $HOME/.hgrc) 96 | - unset HGPLAIN 97 | - exec "$SAGE_LOCAL/bin/hg" "$@" 98 | -fi 99 | - 100 | if [ "$1" = '-merge' -o "$1" = '--merge' ]; then 101 | shift 102 | exec sage-apply-ticket "$@" 103 | @@ -664,21 +646,6 @@ fi 104 | 105 | if [ "$1" = '-r' ]; then 106 | shift 107 | - if [ "$1" != "" ]; then 108 | - cd "$SAGE_ROOT/devel/" 109 | - if [ ! -d "sage-$1" ]; then 110 | - echo >&2 "No such branch '$SAGE_ROOT/devel/sage-$1'" 111 | - echo >&2 "Use 'sage --clone' to create a new branch." 112 | - exit 1 113 | - fi 114 | - # On Solaris (and perhaps other systems), "ln -snf FILE LINK" 115 | - # doesn't remove LINK and then relink it, so we need to first 116 | - # delete LINK -- in this case, SAGE_ROOT/devel/sage -- and then 117 | - # create a new link. We use the full path name to make sure we 118 | - # remove the correct file. 119 | - rm -f "$SAGE_ROOT/devel/sage" 120 | - ln -s "sage-$1" sage 121 | - fi 122 | interactive_sage 123 | fi 124 | 125 | @@ -713,12 +680,6 @@ if [ "$1" = '-sync-build' -o "$1" = '--sync-build' ]; then 126 | exec sage-sync-build.py "$@" 127 | fi 128 | 129 | -if [ "$1" = '-clone' -o "$1" = "--clone" ]; then 130 | - shift 131 | - time sage-clone "$@" 132 | - exit $? 133 | -fi 134 | - 135 | if [ "$1" = '-t' -o "$1" = '-bt' -o "$1" = '-tp' -o "$1" = '-btp' ]; then 136 | if [ "$1" = '-bt' -o "$1" = '-btp' ]; then 137 | build_sage 138 | diff --git a/__SAGE_SRC__/sage/misc/all.py b/__SAGE_SRC__/sage/misc/all.py 139 | index f92f569..c0877ce 100644 140 | --- a/__SAGE_SRC__/sage/misc/all.py 141 | +++ b/__SAGE_SRC__/sage/misc/all.py 142 | @@ -41,8 +41,6 @@ from fpickle import pickle_function, unpickle_function 143 | 144 | from dist import install_scripts 145 | 146 | -from hg import hg_sage, hg_scripts, hg_extcode, hg_sagenb, hg_root 147 | - 148 | from package import install_package, is_package_installed, standard_packages, optional_packages, experimental_packages, upgrade 149 | 150 | from pager import pager 151 | diff --git a/__SAGE_SRC__/sage/misc/lazy_import_cache.py b/__SAGE_SRC__/sage/misc/lazy_import_cache.py 152 | index 7cdd396..cbd1289 100644 153 | --- a/__SAGE_SRC__/sage/misc/lazy_import_cache.py 154 | +++ b/__SAGE_SRC__/sage/misc/lazy_import_cache.py 155 | @@ -17,8 +17,7 @@ def get_cache_file(): 156 | '...-lazy_import_cache.pickle' 157 | sage: get_cache_file().startswith(DOT_SAGE) 158 | True 159 | - sage: from sage.misc.misc import branch_current_hg 160 | - sage: branch_current_hg() in get_cache_file() 161 | + sage: '__SAGE_SRC__' in get_cache_file() 162 | True 163 | 164 | It shouldn't matter whether DOT_SAGE ends with a slash:: 165 | diff --git a/__SAGE_SRC__/sage/misc/misc.py b/__SAGE_SRC__/sage/misc/misc.py 166 | index 5b29892..cd28435 100644 167 | --- a/src/sage/misc/misc.py 168 | +++ b/src/sage/misc/misc.py 169 | @@ -2010,58 +2010,6 @@ def getitem(v, n): 170 | except TypeError: 171 | return v[int(n)] 172 | 173 | - 174 | -def branch_current_hg(): 175 | - """ 176 | - Return the current Mercurial branch name. 177 | - 178 | - TESTS:: 179 | - 180 | - sage: br = sage.misc.misc.branch_current_hg() 181 | - sage: len(br) > 0 182 | - True 183 | - 184 | - AUTHOR: 185 | - 186 | - - Jeroen Demeyer (#12481) 187 | - """ 188 | - try: 189 | - br = os.readlink(SAGE_SRC) 190 | - except OSError: 191 | - raise RuntimeError("Unable to determine branch") 192 | - br = os.path.basename(br) 193 | - 194 | - # Delete everything up to and including the first "-". 195 | - # (if there is no "-", then i == -1 and we return everything) 196 | - i = br.find('-') 197 | - return br[i+1:] 198 | - 199 | -def branch_current_hg_notice(branch): 200 | - r""" 201 | - Return a string describing the current branch. 202 | - 203 | - Also, indicate that the library is being loaded. 204 | - 205 | - INPUT: 206 | - 207 | - - ``branch`` -- a representation of the name of the 208 | - Sage library branch. 209 | - 210 | - OUTPUT: string 211 | - 212 | - .. note:: 213 | - 214 | - If the branch is main, then return an empty string. 215 | - """ 216 | - if branch[-1] == '/': 217 | - branch = branch[:-1] 218 | - if branch == 'main': 219 | - return '' 220 | - notice = 'Loading Sage library. Current Mercurial branch is: ' 221 | - return notice + branch 222 | - 223 | - 224 | - 225 | def pad_zeros(s, size=3): 226 | """ 227 | EXAMPLES:: 228 | 229 | diff --git a/__SAGE_SRC__/sage/tests/cmdline.py b/__SAGE_SRC__/sage/tests/cmdline.py 230 | index 65e2e65..b9aee0f 100644 231 | --- a/__SAGE_SRC__/sage/tests/cmdline.py 232 | +++ b/__SAGE_SRC__/sage/tests/cmdline.py 233 | @@ -11,7 +11,6 @@ test.sage 234 | test.spyx 235 | /path/to/test.spyx 236 | --advanced 237 | ---branch 238 | -c 239 | --cython 240 | --ecl 241 | @@ -20,7 +19,6 @@ test.spyx 242 | --gp 243 | -h 244 | --help 245 | ---hg 246 | --info 247 | --ipython 248 | --kash 249 | @@ -188,14 +186,6 @@ def test_executable(args, input="", timeout=50.0, cwd=None): 250 | sage: ret 251 | 0 252 | 253 | - sage: (out, err, ret) = test_executable(["sage", "--branch"]) 254 | - sage: len(out) >= 2 # at least one character + newline 255 | - True 256 | - sage: err 257 | - '' 258 | - sage: ret 259 | - 0 260 | - 261 | sage: (out, err, ret) = test_executable(["sage", "--root"]) 262 | sage: len(out) >= 2 # at least one character + newline 263 | True 264 | @@ -504,14 +494,6 @@ def test_executable(args, input="", timeout=50.0, cwd=None): 265 | 266 | Some programs of which we check functionality using only ``--version``:: 267 | 268 | - sage: (out, err, ret) = test_executable(["sage", "--hg", "--version"]) 269 | - sage: out.find("Mercurial Distributed SCM") >= 0 270 | - True 271 | - sage: err 272 | - '' 273 | - sage: ret 274 | - 0 275 | - 276 | sage: (out, err, ret) = test_executable(["sage", "--maxima", "--version"]) 277 | sage: out.find("Maxima ") >= 0 278 | True 279 | -- 280 | 1.8.1.5 281 | 282 | -------------------------------------------------------------------------------- /post-process_files/deps1.patch: -------------------------------------------------------------------------------- 1 | From 6fd62566da4864660ba6680f672f0330530fa313 Mon Sep 17 00:00:00 2001 2 | From: "R. Andrew Ohana" 3 | Date: Sun, 17 Mar 2013 01:45:00 -0700 4 | Subject: [PATCH] (FIXUP) __SAGE_BUILD__/deps: core repositories 5 | 6 | The core repositories are no longer spkgs, so their entries 7 | needed rewriting in deps. Also, the root repository is no longer 8 | installed, so nothing can depend on it. 9 | --- 10 | 11 | diff --git a/__SAGE_BUILD__/deps b/__SAGE_BUILD__/deps 12 | index 155a1af..c51d18b 100644 13 | --- a/__SAGE_BUILD__/deps 14 | +++ b/__SAGE_BUILD__/deps 15 | @@ -13,7 +13,7 @@ INST = "$(SAGE_SPKG_INST)" 16 | # (SAGE_ROOT/spkg/bin is added to the PATH in spkg/install). 17 | # Therefore, do not put an explicit path for sage-spkg here. 18 | SAGE_SPKG = sage-spkg $${SAGE_SPKG_OPTS} 19 | -PIPE = $(SAGE_ROOT)/spkg/pipestatus 20 | +PIPE = $(SAGE_ROOT)/__SAGE_BUILD__/pipestatus 21 | 22 | # Tell make not to look for files with these names: 23 | .PHONY: all all-sage base toolchain toolchain-deps 24 | @@ -45,7 +45,6 @@ all-sage: \ 25 | $(INST)/$(ECLIB) \ 26 | $(INST)/$(ECM) \ 27 | $(INST)/$(ELLIPTIC_CURVES) \ 28 | - $(INST)/$(EXTCODE) \ 29 | $(INST)/$(FFLASFFPACK) \ 30 | $(INST)/$(FLINT) \ 31 | $(INST)/$(FLINTQS) \ 32 | @@ -100,9 +99,6 @@ all-sage: \ 33 | $(INST)/$(RPY) \ 34 | $(INST)/$(READLINE) \ 35 | $(INST)/$(RUBIKS) \ 36 | - $(INST)/$(SAGE) \ 37 | - $(INST)/$(SAGE_SCRIPTS) \ 38 | - $(INST)/$(SAGE_ROOT_REPO) \ 39 | $(INST)/$(SAGENB) \ 40 | $(INST)/$(SAGETEX) \ 41 | $(INST)/$(SCIPY) \ 42 | @@ -118,7 +114,11 @@ all-sage: \ 43 | $(INST)/$(TACHYON) \ 44 | $(INST)/$(TERMCAP) \ 45 | $(INST)/$(ZLIB) \ 46 | - $(INST)/$(ZNPOLY) 47 | + $(INST)/$(ZNPOLY) \ 48 | + scripts \ 49 | + sage \ 50 | + csage \ 51 | + extcode 52 | 53 | # TOOLCHAIN consists of dependencies determined by spkg/install, 54 | # including for example the GCC package. 55 | @@ -138,8 +138,7 @@ toolchain-deps: 56 | 57 | # Everything needed to start up Sage using "./sage". Of course, not 58 | # every part of Sage will work. It does not include Maxima for example. 59 | -SAGERUNTIME = $(INST)/$(SAGE_SCRIPTS) $(INST)/$(SAGE) $(INST)/$(SAGENB) \ 60 | - $(INST)/$(IPYTHON) $(INST)/$(GAP) 61 | +SAGERUNTIME = scripts sage $(INST)/$(SAGENB) $(INST)/$(IPYTHON) $(INST)/$(GAP) 62 | 63 | ############################################################################### 64 | # Building the base system 65 | @@ -159,11 +158,7 @@ $(INST)/$(PREREQ): 66 | # spkg (which is gzip compressed). We continue using the old bzip2 67 | # installation (which is version 1.0.5 since sage-3.3), which is fine. 68 | $(INST)/$(BZIP2): $(INST)/$(PREREQ) 69 | - +if [ -f "$(SAGE_ROOT)/spkg/bin/sage-spkg" ] ; then \ 70 | - $(PIPE) "$(SAGE_SPKG) $(BZIP2) 2>&1" "tee -a $(SAGE_LOGS)/$(BZIP2).log"; \ 71 | - else \ 72 | - touch "$@"; \ 73 | - fi 74 | + $(PIPE) "$(SAGE_SPKG) $(BZIP2) 2>&1" "tee -a $(SAGE_LOGS)/$(BZIP2).log"; \ 75 | 76 | $(INST)/$(PATCH): $(INST)/$(BZIP2) 77 | +$(PIPE) "$(SAGE_SPKG) $(PATCH) 2>&1" "tee -a $(SAGE_LOGS)/$(PATCH).log" 78 | @@ -195,21 +190,15 @@ $(INST)/$(ICONV): 79 | $(INST)/$(DOCUTILS): $(INST)/$(PYTHON) 80 | +$(PIPE) "$(SAGE_SPKG) $(DOCUTILS) 2>&1" "tee -a $(SAGE_LOGS)/$(DOCUTILS).log" 81 | 82 | -# ELLIPTIC_CURVES depends on SAGE_ROOT_REPO because it needs SAGE_SHARE 83 | -# to be set in sage-env. 84 | -$(INST)/$(ELLIPTIC_CURVES): $(INST)/$(PYTHON) \ 85 | - $(INST)/$(SQLITE) $(INST)/$(SAGE_ROOT_REPO) 86 | +$(INST)/$(ELLIPTIC_CURVES): $(INST)/$(PYTHON) $(INST)/$(SQLITE) 87 | +$(PIPE) "$(SAGE_SPKG) $(ELLIPTIC_CURVES) 2>&1" "tee -a $(SAGE_LOGS)/$(ELLIPTIC_CURVES).log" 88 | 89 | -# CONWAY depends on SAGE_ROOT_REPO because it needs SAGE_SHARE 90 | -# to be set in sage-env. It also depends on SAGERUNTIME because it 91 | -# runs Sage code to generate a Sage object (.sobj). 92 | -$(INST)/$(CONWAY): $(INST)/$(SAGE_ROOT_REPO) $(SAGERUNTIME) 93 | +# CONWAY depends on depends on SAGERUNTIME because it runs Sage code to 94 | +# generate a Sage object (.sobj). 95 | +$(INST)/$(CONWAY): $(SAGERUNTIME) 96 | +$(PIPE) "$(SAGE_SPKG) $(CONWAY) 2>&1" "tee -a $(SAGE_LOGS)/$(CONWAY).log" 97 | 98 | -# GRAPHS depends on SAGE_ROOT_REPO because it needs SAGE_SHARE 99 | -# to be set in sage-env. 100 | -$(INST)/$(GRAPHS): $(INST)/$(SAGE_ROOT_REPO) 101 | +$(INST)/$(GRAPHS): 102 | +$(PIPE) "$(SAGE_SPKG) $(GRAPHS) 2>&1" "tee -a $(SAGE_LOGS)/$(GRAPHS).log" 103 | 104 | $(INST)/$(GLPK): $(INST)/$(MPIR) $(INST)/$(ZLIB) 105 | @@ -244,15 +233,10 @@ $(INST)/$(POLYBORI): $(INST)/$(PYTHON) $(INST)/$(IPYTHON) \ 106 | $(INST)/$(M4RI) $(INST)/$(GD) 107 | +$(PIPE) "$(SAGE_SPKG) $(POLYBORI) 2>&1" "tee -a $(SAGE_LOGS)/$(POLYBORI).log" 108 | 109 | -# POLYTOPES_DB depends on SAGE_ROOT_REPO because it needs SAGE_SHARE 110 | -# to be set in sage-env. 111 | -$(INST)/$(POLYTOPES_DB): $(INST)/$(SAGE_ROOT_REPO) 112 | +$(INST)/$(POLYTOPES_DB): 113 | +$(PIPE) "$(SAGE_SPKG) $(POLYTOPES_DB) 2>&1" "tee -a $(SAGE_LOGS)/$(POLYTOPES_DB).log" 114 | 115 | -# PPL depends on SAGE_ROOT_REPO because it *executes* C++ code at 116 | -# build time. Therefore, it needs an up-to-date version of sage-env 117 | -# which adds $SAGE_LOCAL/lib64 to the LD_LIBRARY_PATH. 118 | -$(INST)/$(PPL): $(INST)/$(MPIR) $(INST)/$(SAGE_ROOT_REPO) 119 | +$(INST)/$(PPL): $(INST)/$(MPIR) 120 | +$(PIPE) "$(SAGE_SPKG) $(PPL) 2>&1" "tee -a $(SAGE_LOGS)/$(PPL).log" 121 | 122 | $(INST)/$(MPC): $(INST)/$(MPIR) $(INST)/$(MPFR) 123 | @@ -376,11 +360,7 @@ $(INST)/$(MATPLOTLIB): $(INST)/$(PYTHON) $(INST)/$(NUMPY) \ 124 | $(INST)/$(CDDLIB): $(INST)/$(MPIR) 125 | +$(PIPE) "$(SAGE_SPKG) $(CDDLIB) 2>&1" "tee -a $(SAGE_LOGS)/$(CDDLIB).log" 126 | 127 | -# Gfan depends on SAGE_ROOT_REPO because it *executes* C++ code at 128 | -# build time. Therefore, it needs an up-to-date version of sage-env 129 | -# which adds $SAGE_LOCAL/lib64 to the LD_LIBRARY_PATH. 130 | -$(INST)/$(GFAN): $(INST)/$(MPIR) $(INST)/$(CDDLIB) \ 131 | - $(INST)/$(SAGE_ROOT_REPO) 132 | +$(INST)/$(GFAN): $(INST)/$(MPIR) $(INST)/$(CDDLIB) 133 | +$(PIPE) "$(SAGE_SPKG) $(GFAN) 2>&1" "tee -a $(SAGE_LOGS)/$(GFAN).log" 134 | 135 | $(INST)/$(TACHYON): $(INST)/$(LIBPNG) 136 | @@ -398,10 +378,7 @@ $(INST)/$(ECL): $(INST)/$(MPIR) $(INST)/$(READLINE) $(INST)/$(BOEHM_GC) 137 | $(INST)/$(MAXIMA): $(INST)/$(ECL) 138 | +$(PIPE) "$(SAGE_SPKG) $(MAXIMA) 2>&1" "tee -a $(SAGE_LOGS)/$(MAXIMA).log" 139 | 140 | -# R depends on SAGE_ROOT_REPO because it needs an up-to-date 141 | -# sage-env script which sets $OBJC on OS X. 142 | -$(INST)/$(R): $(INST)/$(ATLAS) $(INST)/$(ICONV) \ 143 | - $(INST)/$(SAGE_ROOT_REPO) $(INST)/$(READLINE) 144 | +$(INST)/$(R): $(INST)/$(ATLAS) $(INST)/$(ICONV) $(INST)/$(READLINE) 145 | +$(PIPE) "$(SAGE_SPKG) $(R) 2>&1" "tee -a $(SAGE_LOGS)/$(R).log" 146 | 147 | $(INST)/$(RPY): $(INST)/$(PYTHON) $(INST)/$(R) 148 | @@ -419,11 +396,6 @@ $(INST)/$(FLINTQS): $(INST)/$(MPIR) 149 | $(INST)/$(FLINT): $(INST)/$(MPIR) $(INST)/$(NTL) 150 | +$(PIPE) "$(SAGE_SPKG) $(FLINT) 2>&1" "tee -a $(SAGE_LOGS)/$(FLINT).log" 151 | 152 | -# EXTCODE depends on SAGE_ROOT_REPO because it needs SAGE_EXTCODE 153 | -# to be set in sage-env. 154 | -$(INST)/$(EXTCODE): $(INST)/$(SAGE_ROOT_REPO) 155 | - +$(PIPE) "$(SAGE_SPKG) $(EXTCODE) 2>&1" "tee -a $(SAGE_LOGS)/$(EXTCODE).log" 156 | - 157 | $(INST)/$(M4RI): $(INST)/$(LIBPNG) 158 | +$(PIPE) "$(SAGE_SPKG) $(M4RI) 2>&1" "tee -a $(SAGE_LOGS)/$(M4RI).log" 159 | 160 | @@ -435,11 +407,6 @@ $(INST)/$(M4RIE): $(INST)/$(M4RI) $(INST)/$(GIVARO) $(INST)/$(NTL) 161 | $(INST)/$(ZNPOLY): $(INST)/$(MPIR) $(INST)/$(PYTHON) 162 | +$(PIPE) "$(SAGE_SPKG) $(ZNPOLY) 2>&1" "tee -a $(SAGE_LOGS)/$(ZNPOLY).log" 163 | 164 | -# the spkg-install file for the root repo uses many 'hg' commands, so 165 | -# build mercurial first. 166 | -$(INST)/$(SAGE_ROOT_REPO): $(INST)/$(MERCURIAL) 167 | - +$(PIPE) "$(SAGE_SPKG) $(SAGE_ROOT_REPO) 2>&1" "tee -a $(SAGE_LOGS)/$(SAGE_ROOT_REPO).log" 168 | - 169 | $(INST)/$(SAGENB): $(INST)/$(PYTHON) $(INST)/$(SETUPTOOLS) $(INST)/$(PEXPECT) \ 170 | $(INST)/$(JINJA2) $(INST)/$(SPHINX) $(INST)/$(DOCUTILS) 171 | +$(PIPE) "$(SAGE_SPKG) $(SAGENB) 2>&1" "tee -a $(SAGE_LOGS)/$(SAGENB).log" 172 | @@ -460,9 +427,9 @@ $(INST)/$(PYGMENTS): $(INST)/$(PYTHON) $(INST)/$(SETUPTOOLS) 173 | 174 | # List all *build-time* dependencies of the Sage library. These are, 175 | # on the one hand, programs needed for the build/install process of the 176 | -# Sage library (e.g. SAGE_SCRIPTS, SCONS, MERCURIAL, JINJA2), and on the 177 | +# Sage library (e.g. JINJA2), and on the 178 | # other hand all dependencies for Cython files (e.g. PARI, NTL, MPIR). 179 | -$(INST)/$(SAGE): \ 180 | +sage: \ 181 | $(INST)/$(ATLAS) \ 182 | $(INST)/$(CEPHES) \ 183 | $(INST)/$(CLIQUER) \ 184 | @@ -498,19 +465,33 @@ $(INST)/$(SAGE): \ 185 | $(INST)/$(PYTHON) \ 186 | $(INST)/$(RATPOINTS) \ 187 | $(INST)/$(READLINE) \ 188 | - $(INST)/$(SAGE_SCRIPTS) \ 189 | - $(INST)/$(SCONS) \ 190 | $(INST)/$(SINGULAR) \ 191 | $(INST)/$(SYMMETRICA) \ 192 | - $(INST)/$(ZNPOLY) 193 | - +$(PIPE) "$(SAGE_SPKG) $(SAGE) 2>&1" "tee -a $(SAGE_LOGS)/$(SAGE).log" 194 | + $(INST)/$(ZNPOLY) \ 195 | + csage 196 | + +$(PIPE) "cd $(SAGE_SRC) && python setup.py install 2>&1" "tee -a $(SAGE_LOGS)/$(SAGE).log" 197 | + 198 | +# don't just use `install` since we don't want to change permissions 199 | +$(SAGE_LOCAL)/bin/%: $(SAGE_SRC)/__SAGE_SCRIPTS_REL__/% 200 | + cp $< $@ 201 | + 202 | +# don't just use `install -D` since we don't want to change permissions 203 | +$(SAGE_EXTCODE)/%: $(SAGE_SRC)/__SAGE_EXTREL__/% 204 | + @mkdir -p "$(@D)" 205 | + cp $< $@ 206 | + 207 | +SCRIPT_SOURCES = $(wildcard $(SAGE_SRC)/__SAGE_SCRIPTS_REL__/*) 208 | +SCRIPT_TARGETS = $(subst $(SAGE_SRC),$(SAGE_LOCAL),$(SCRIPT_SOURCES)) 209 | + 210 | +scripts: $(SCRIPT_TARGETS) 211 | + 212 | +EXTCODE_SOURCES = $(shell find $(SAGE_SRC)/__SAGE_EXTREL__ -type f) 213 | +EXTCODE_TARGETS = $(subst $(SAGE_SRC)/__SAGE_EXTREL__,$(SAGE_EXTCODE),$(EXTCODE_SOURCES)) 214 | + 215 | +extcode: $(EXTCODE_TARGETS) 216 | 217 | -# Because of ticket #11073 (remove the base repo), merged in sage-5.0, 218 | -# a version 5.x scripts repo does not work together with a version 4.x 219 | -# root repo. When upgrading, we must therefore install the new root 220 | -# repo before the scripts repo. 221 | -$(INST)/$(SAGE_SCRIPTS): $(INST)/$(SAGE_ROOT_REPO) 222 | - +$(PIPE) "$(SAGE_SPKG) $(SAGE_SCRIPTS) 2>&1" "tee -a $(SAGE_LOGS)/$(SAGE_SCRIPTS).log" 223 | +csage: $(INST)/$(SCONS) $(INST)/$(MPIR) $(INST)/$(PARI) 224 | + +$(PIPE) "cd $(SAGE_SRC)/c_lib && scons -Q install 2>&1" "tee -a $(SAGE_LOGS)/csage.log" 225 | 226 | $(INST)/ccache: $(BASE) $(INST)/$(ZLIB) 227 | +$(PIPE) "$(SAGE_SPKG) ccache 2>&1" "tee -a $(SAGE_LOGS)/ccache.log" 228 | @@ -523,10 +504,7 @@ $(INST)/$(GCC): $(INST)/$(MPIR) $(INST)/$(MPFR) $(INST)/$(MPC) \ 229 | $(INST)/$(PIL): $(INST)/$(PYTHON) 230 | +$(PIPE) "$(SAGE_SPKG) $(PIL) 2>&1" "tee -a $(SAGE_LOGS)/$(PIL).log" 231 | 232 | -# Lapack depends on SAGE_ROOT_REPO because it *executes* Fortran code at 233 | -# build time. Therefore, it needs an up-to-date version of sage-env 234 | -# which adds $SAGE_LOCAL/lib64 to the LD_LIBRARY_PATH. 235 | -$(INST)/$(LAPACK): $(INST)/$(SAGE_ROOT_REPO) 236 | +$(INST)/$(LAPACK): 237 | +$(PIPE) "$(SAGE_SPKG) $(LAPACK) 2>&1" "tee -a $(SAGE_LOGS)/$(LAPACK).log" 238 | 239 | $(INST)/$(BLAS): 240 | -- 241 | 1.8.1.5 242 | 243 | -------------------------------------------------------------------------------- /consolidate-repos.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # consolidate-repos.sh 4 | # 5 | # Requires git, hg, and hg-git, as well as a copy of Sage. hg-git must 6 | # contain revision e58a6d0b80e2, to avoid getting corrupt git repos. 7 | # As of 2012-03-19 this means it needs to be directly pulled from the 8 | # repo at http://bitbucket.org/durin42/hg-git/ . 9 | # 10 | # If GNU parallel is present, certain operations will be parallelized. 11 | # If notify-send is present, the script will send notifications that 12 | # certain long segments of the operation have been completed. 13 | # 14 | # Usage: 15 | # 16 | # consolidate-repos.sh -i sagedir -o outdir -t tmpdir 17 | # 18 | # Output: 19 | # 20 | # - A consolidated repo in outdir 21 | # - tarballs for the source files in outdir/$SAGE_TARBALLS/ 22 | 23 | . ${0%consolidate-repos.sh}configuration.sh 24 | 25 | CMD="${0##*/}" 26 | 27 | die () { 28 | echo $@ 1>&2 29 | exit 1 30 | } 31 | 32 | usage () { 33 | echo "usage: $CMD -i sagedir -o outdir -t tmpdir" 34 | } 35 | 36 | # parse command line options 37 | while getopts "i:o:t:" opt ; do 38 | case $opt in 39 | i) SAGEDIR=$(readlink -f "$OPTARG") ;; 40 | o) OUTDIR=$(readlink -f "$OPTARG") ;; 41 | t) TMPDIR=$(readlink -f "$OPTARG") ;; 42 | esac 43 | done 44 | shift $((OPTIND-1)) 45 | 46 | # read options if not explicitly specified 47 | if [ -z "$SAGEDIR" ]; then 48 | [ -d "$1" ] || die $(usage) 49 | SAGEDIR="$1" 50 | shift 51 | fi 52 | if [ -z "$OUTDIR" ]; then 53 | [ -d "$1" ] || die $(usage) 54 | OUTDIR="$1" 55 | shift 56 | fi 57 | [ -z "$TMPDIR" ] && TMPDIR="$(mktemp -d /tmp/consolidate-repos.XXXX)" && 58 | MADETMP=yes && echo "Created directory $TMPDIR" 59 | 60 | export SAGEDIR OUTDIR TMPDIR 61 | 62 | mkdir -p "$TMPDIR" && cd "$TMPDIR" && rm -rf * 63 | 64 | # initialize output repo 65 | git init "$TMPDIR"/sage-repo && cd "$TMPDIR"/sage-repo 66 | 67 | # move the base tarballs into $SAGE_TARBALLS 68 | rm -rf "$OUTDIR" 69 | mkdir -p "$OUTDIR"/$SAGE_TARBALLS 70 | mkdir -p "$TMPDIR"/spkg 71 | cp "$SAGEDIR"/spkg/base/*.tar* "$OUTDIR"/$SAGE_TARBALLS 72 | 73 | # get the SPKG repos converted to git and pull them into the consolidated repo 74 | # also tarball the src/ directories of the SPKGs and put them into a $SAGE_TARBALLS/ directory 75 | mkdir -p "$TMPDIR"/spkg-git 76 | 77 | process-spkg () { 78 | # figure out what the spkg is 79 | SPKGPATH=$1 80 | SPKG="${SPKGPATH#$SAGEDIR/spkg/*/}" 81 | SPKG="${SPKG%.spkg}" 82 | PKGNAME=$(sed -e 's/\([^-_]*\)[-_][0-9].*$/\1/' <<< "$SPKG") 83 | PKGVER=$(sed -e 's/^[-_]\+\(.*\)$/\1/' -e 's/[-_]/\./g' <<< "${SPKG#"$PKGNAME"}") 84 | PKGVER_UPSTREAM=$(sed -e 's/\.p[0-9][0-9]*$//' <<<"$PKGVER") 85 | echo 86 | echo "*** Found SPKG: $PKGNAME version $PKGVER" 87 | tar x -p -C "$TMPDIR"/spkg -f "$SPKGPATH" 88 | 89 | # determine eventual subtree of the spkg's repo 90 | # tarball the src/ directory and put it into our $SAGE_TARBALLS/ directory 91 | # apply any WIP mecurial patches 92 | pushd "$TMPDIR"/spkg/$SPKG > /dev/null 93 | if [ ! -d .hg ]; then 94 | popd > /dev/null 95 | rm -rf "$TMPDIR"/spkg/$SPKG 96 | echo "${SPKGPATH#$SAGEDIR/spkg/}" >> "$OUTDIR"/failed-spkgs.txt 97 | return 0 98 | fi 99 | 100 | TAGS_SWITCH='' 101 | case $PKGNAME in 102 | sage_root) 103 | REPO=. 104 | BRANCH=base 105 | ;; 106 | sage) 107 | REPO=$SAGE_SRC 108 | BRANCH=library 109 | TAGS_SWITCH='--tag-name-filter cat' 110 | ;; 111 | sage_scripts) 112 | REPO=$SAGE_SCRIPTS_DIR 113 | BRANCH=devel/bin 114 | ;; 115 | extcode) 116 | REPO=$SAGE_EXTDIR 117 | BRANCH=devel/ext 118 | ;; 119 | *) 120 | REPO=$SAGE_PKGS/$PKGNAME 121 | BRANCH=packages/$PKGNAME 122 | 123 | if tar --test-label < "$SPKGPATH" 2>/dev/null; then 124 | TAROPTS= 125 | TAREXT=.tar 126 | elif gzip -t "$SPKGPATH" 2>/dev/null; then 127 | TAROPTS=z 128 | TAREXT=.tar.gz 129 | else # assume everything else is bzip2 130 | TAROPTS=j 131 | TAREXT=.tar.bz2 132 | fi 133 | mv -T "$TMPDIR"/spkg/$SPKG/src "$TMPDIR"/spkg/$SPKG/$PKGNAME-$PKGVER_UPSTREAM 134 | tar c -${TAROPTS}f "$OUTDIR"/$SAGE_TARBALLS/$PKGNAME-${PKGVER_UPSTREAM}${TAREXT} -C "$TMPDIR"/spkg/$SPKG/ $PKGNAME-$PKGVER_UPSTREAM 135 | rm -rf "$TMPDIR"/spkg/$SPKG/$PKGNAME-$PKGVER_UPSTREAM 136 | ;; 137 | esac 138 | popd > /dev/null 139 | 140 | # convert the SPKG's hg repo to git 141 | git init --bare "$TMPDIR"/spkg-git/$PKGNAME 142 | pushd "$TMPDIR"/spkg-git/$PKGNAME > /dev/null 143 | $WORKFLOW_DIR/fast-export/hg-fast-export.sh -r "$TMPDIR"/spkg/$SPKG -M master 144 | rm -rf "$TMPDIR"/spkg/$SPKG 145 | 146 | # rewrite paths 147 | # hacked into git-filter-branch so that we can use a bash array across 148 | # commits (bash does not support exporting arrays) 149 | export REPO SAGE_BUILD SAGE_MACAPP SAGE_SCRIPTS_DIR SAGE_EXTDIR 150 | $WORKFLOW_DIR/git-filter-branch -f -d "$TMPDIR/filter-branch/$SPKG" --prune-empty --index-filter '' $TAGS_SWITCH master 151 | popd > /dev/null 152 | 153 | if [ -n "$TAGS_SWITCH" ]; then 154 | TAGS_SWITCH='' 155 | else 156 | TAGS_SWITCH='-n' 157 | fi 158 | # pull it into the consolidated repo 159 | git fetch $TAGS_SWITCH "$TMPDIR"/spkg-git/$PKGNAME master:$BRANCH && 160 | rm -rf "$TMPDIR"/spkg-git/$PKGNAME 161 | 162 | # save the package version for later 163 | mkdir -p "$TMPDIR"/spkg-git/$PKGNAME 164 | echo "$PKGVER" > "$TMPDIR"/spkg-git/$PKGNAME/spkg-version.txt 165 | } 166 | export -f process-spkg 167 | 168 | for SPKGPATH in "$SAGEDIR"/spkg/*/*.spkg ; do 169 | process-spkg "$SPKGPATH" 170 | done 171 | 172 | if [[ $(command -v notify-send) ]] ; then 173 | notify-send "$CMD: finished parsing SPKGs" 174 | fi 175 | 176 | # Humongous octomerge 177 | # Put together a directory listing for the repo to commit in the merge 178 | BRANCHES=$(git branch | sed 's+^\**\s*++') 179 | DEVOBJS="" 180 | PKGOBJS="" 181 | # Collect directory entries from the various branches 182 | for BRANCH in $BRANCHES ; do 183 | case "$BRANCH" in 184 | base) 185 | # Skip for now, we will merge this with the other 186 | # trees later 187 | ;; 188 | devel/*) 189 | # We incrementally build a list of stuff in $SAGE_SRC/ ; 190 | # this $BRANCH will give us one of the subdirs' tree 191 | # objects. This will happen twice, once for devel/bin 192 | # and once for devel/ext. 193 | case "$BRANCH" in 194 | devel/ext) BRANCH_DIR="$SAGE_EXTDIR $SAGE_MACAPP" ;; 195 | devel/bin) BRANCH_DIR=$SAGE_SCRIPTS_DIR ;; 196 | esac 197 | DEV_ENTRY=$(git ls-tree -d $BRANCH $BRANCH_DIR) 198 | DEV_ENTRY=$(sed "s+$SAGE_SRC/++" <<<"$DEV_ENTRY") 199 | DEVOBJS="${DEVOBJS}${DEV_ENTRY}\n" 200 | ;; 201 | library) 202 | # We incrementally build a list of stuff in $SAGE_SRC/ ; 203 | # this $BRANCH will give us the rest of the entries in 204 | # $SAGE_SRC/ . 205 | DEV_ENTRIES=$(git ls-tree $BRANCH $SAGE_SRC/) 206 | DEV_ENTRIES=$(sed "s+$SAGE_SRC/++" <<<"$DEV_ENTRIES") 207 | DEVOBJS="${DEVOBJS}${DEV_ENTRIES}\n" 208 | ;; 209 | packages/*) 210 | # We incrementally build a list of stuff in $SAGE_PKGS/ 211 | # ; this $BRANCH will give us one of the subdirs' tree 212 | # objects. This will happen many many times. 213 | BRANCH_DIR=$SAGE_PKGS${BRANCH#packages} 214 | PKG_ENTRY=$(git ls-tree -d $BRANCH $BRANCH_DIR) 215 | PKG_ENTRY=$(sed "s+$SAGE_PKGS/++" <<<"$PKG_ENTRY") 216 | PKGOBJS="${PKGOBJS}${PKG_ENTRY}\n" 217 | ;; 218 | *) 219 | # WTF? 220 | die "Something bizarre happened; branch name $BRANCH shouldn't exist!" 221 | esac 222 | done 223 | 224 | # Produce new directory listing objects for $SAGE_PKGS/ and $SAGE_SRC/ 225 | # from the information gathered above, then dump those objects 226 | # into the listing of the root directory which we are building on 227 | # stdout. --batch is used because there's an extra newline at the 228 | # end of $DEVOBJS and $PKGOBJS. 229 | flatten-tree () { 230 | TREE="$1" 231 | TREE_DIR="$2" 232 | while true 233 | do 234 | TREE=$(echo -e "040000 tree $TREE\t${TREE_DIR##*/}" | git mktree --missing) 235 | if [[ "${TREE_DIR}" != *"/"* ]]; then 236 | echo -n "$TREE" 237 | return 0 238 | fi 239 | TREE_DIR="${TREE_DIR%/*}" 240 | done 241 | } 242 | export -f flatten-tree 243 | 244 | get-object () { 245 | git ls-tree $1 $2 | cut -f3 -d' ' | cut -f1 246 | } 247 | export -f get-object 248 | 249 | merge-tree () { 250 | local TREE_ONE=$1 251 | local TREE_TWO=$2 252 | local LS_ONE LS_TWO LS_NEW ITEM 253 | LS_ONE="$(git ls-tree --name-only $TREE_ONE)" 254 | LS_TWO="$(git ls-tree --name-only $TREE_TWO)" 255 | LS_NEW="$(printf '%s\n%s\n' "$LS_ONE" "$LS_TWO"| sort -u)" 256 | 257 | # all duplicates are assumed to be trees 258 | for ITEM in $LS_NEW; do 259 | if echo "$LS_ONE" | egrep "^$ITEM$" >/dev/null; then 260 | if echo "$LS_TWO" | egrep "^$ITEM$" >/dev/null; then 261 | echo -e "040000 tree $(merge-tree $(get-object $TREE_ONE "$ITEM") $(get-object $TREE_TWO "$ITEM"))\t$ITEM" 262 | else 263 | git ls-tree $TREE_ONE "$ITEM" 264 | fi 265 | else 266 | git ls-tree $TREE_TWO "$ITEM" 267 | fi 268 | done | git mktree --missing 269 | } 270 | export -f merge-tree 271 | 272 | DEVTREE=$(echo -e "$DEVOBJS" | git mktree --missing --batch) 273 | PKGTREE=$(echo -e "$PKGOBJS" | git mktree --missing --batch) 274 | DEVTREE=$(flatten-tree $DEVTREE "$SAGE_SRC") 275 | PKGTREE=$(flatten-tree $PKGTREE "$SAGE_PKGS") 276 | 277 | MERGETREE=$(merge-tree base $DEVTREE) 278 | MERGETREE=$(merge-tree $MERGETREE $PKGTREE) 279 | 280 | # Commit the new fully consolidated file tree 281 | MERGECOMMIT=$( 282 | { 283 | for BRANCH in $BRANCHES ; do 284 | echo '-p '$(git show-ref -s --heads $BRANCH) 285 | done 286 | } | xargs git commit-tree $MERGETREE -m "Consolidate Sage's Repositories" 287 | ) 288 | # Set up a new master branch and delete the other branches, and we're 289 | # done! 290 | git checkout -b master $MERGECOMMIT 291 | for BRANCH in $BRANCHES ; do 292 | git branch -d $BRANCH || die "The octomerge failed; $BRANCH is still unmerged!" 293 | done 294 | 295 | git checkout -b build_system 296 | # Commit package-version.txt files to track package \.p[0-9]+ versions 297 | # (i.e. local revisions) 298 | for BRANCH in $BRANCHES ; do 299 | case $BRANCH in 300 | packages/*) 301 | PKGNAME=${BRANCH#packages/} 302 | mv "$TMPDIR"/spkg-git/$PKGNAME/spkg-version.txt -T $SAGE_PKGS/$PKGNAME/package-version.txt 303 | git add $SAGE_PKGS/$PKGNAME/package-version.txt 304 | ;; 305 | esac 306 | done 307 | git commit -m "[CLEANUP] Add package-version.txt files" 308 | 309 | # Optimize the repo 310 | git gc --aggressive --prune=0 311 | 312 | # Move the consolidated repo into place, and check out the package 313 | # installation scripts so that Sage can start building 314 | mv "$TMPDIR"/sage-repo/.git "$OUTDIR" 315 | cd "$OUTDIR" 316 | git checkout build_system . 317 | 318 | # Clean up $TMPDIR 319 | [[ -z $MADETMP ]] || rm -rf "$TMPDIR" 320 | -------------------------------------------------------------------------------- /fast-export/hg-fast-export.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # Copyright (c) 2007, 2008 Rocco Rutte and others. 4 | # License: MIT 5 | 6 | from mercurial import node 7 | from hg2git import setup_repo,fixup_user,get_branch,get_changeset 8 | from hg2git import load_cache,save_cache,get_git_sha1,set_default_branch,set_origin_name 9 | from optparse import OptionParser 10 | import re 11 | import sys 12 | import os 13 | 14 | if sys.platform == "win32": 15 | # On Windows, sys.stdout is initially opened in text mode, which means that 16 | # when a LF (\n) character is written to sys.stdout, it will be converted 17 | # into CRLF (\r\n). That makes git blow up, so use this platform-specific 18 | # code to change the mode of sys.stdout to binary. 19 | import msvcrt 20 | msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) 21 | 22 | # silly regex to catch Signed-off-by lines in log message 23 | sob_re=re.compile('^Signed-[Oo]ff-[Bb]y: (.+)$') 24 | # insert 'checkpoint' command after this many commits or none at all if 0 25 | cfg_checkpoint_count=0 26 | # write some progress message every this many file contents written 27 | cfg_export_boundary=1000 28 | 29 | def gitmode(flags): 30 | return 'l' in flags and '120000' or 'x' in flags and '100755' or '100644' 31 | 32 | def wr(msg=''): 33 | if msg: 34 | sys.stdout.write(msg) 35 | sys.stdout.write('\n') 36 | #map(lambda x: sys.stderr.write('\t[%s]\n' % x),msg.split('\n')) 37 | 38 | def checkpoint(count): 39 | count=count+1 40 | if cfg_checkpoint_count>0 and count%cfg_checkpoint_count==0: 41 | sys.stderr.write("Checkpoint after %d commits\n" % count) 42 | wr('checkpoint') 43 | wr() 44 | return count 45 | 46 | def revnum_to_revref(rev, old_marks): 47 | """Convert an hg revnum to a git-fast-import rev reference (an SHA1 48 | or a mark)""" 49 | return old_marks.get(rev) or ':%d' % (rev+1) 50 | 51 | def file_mismatch(f1,f2): 52 | """See if two revisions of a file are not equal.""" 53 | return node.hex(f1)!=node.hex(f2) 54 | 55 | def split_dict(dleft,dright,l=[],c=[],r=[],match=file_mismatch): 56 | """Loop over our repository and find all changed and missing files.""" 57 | for left in dleft.keys(): 58 | right=dright.get(left,None) 59 | if right==None: 60 | # we have the file but our parent hasn't: add to left set 61 | l.append(left) 62 | elif match(dleft[left],right): 63 | # we have it but checksums mismatch: add to center set 64 | c.append(left) 65 | for right in dright.keys(): 66 | left=dleft.get(right,None) 67 | if left==None: 68 | # if parent has file but we don't: add to right set 69 | r.append(right) 70 | # change is already handled when comparing child against parent 71 | return l,c,r 72 | 73 | def get_filechanges(repo,revision,parents,mleft): 74 | """Given some repository and revision, find all changed/deleted files.""" 75 | l,c,r=[],[],[] 76 | for p in parents: 77 | if p<0: continue 78 | mright=repo.changectx(p).manifest() 79 | l,c,r=split_dict(mleft,mright,l,c,r) 80 | l.sort() 81 | c.sort() 82 | r.sort() 83 | return l,c,r 84 | 85 | def get_author(logmessage,committer,authors): 86 | """As git distincts between author and committer of a patch, try to 87 | extract author by detecting Signed-off-by lines. 88 | 89 | This walks from the end of the log message towards the top skipping 90 | empty lines. Upon the first non-empty line, it walks all Signed-off-by 91 | lines upwards to find the first one. For that (if found), it extracts 92 | authorship information the usual way (authors table, cleaning, etc.) 93 | 94 | If no Signed-off-by line is found, this defaults to the committer. 95 | 96 | This may sound stupid (and it somehow is), but in log messages we 97 | accidentially may have lines in the middle starting with 98 | "Signed-off-by: foo" and thus matching our detection regex. Prevent 99 | that.""" 100 | 101 | loglines=logmessage.split('\n') 102 | i=len(loglines) 103 | # from tail walk to top skipping empty lines 104 | while i>=0: 105 | i-=1 106 | if len(loglines[i].strip())==0: continue 107 | break 108 | if i>=0: 109 | # walk further upwards to find first sob line, store in 'first' 110 | first=None 111 | while i>=0: 112 | m=sob_re.match(loglines[i]) 113 | if m==None: break 114 | first=m 115 | i-=1 116 | # if the last non-empty line matches our Signed-Off-by regex: extract username 117 | if first!=None: 118 | r=fixup_user(first.group(1),authors) 119 | if r.find('>') < r.find('<'): 120 | return "Invalid User " 121 | return r 122 | if committer.find('>') < committer.find('<'): 123 | return "Invalid User " 124 | return committer 125 | 126 | def export_file_contents(ctx,manifest,files): 127 | count=0 128 | max=len(files) 129 | for file in files: 130 | # Skip .hgtags files. They only get us in trouble. 131 | if file == ".hgtags": 132 | sys.stderr.write('Skip %s\n' % (file)) 133 | continue 134 | d=ctx.filectx(file).data() 135 | wr('M %s inline %s' % (gitmode(manifest.flags(file)),file)) 136 | wr('data %d' % len(d)) # had some trouble with size() 137 | wr(d) 138 | count+=1 139 | if count%cfg_export_boundary==0: 140 | sys.stderr.write('Exported %d/%d files\n' % (count,max)) 141 | if max>cfg_export_boundary: 142 | sys.stderr.write('Exported %d/%d files\n' % (count,max)) 143 | 144 | def sanitize_name(name,what="branch"): 145 | """Sanitize input roughly according to git-check-ref-format(1)""" 146 | 147 | def dot(name): 148 | if name[0] == '.': return '_'+name[1:] 149 | return name 150 | 151 | n=name 152 | p=re.compile('([[ ~^:?*]|\.\.)') 153 | n=p.sub('_', n) 154 | if n[-1] in ('/', '.'): n=n[:-1]+'_' 155 | n='/'.join(map(dot,n.split('/'))) 156 | p=re.compile('_+') 157 | n=p.sub('_', n) 158 | 159 | if n!=name: 160 | sys.stderr.write('Warning: sanitized %s [%s] to [%s]\n' % (what,name,n)) 161 | return n 162 | 163 | def export_commit(ui,repo,revision,old_marks,max,count,authors,sob,brmap): 164 | def get_branchname(name): 165 | if brmap.has_key(name): 166 | return brmap[name] 167 | n=sanitize_name(name) 168 | brmap[name]=n 169 | return n 170 | 171 | (revnode,_,user,(time,timezone),files,desc,branch,_)=get_changeset(ui,repo,revision,authors) 172 | if user.find("")!=-1: 173 | user = "Evil Email " 174 | 175 | branch=get_branchname(branch) 176 | 177 | parents = [p for p in repo.changelog.parentrevs(revision) if p >= 0] 178 | 179 | if len(parents)==0 and revision != 0: 180 | wr('reset refs/heads/%s' % branch) 181 | 182 | wr('commit refs/heads/%s' % branch) 183 | wr('mark :%d' % (revision+1)) 184 | if sob: 185 | wr('author %s %d %s' % (get_author(desc,user,authors),time,timezone)) 186 | wr('committer %s %d %s' % (user,time,timezone)) 187 | wr('data %d' % (len(desc)+1)) # wtf? 188 | wr(desc) 189 | wr() 190 | 191 | 192 | # Sort the parents based on revision ids so that we always get the 193 | # same resulting git repo, no matter how the revisions were 194 | # numbered. 195 | parents.sort(key=repo.changelog.node, reverse=True) 196 | 197 | ctx=repo.changectx(str(revision)) 198 | man=ctx.manifest() 199 | added,changed,removed,type=[],[],[],'' 200 | 201 | if len(parents) == 0: 202 | # first revision: feed in full manifest 203 | added=man.keys() 204 | added.sort() 205 | type='full' 206 | else: 207 | wr('from %s' % revnum_to_revref(parents[0], old_marks)) 208 | if len(parents) == 1: 209 | # later non-merge revision: feed in changed manifest 210 | # if we have exactly one parent, just take the changes from the 211 | # manifest without expensively comparing checksums 212 | f=repo.status(repo.lookup(parents[0]),revnode)[:3] 213 | added,changed,removed=f[1],f[0],f[2] 214 | type='simple delta' 215 | else: # a merge with two parents 216 | wr('merge %s' % revnum_to_revref(parents[1], old_marks)) 217 | # later merge revision: feed in changed manifest 218 | # for many files comparing checksums is expensive so only do it for 219 | # merges where we really need it due to hg's revlog logic 220 | added,changed,removed=get_filechanges(repo,revision,parents,man) 221 | type='thorough delta' 222 | 223 | sys.stderr.write('%s: Exporting %s revision %d/%d with %d/%d/%d added/changed/removed files\n' % 224 | (branch,type,revision+1,max,len(added),len(changed),len(removed))) 225 | 226 | map(lambda r: wr('D %s' % r),removed) 227 | export_file_contents(ctx,man,added) 228 | export_file_contents(ctx,man,changed) 229 | wr() 230 | 231 | return checkpoint(count) 232 | 233 | def export_tags(ui,repo,old_marks,mapping_cache,count,authors): 234 | l=repo.tagslist() 235 | for tag,node in l: 236 | tag=sanitize_name(tag,"tag") 237 | # ignore latest revision 238 | if tag=='tip': continue 239 | # ignore tags to nodes that are missing (ie, 'in the future') 240 | if node.encode('hex_codec') not in mapping_cache: 241 | sys.stderr.write('Tag %s refers to unseen node %s\n' % (tag, node.encode('hex_codec'))) 242 | continue 243 | 244 | rev=int(mapping_cache[node.encode('hex_codec')]) 245 | 246 | ref=revnum_to_revref(rev, old_marks) 247 | if ref==None: 248 | sys.stderr.write('Failed to find reference for creating tag' 249 | ' %s at r%d\n' % (tag,rev)) 250 | continue 251 | sys.stderr.write('Exporting tag [%s] at [hg r%d] [git %s]\n' % (tag,rev,ref)) 252 | wr('reset refs/tags/%s' % tag) 253 | wr('from %s' % ref) 254 | wr() 255 | count=checkpoint(count) 256 | return count 257 | 258 | def load_authors(filename): 259 | cache={} 260 | if not os.path.exists(filename): 261 | return cache 262 | f=open(filename,'r') 263 | l=0 264 | lre=re.compile('^([^=]+)[ ]*=[ ]*(.+)$') 265 | for line in f.readlines(): 266 | l+=1 267 | m=lre.match(line) 268 | if m==None: 269 | sys.stderr.write('Invalid file format in [%s], line %d\n' % (filename,l)) 270 | continue 271 | # put key:value in cache, key without ^: 272 | cache[m.group(1).strip()]=m.group(2).strip() 273 | f.close() 274 | sys.stderr.write('Loaded %d authors\n' % l) 275 | return cache 276 | 277 | def verify_heads(ui,repo,cache,force): 278 | branches=repo.branchtags() 279 | l=[(-repo.changelog.rev(n), n, t) for t, n in branches.items()] 280 | l.sort() 281 | 282 | # get list of hg's branches to verify, don't take all git has 283 | for _,_,b in l: 284 | b=get_branch(b) 285 | sha1=get_git_sha1(b) 286 | c=cache.get(b) 287 | if sha1!=c: 288 | sys.stderr.write('Error: Branch [%s] modified outside hg-fast-export:' 289 | '\n%s (repo) != %s (cache)\n' % (b,sha1,c)) 290 | if not force: return False 291 | 292 | # verify that branch has exactly one head 293 | t={} 294 | for h in repo.heads(): 295 | (_,_,_,_,_,_,branch,_)=get_changeset(ui,repo,h) 296 | if t.get(branch,False): 297 | sys.stderr.write('Error: repository has at least one unnamed head: hg r%s\n' % 298 | repo.changelog.rev(h)) 299 | if not force: return False 300 | t[branch]=True 301 | 302 | return True 303 | 304 | def hg2git(repourl,m,marksfile,mappingfile,headsfile,tipfile,authors={},sob=False,force=False): 305 | _max=int(m) 306 | 307 | old_marks=load_cache(marksfile,lambda s: int(s)-1) 308 | mapping_cache=load_cache(mappingfile) 309 | heads_cache=load_cache(headsfile) 310 | state_cache=load_cache(tipfile) 311 | 312 | ui,repo=setup_repo(repourl) 313 | 314 | if not verify_heads(ui,repo,heads_cache,force): 315 | return 1 316 | 317 | try: 318 | tip=repo.changelog.count() 319 | except AttributeError: 320 | tip=len(repo) 321 | 322 | min=int(state_cache.get('tip',0)) 323 | max=_max 324 | if _max<0 or max>tip: 325 | max=tip 326 | 327 | for rev in range(0,max): 328 | (revnode,_,_,_,_,_,_,_)=get_changeset(ui,repo,rev,authors) 329 | mapping_cache[revnode.encode('hex_codec')] = str(rev) 330 | 331 | 332 | c=0 333 | brmap={} 334 | for rev in range(min,max): 335 | c=export_commit(ui,repo,rev,old_marks,max,c,authors,sob,brmap) 336 | 337 | state_cache['tip']=max 338 | state_cache['repo']=repourl 339 | save_cache(tipfile,state_cache) 340 | save_cache(mappingfile,mapping_cache) 341 | 342 | c=export_tags(ui,repo,old_marks,mapping_cache,c,authors) 343 | 344 | sys.stderr.write('Issued %d commands\n' % c) 345 | 346 | return 0 347 | 348 | if __name__=='__main__': 349 | def bail(parser,opt): 350 | sys.stderr.write('Error: No %s option given\n' % opt) 351 | parser.print_help() 352 | sys.exit(2) 353 | 354 | parser=OptionParser() 355 | 356 | parser.add_option("-m","--max",type="int",dest="max", 357 | help="Maximum hg revision to import") 358 | parser.add_option("--mapping",dest="mappingfile", 359 | help="File to read last run's hg-to-git SHA1 mapping") 360 | parser.add_option("--marks",dest="marksfile", 361 | help="File to read git-fast-import's marks from") 362 | parser.add_option("--heads",dest="headsfile", 363 | help="File to read last run's git heads from") 364 | parser.add_option("--status",dest="statusfile", 365 | help="File to read status from") 366 | parser.add_option("-r","--repo",dest="repourl", 367 | help="URL of repo to import") 368 | parser.add_option("-s",action="store_true",dest="sob", 369 | default=False,help="Enable parsing Signed-off-by lines") 370 | parser.add_option("-A","--authors",dest="authorfile", 371 | help="Read authormap from AUTHORFILE") 372 | parser.add_option("-f","--force",action="store_true",dest="force", 373 | default=False,help="Ignore validation errors by force") 374 | parser.add_option("-M","--default-branch",dest="default_branch", 375 | help="Set the default branch") 376 | parser.add_option("-o","--origin",dest="origin_name", 377 | help="use as namespace to track upstream") 378 | 379 | (options,args)=parser.parse_args() 380 | 381 | m=-1 382 | if options.max!=None: m=options.max 383 | 384 | if options.marksfile==None: bail(parser,'--marks') 385 | if options.mappingfile==None: bail(parser,'--mapping') 386 | if options.headsfile==None: bail(parser,'--heads') 387 | if options.statusfile==None: bail(parser,'--status') 388 | if options.repourl==None: bail(parser,'--repo') 389 | 390 | a={} 391 | if options.authorfile!=None: 392 | a=load_authors(options.authorfile) 393 | 394 | if options.default_branch!=None: 395 | set_default_branch(options.default_branch) 396 | 397 | if options.origin_name!=None: 398 | set_origin_name(options.origin_name) 399 | 400 | sys.exit(hg2git(options.repourl,m,options.marksfile,options.mappingfile,options.headsfile, 401 | options.statusfile,authors=a,sob=options.sob,force=options.force)) 402 | -------------------------------------------------------------------------------- /git-filter-branch: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Rewrite revision history 4 | # Copyright (c) Petr Baudis, 2006 5 | # Minimal changes to "port" it to core-git (c) Johannes Schindelin, 2007 6 | # 7 | # Lets you rewrite the revision history of the current branch, creating 8 | # a new branch. You can specify a number of filters to modify the commits, 9 | # files and trees. 10 | 11 | # The following functions will also be available in the commit filter: 12 | 13 | functions=$(cat << \EOF 14 | warn () { 15 | echo "$*" >&2 16 | } 17 | 18 | map() 19 | { 20 | # if it was not rewritten, take the original 21 | if test -r "$workdir/../map/$1" 22 | then 23 | cat "$workdir/../map/$1" 24 | else 25 | echo "$1" 26 | fi 27 | } 28 | 29 | # if you run 'skip_commit "$@"' in a commit filter, it will print 30 | # the (mapped) parents, effectively skipping the commit. 31 | 32 | skip_commit() 33 | { 34 | shift; 35 | while [ -n "$1" ]; 36 | do 37 | shift; 38 | map "$1"; 39 | shift; 40 | done; 41 | } 42 | 43 | # if you run 'git_commit_non_empty_tree "$@"' in a commit filter, 44 | # it will skip commits that leave the tree untouched, commit the other. 45 | git_commit_non_empty_tree() 46 | { 47 | if test $# = 3 && test "$1" = $(git rev-parse "$3^{tree}"); then 48 | map "$3" 49 | else 50 | git commit-tree "$@" 51 | fi 52 | } 53 | # override die(): this version puts in an extra line break, so that 54 | # the progress is still visible 55 | 56 | die() 57 | { 58 | echo >&2 59 | echo "$*" >&2 60 | exit 1 61 | } 62 | EOF 63 | ) 64 | 65 | eval "$functions" 66 | 67 | finish_ident() { 68 | # Ensure non-empty id name. 69 | echo "case \"\$GIT_$1_NAME\" in \"\") GIT_$1_NAME=\"\${GIT_$1_EMAIL%%@*}\" && export GIT_$1_NAME;; esac" 70 | # And make sure everything is exported. 71 | echo "export GIT_$1_NAME" 72 | echo "export GIT_$1_EMAIL" 73 | echo "export GIT_$1_DATE" 74 | } 75 | 76 | set_ident () { 77 | parse_ident_from_commit author AUTHOR committer COMMITTER 78 | finish_ident AUTHOR 79 | finish_ident COMMITTER 80 | } 81 | 82 | USAGE="[--env-filter ] [--tree-filter ] 83 | [--index-filter ] [--parent-filter ] 84 | [--msg-filter ] [--commit-filter ] 85 | [--tag-name-filter ] [--subdirectory-filter ] 86 | [--original ] [-d ] [-f | --force] 87 | [...]" 88 | 89 | OPTIONS_SPEC= 90 | . $(git --exec-path)/git-sh-setup 91 | 92 | if [ "$(is_bare_repository)" = false ]; then 93 | require_clean_work_tree 'rewrite branches' 94 | fi 95 | 96 | tempdir=.git-rewrite 97 | filter_env= 98 | filter_tree= 99 | filter_index= 100 | filter_parent= 101 | filter_msg=cat 102 | filter_commit= 103 | filter_tag_name= 104 | filter_subdir= 105 | orig_namespace=refs/original/ 106 | force= 107 | prune_empty= 108 | remap_to_ancestor= 109 | while : 110 | do 111 | case "$1" in 112 | --) 113 | shift 114 | break 115 | ;; 116 | --force|-f) 117 | shift 118 | force=t 119 | continue 120 | ;; 121 | --remap-to-ancestor) 122 | # deprecated ($remap_to_ancestor is set now automatically) 123 | shift 124 | remap_to_ancestor=t 125 | continue 126 | ;; 127 | --prune-empty) 128 | shift 129 | prune_empty=t 130 | continue 131 | ;; 132 | -*) 133 | ;; 134 | *) 135 | break; 136 | esac 137 | 138 | # all switches take one argument 139 | ARG="$1" 140 | case "$#" in 1) usage ;; esac 141 | shift 142 | OPTARG="$1" 143 | shift 144 | 145 | case "$ARG" in 146 | -d) 147 | tempdir="$OPTARG" 148 | ;; 149 | --env-filter) 150 | filter_env="$OPTARG" 151 | ;; 152 | --tree-filter) 153 | filter_tree="$OPTARG" 154 | ;; 155 | --index-filter) 156 | filter_index="$OPTARG" 157 | ;; 158 | --parent-filter) 159 | filter_parent="$OPTARG" 160 | ;; 161 | --msg-filter) 162 | filter_msg="$OPTARG" 163 | ;; 164 | --commit-filter) 165 | filter_commit="$functions; $OPTARG" 166 | ;; 167 | --tag-name-filter) 168 | filter_tag_name="$OPTARG" 169 | ;; 170 | --subdirectory-filter) 171 | filter_subdir="$OPTARG" 172 | remap_to_ancestor=t 173 | ;; 174 | --original) 175 | orig_namespace=$(expr "$OPTARG/" : '\(.*[^/]\)/*$')/ 176 | ;; 177 | *) 178 | usage 179 | ;; 180 | esac 181 | done 182 | 183 | case "$prune_empty,$filter_commit" in 184 | ,) 185 | filter_commit='git commit-tree "$@"';; 186 | t,) 187 | filter_commit="$functions;"' git_commit_non_empty_tree "$@"';; 188 | ,*) 189 | ;; 190 | *) 191 | die "Cannot set --prune-empty and --commit-filter at the same time" 192 | esac 193 | 194 | case "$force" in 195 | t) 196 | rm -rf "$tempdir" 197 | ;; 198 | '') 199 | test -d "$tempdir" && 200 | die "$tempdir already exists, please remove it" 201 | esac 202 | mkdir -p "$tempdir/t" && 203 | tempdir="$(cd "$tempdir"; pwd)" && 204 | cd "$tempdir/t" && 205 | workdir="$(pwd)" || 206 | die "" 207 | 208 | # Remove tempdir on exit 209 | trap 'cd ../..; rm -rf "$tempdir"' 0 210 | 211 | ORIG_GIT_DIR="$GIT_DIR" 212 | ORIG_GIT_WORK_TREE="$GIT_WORK_TREE" 213 | ORIG_GIT_INDEX_FILE="$GIT_INDEX_FILE" 214 | GIT_WORK_TREE=. 215 | export GIT_DIR GIT_WORK_TREE 216 | 217 | # Make sure refs/original is empty 218 | git for-each-ref > "$tempdir"/backup-refs || exit 219 | while read sha1 type name 220 | do 221 | case "$force,$name" in 222 | ,$orig_namespace*) 223 | die "Cannot create a new backup. 224 | A previous backup already exists in $orig_namespace 225 | Force overwriting the backup with -f" 226 | ;; 227 | t,$orig_namespace*) 228 | git update-ref -d "$name" $sha1 229 | ;; 230 | esac 231 | done < "$tempdir"/backup-refs 232 | 233 | # The refs should be updated if their heads were rewritten 234 | git rev-parse --no-flags --revs-only --symbolic-full-name \ 235 | --default HEAD "$@" > "$tempdir"/raw-heads || exit 236 | sed -e '/^^/d' "$tempdir"/raw-heads >"$tempdir"/heads 237 | 238 | test -s "$tempdir"/heads || 239 | die "Which ref do you want to rewrite?" 240 | 241 | GIT_INDEX_FILE="$(pwd)/../index" 242 | export GIT_INDEX_FILE 243 | 244 | # map old->new commit ids for rewriting parents 245 | mkdir ../map || die "Could not create map/ directory" 246 | 247 | # we need "--" only if there are no path arguments in $@ 248 | nonrevs=$(git rev-parse --no-revs "$@") || exit 249 | if test -z "$nonrevs" 250 | then 251 | dashdash=-- 252 | else 253 | dashdash= 254 | remap_to_ancestor=t 255 | fi 256 | 257 | rev_args=$(git rev-parse --revs-only "$@") 258 | 259 | case "$filter_subdir" in 260 | "") 261 | eval set -- "$(git rev-parse --sq --no-revs "$@")" 262 | ;; 263 | *) 264 | eval set -- "$(git rev-parse --sq --no-revs "$@" $dashdash \ 265 | "$filter_subdir")" 266 | ;; 267 | esac 268 | 269 | # add null object to repository for is-binary 270 | NULL_OBJECT=`git hash-object -w /dev/null` 271 | export NULL_OBJECT 272 | 273 | # based on 274 | # http://stackoverflow.com/questions/6119956/how-to-determine-if-git-handles-a-file-as-binary-or-as-text 275 | BINARY_NUMSTAT=$(printf '%s\t-\t' -) 276 | declare -A GIT_OBJ_DICT 277 | export BINARY_NUMSTAT 278 | is-binary () { 279 | diffstat="`git diff --numstat $NULL_OBJECT $1`" 280 | case $diffstat in 281 | "$BINARY_NUMSTAT"*) 282 | return 0 283 | ;; 284 | *) 285 | return 1 286 | ;; 287 | esac 288 | } 289 | export -f is-binary 290 | 291 | git rev-list --reverse --topo-order --default HEAD \ 292 | --parents --simplify-merges $rev_args "$@" > ../revs || 293 | die "Could not get the commits" 294 | commits=$(wc -l <../revs | tr -d " ") 295 | 296 | test $commits -eq 0 && die "Found nothing to rewrite" 297 | 298 | # Rewrite the commits 299 | 300 | git_filter_branch__commit_count=0 301 | while read commit parents; do 302 | git_filter_branch__commit_count=$(($git_filter_branch__commit_count+1)) 303 | printf "\rRewrite $commit ($git_filter_branch__commit_count/$commits)" 304 | 305 | case "$filter_subdir" in 306 | "") 307 | git read-tree -i -m $commit 308 | ;; 309 | *) 310 | # The commit may not have the subdirectory at all 311 | err=$(git read-tree -i -m $commit:"$filter_subdir" 2>&1) || { 312 | if ! git rev-parse -q --verify $commit:"$filter_subdir" 313 | then 314 | rm -f "$GIT_INDEX_FILE" 315 | else 316 | echo >&2 "$err" 317 | false 318 | fi 319 | } 320 | esac || die "Could not initialize the index" 321 | 322 | GIT_COMMIT=$commit 323 | export GIT_COMMIT 324 | 325 | if [ "${#parents}" != "40" ]; then 326 | readarray -t < <(git ls-files -s | sed "s/\t/ /" | cut -f1,2,4) 327 | else 328 | readarray -t < <(git diff-tree -r --no-commit-id $parents $commit | sed "s/\t/ /" | cut -f2,4,6 -d' ') 329 | fi 330 | for line in "${MAPFILE[@]}" 331 | do 332 | object="${line:7:40}" 333 | if [ -z "${GIT_OBJ_DICT[X$object]}" ]; then 334 | if [ "${line:0:2}" != "10" ]; then 335 | # not a regular file in this case, so skip it 336 | new_object=$object 337 | elif is-binary $object; then 338 | # don't mess with binaries (such as png files) 339 | new_object=$object 340 | elif [ "${line: -6}" == ".patch" -o "${line: -5}" == ".diff" ]; then 341 | # don't mess with diff or patch files 342 | new_object=$object 343 | else 344 | new_object=`git cat-file -p $object | sed 's+\s*$++' | git hash-object -w --stdin` 345 | fi 346 | GIT_OBJ_DICT[X$object]=$new_object 347 | fi 348 | done 349 | 350 | git ls-files -s | 351 | { 352 | while read a object b c 353 | do 354 | echo -e "$a ${GIT_OBJ_DICT[X$object]} $b\t$c" 355 | done 356 | } | 357 | { 358 | if [ "$REPO" == "." ]; then 359 | sed "s+\tspkg/bin+\t$SAGE_SCRIPTS_DIR+" | 360 | sed "s+\tspkg+\t$SAGE_BUILD+" 361 | elif [ "$REPO" == "$SAGE_EXTDIR" ]; then 362 | sed -e "s+\t+&$REPO/+" -e '/~$/d' | 363 | sed "s+$REPO/sage/ext/mac-app+$SAGE_MACAPP+" 364 | elif [ "$REPO" == "$SAGE_SRC" ]; then 365 | sed "/\(\.tar\|\(~\|\.zip\|\.spkg\)\$\)/d" | 366 | sed "s+\t+&$REPO/+" 367 | else 368 | sed "/\(\tsrc\|\.tar\|\(~\|\.zip\|\.spkg\)\$\)/d" | 369 | sed "s+\t+&$REPO/+" 370 | fi 371 | } | 372 | GIT_INDEX_FILE=$GIT_INDEX_FILE.new git update-index --index-info && 373 | { 374 | if [ -f $GIT_INDEX_FILE.new ]; then 375 | mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE 376 | else 377 | rm $GIT_INDEX_FILE 378 | fi 379 | } 380 | 381 | git cat-file commit "$commit" >../commit || 382 | die "Cannot read commit $commit" 383 | 384 | eval "$(set_ident <../commit)" || 385 | die "setting author/committer failed for commit $commit" 386 | eval "$filter_env" < /dev/null || 387 | die "env filter failed: $filter_env" 388 | 389 | if [ "$filter_tree" ]; then 390 | git checkout-index -f -u -a || 391 | die "Could not checkout the index" 392 | # files that $commit removed are now still in the working tree; 393 | # remove them, else they would be added again 394 | git clean -d -q -f -x 395 | eval "$filter_tree" < /dev/null || 396 | die "tree filter failed: $filter_tree" 397 | 398 | ( 399 | git diff-index -r --name-only --ignore-submodules $commit && 400 | git ls-files --others 401 | ) > "$tempdir"/tree-state || exit 402 | git update-index --add --replace --remove --stdin \ 403 | < "$tempdir"/tree-state || exit 404 | fi 405 | 406 | eval "$filter_index" < /dev/null || 407 | die "index filter failed: $filter_index" 408 | 409 | parentstr= 410 | for parent in $parents; do 411 | for reparent in $(map "$parent"); do 412 | parentstr="$parentstr -p $reparent" 413 | done 414 | done 415 | if [ "$filter_parent" ]; then 416 | parentstr="$(echo "$parentstr" | eval "$filter_parent")" || 417 | die "parent filter failed: $filter_parent" 418 | fi 419 | 420 | sed -e '1,/^$/d' <../commit | \ 421 | eval "$filter_msg" > ../message || 422 | die "msg filter failed: $filter_msg" 423 | workdir=$workdir /bin/sh -c "$filter_commit" "git commit-tree" \ 424 | $(git write-tree) $parentstr < ../message > ../map/$commit || 425 | die "could not write rewritten commit" 426 | done <../revs 427 | 428 | # If we are filtering for paths, as in the case of a subdirectory 429 | # filter, it is possible that a specified head is not in the set of 430 | # rewritten commits, because it was pruned by the revision walker. 431 | # Ancestor remapping fixes this by mapping these heads to the unique 432 | # nearest ancestor that survived the pruning. 433 | 434 | if test "$remap_to_ancestor" = t 435 | then 436 | while read ref 437 | do 438 | sha1=$(git rev-parse "$ref"^0) 439 | test -f "$workdir"/../map/$sha1 && continue 440 | ancestor=$(git rev-list --simplify-merges -1 "$ref" "$@") 441 | test "$ancestor" && echo $(map $ancestor) >> "$workdir"/../map/$sha1 442 | done < "$tempdir"/heads 443 | fi 444 | 445 | # Finally update the refs 446 | 447 | _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]' 448 | _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40" 449 | echo 450 | while read ref 451 | do 452 | # avoid rewriting a ref twice 453 | test -f "$orig_namespace$ref" && continue 454 | 455 | sha1=$(git rev-parse "$ref"^0) 456 | rewritten=$(map $sha1) 457 | 458 | test $sha1 = "$rewritten" && 459 | warn "WARNING: Ref '$ref' is unchanged" && 460 | continue 461 | 462 | case "$rewritten" in 463 | '') 464 | echo "Ref '$ref' was deleted" 465 | git update-ref -m "filter-branch: delete" -d "$ref" $sha1 || 466 | die "Could not delete $ref" 467 | ;; 468 | $_x40) 469 | echo "Ref '$ref' was rewritten" 470 | if ! git update-ref -m "filter-branch: rewrite" \ 471 | "$ref" $rewritten $sha1 2>/dev/null; then 472 | if test $(git cat-file -t "$ref") = tag; then 473 | if test -z "$filter_tag_name"; then 474 | warn "WARNING: You said to rewrite tagged commits, but not the corresponding tag." 475 | warn "WARNING: Perhaps use '--tag-name-filter cat' to rewrite the tag." 476 | fi 477 | else 478 | die "Could not rewrite $ref" 479 | fi 480 | fi 481 | ;; 482 | *) 483 | # NEEDSWORK: possibly add -Werror, making this an error 484 | warn "WARNING: '$ref' was rewritten into multiple commits:" 485 | warn "$rewritten" 486 | warn "WARNING: Ref '$ref' points to the first one now." 487 | rewritten=$(echo "$rewritten" | head -n 1) 488 | git update-ref -m "filter-branch: rewrite to first" \ 489 | "$ref" $rewritten $sha1 || 490 | die "Could not rewrite $ref" 491 | ;; 492 | esac 493 | git update-ref -m "filter-branch: backup" "$orig_namespace$ref" $sha1 || 494 | exit 495 | done < "$tempdir"/heads 496 | 497 | # TODO: This should possibly go, with the semantics that all positive given 498 | # refs are updated, and their original heads stored in refs/original/ 499 | # Filter tags 500 | 501 | if [ "$filter_tag_name" ]; then 502 | git for-each-ref --format='%(objectname) %(objecttype) %(refname)' refs/tags | 503 | while read sha1 type ref; do 504 | ref="${ref#refs/tags/}" 505 | # XXX: Rewrite tagged trees as well? 506 | if [ "$type" != "commit" -a "$type" != "tag" ]; then 507 | continue; 508 | fi 509 | 510 | if [ "$type" = "tag" ]; then 511 | # Dereference to a commit 512 | sha1t="$sha1" 513 | sha1="$(git rev-parse -q "$sha1"^{commit})" || continue 514 | fi 515 | 516 | [ -f "../map/$sha1" ] || continue 517 | new_sha1="$(cat "../map/$sha1")" 518 | GIT_COMMIT="$sha1" 519 | export GIT_COMMIT 520 | new_ref="$(echo "$ref" | eval "$filter_tag_name")" || 521 | die "tag name filter failed: $filter_tag_name" 522 | 523 | echo "$ref -> $new_ref ($sha1 -> $new_sha1)" 524 | 525 | if [ "$type" = "tag" ]; then 526 | new_sha1=$( ( printf 'object %s\ntype commit\ntag %s\n' \ 527 | "$new_sha1" "$new_ref" 528 | git cat-file tag "$ref" | 529 | sed -n \ 530 | -e '1,/^$/{ 531 | /^object /d 532 | /^type /d 533 | /^tag /d 534 | }' \ 535 | -e '/^-----BEGIN PGP SIGNATURE-----/q' \ 536 | -e 'p' ) | 537 | git mktag) || 538 | die "Could not create new tag object for $ref" 539 | if git cat-file tag "$ref" | \ 540 | sane_grep '^-----BEGIN PGP SIGNATURE-----' >/dev/null 2>&1 541 | then 542 | warn "gpg signature stripped from tag object $sha1t" 543 | fi 544 | fi 545 | 546 | git update-ref "refs/tags/$new_ref" "$new_sha1" || 547 | die "Could not write tag $new_ref" 548 | done 549 | fi 550 | 551 | cd ../.. 552 | rm -rf "$tempdir" 553 | 554 | trap - 0 555 | 556 | unset GIT_DIR GIT_WORK_TREE GIT_INDEX_FILE 557 | test -z "$ORIG_GIT_DIR" || { 558 | GIT_DIR="$ORIG_GIT_DIR" && export GIT_DIR 559 | } 560 | test -z "$ORIG_GIT_WORK_TREE" || { 561 | GIT_WORK_TREE="$ORIG_GIT_WORK_TREE" && 562 | export GIT_WORK_TREE 563 | } 564 | test -z "$ORIG_GIT_INDEX_FILE" || { 565 | GIT_INDEX_FILE="$ORIG_GIT_INDEX_FILE" && 566 | export GIT_INDEX_FILE 567 | } 568 | 569 | if [ "$(is_bare_repository)" = false ]; then 570 | git read-tree -u -m HEAD || exit 571 | fi 572 | 573 | exit 0 574 | --------------------------------------------------------------------------------