Browse files

added code, license, readme and script to easily update externals

  • Loading branch information...
0 parents commit 9437ffd0fedd958fbfb2d1c038b0f89f3bfe8978 @cosmin cosmin committed May 14, 2009
Showing with 107 additions and 0 deletions.
  1. +3 −0 .gitmodules
  2. +19 −0 LICENSE
  3. +42 −0 README
  4. +36 −0 source.sh
  5. +7 −0 update-externals.sh
3 .gitmodules
@@ -0,0 +1,3 @@
+[submodule "fast-export"]
+ path = fast-export
+ url = git://repo.or.cz/fast-export.git
19 LICENSE
@@ -0,0 +1,19 @@
+Copyright (c) 2009, Cosmin Stejerean (offbytwo)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
42 README
@@ -0,0 +1,42 @@
+Author: Cosmin Stejerean (offbytwo)
+License: MIT
+Description: A set of scripts for checking out and tracking a mercrial project
+from git.
+
+* Dependencies *
+
+If this is a fresh checkout run
+
+ $ git submodule init
+ $ git submodule update
+
+to pull in fast-export. If for some reason you cannot do this
+get a copy of fast-export from http://repo.or.cz/w/fast-export.git and
+place it in the root of the checkout.
+
+* Installation *
+
+. /path/to/this/checkout/source.sh
+
+* Usage *
+
+- clone an hg repo, including ones over HTTP
+
+ $ git-hg-clone http://some/random/hg/repo local-git-repo-name
+
+- fetch updates from the hg repo
+
+ $ git-hg-fetch
+
+ or optionally
+
+ $ git-hg-pull # same as git-hg-fetch && git merge hg/branch_name
+
+
+* Structure *
+
+.git/hgcheckout - contains a bare mercurial checkout of the specified repo
+
+.git/hgremote - contains a bare git repo clones from the mercurial one, this
+ is added as a remote called "hg" in the base repo
+
36 source.sh
@@ -0,0 +1,36 @@
+function git-current-branch {
+ echo "`git branch | grep "*" | awk '{print $2}'`"
+}
+
+function git-hg-clone {
+ HG_REMOTE=$1
+ CHECKOUT=$2
+ mkdir $CHECKOUT
+ cd $CHECKOUT
+ CURRENT_PATH=`pwd`
+ git init
+ hg clone -U $HG_REMOTE .git/hgcheckout
+ mkdir .git/hgremote
+ cd .git/hgremote
+ git --bare init
+ $GITEXT_HOME/fast-export/hg-fast-export.sh -r ../hgcheckout
+ cd $CURRENT_PATH
+ git remote add hg .git/hgremote
+ git fetch hg
+ git pull hg master
+}
+
+function git-hg-fetch {
+ hg -R .git/hgcheckout pull
+ CURRENT_PATH=`pwd`
+ cd .git/hgremote
+ $GITEXT_HOME/fast-export/hg-fast-export.sh
+ cd $CURRENT_PATH
+ git fetch hg
+}
+
+function git-hg-pull {
+ current_branch=`git-current-branch`
+ git-hg-fetch
+ git merge hg/$current_branch
+}
7 update-externals.sh
@@ -0,0 +1,7 @@
+#!/usr/bin/env bash
+
+cd fast-export
+echo "`pwd`"
+git checkout master
+git pull origin
+cd ..

0 comments on commit 9437ffd

Please sign in to comment.