Takayuki KONDO avatar Takayuki KONDO committed 6f6e43f

improve get-hg-changegroup script

Comments (0)

Files changed (1)

get-hg-changegroup.sh

-#!/bin/bash
-
-if [[ -z $1 ]]; then
-    echo "Usage: $0 repository"
-    exit 1;
-fi
-
-function getFirstRev  # $1: Repository path
-{
-    if [[ $(uname -s) = MINGW* ]]; then
-	export LANGUAGE=C
-    else
-	export LANG=C
-    fi
-
-    TMP=/tmp/tmp.hg.$$
-    hg rollback --dry-run -R$1 > $TMP
-    
-    rollbackrev=`sed -e 's/repository tip rolled back to revision \([0-9-]*\) (undo commit)/\1/' $TMP`
-    rm $TMP
-
-    firstrev=`expr $rollbackrev + 1`
-
-    echo $firstrev
-}
-
-### for example (after a changegroup has been added via pull)
-HG_NODE=`getFirstRev $1`
-hg log -r "$HG_NODE:tip" -R$1
-
+#!/bin/bash
+# -*- coding:sjis-unix -*-
+
+if [[ -z $1 ]]; then
+    echo "Usage: $0 repository"
+    exit 1;
+fi
+
+function getFirstRev  # $1: Repository path
+{
+    if [[ $(uname -s) = MINGW* ]]; then
+	export LANGUAGE=C
+    else
+	export LANG=C
+    fi
+
+    TMP=/tmp/tmp.hg.$$
+    hg rollback --dry-run -R$1 > $TMP
+    
+    rollbackrev=`sed -e 's/repository tip rolled back to revision \([0-9-]*\) \([(a-z )]*\)/\1/' $TMP`
+    rm $TMP
+
+    if [[ -z $rollbackrev ]]; then
+	echo ""
+	exit 1;  # error 
+    fi
+
+    firstrev=`expr $rollbackrev + 1`
+
+    echo $firstrev
+}
+
+
+function getBranchNames  # $1: Repository path
+{
+    HG_NODE=`getFirstRev $1`
+
+    if [[ -z $HG_NODE ]];then
+	echo ""
+	exit 1;  # error
+    fi
+
+    BRANCH_NAMES=""
+    for branch in `hg log -R$1 -r "$HG_NODE:tip" --template "{branch} \n" | /usr/bin/sort | /usr/bin/uniq`; do
+	BRANCH_NAMES="$BRANCH_NAMES $branch"
+    done
+
+    echo $BRANCH_NAMES
+}
+
+
+# for example
+HG_BRANCH_NAMES=`getBranchNames $1`
+echo 'push ���ꂽ �u�����`���ꗗ :' $HG_BRANCH_NAMES
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.