[PATCH 2 of 2] parentrevspec: foo~~ syntax to find the start of the branch
Florent Guillaume
fg at nuxeo.com
Tue Feb 26 13:07:05 UTC 2008
# HG changeset patch
# User Florent Guillaume <fg at nuxeo.com>
# Date 1204031074 -3600
# Node ID 50c8228fd413ad747f067e7045408a3288194c59
# Parent 5058175e99fbd7078d5ca7f37a5c03c7e0918973
parentrevspec: foo~~ syntax to find the start of the branch
diff --git a/hgext/parentrevspec.py b/hgext/parentrevspec.py
--- a/hgext/parentrevspec.py
+++ b/hgext/parentrevspec.py
@@ -22,6 +22,7 @@ For example, if you can refer to a revis
foo~0 = foo
foo~1 = foo^1 = foo^ = first parent of foo
foo~2 = foo^1^1 = foo^^ = first parent of first parent of foo
+ foo~~ = start of the branch containing foo
'''
import mercurial.repo
@@ -75,6 +76,12 @@ def reposetup(ui, repo):
if n:
rev = p[n - 1]
i = j
+ # foo~~ = start of the branch containing foo
+ elif suffix[i:i+2] == '~~':
+ i += 2
+ rev = cl.branchingrev(rev)
+ if rev is None:
+ raise
# foo~N => Nth first grandparent of foo
# foo~0 = foo
# foo~1 = foo^1 == foo^ == 1st parent of foo
diff --git a/tests/test-parentrevspec b/tests/test-parentrevspec
--- a/tests/test-parentrevspec
+++ b/tests/test-parentrevspec
@@ -19,6 +19,15 @@ commit()
hg commit -d '0 0' -qAm "$msg" foo
}
+lookup()
+{
+ for rev in "$@"; do
+ printf "$rev: "
+ hg id -nr $rev
+ done
+ true
+}
+
hg init repo
cd repo
@@ -30,20 +39,19 @@ commit '2: change foo 2a'
commit '2: change foo 2a'
commit '3: change foo 3a'
commit '4: change foo 2b' 1
+
+hg log --template '#rev#:#node|short# #parents#\n'
+echo
+
+echo 'branching points'
+lookup "0~~" "1~~" "2~~" "3~~" "4~~"
+echo
+
commit '5: merge' 3 4
commit '6: change foo again'
hg log --template '#rev#:#node|short# #parents#\n'
echo
-
-lookup()
-{
- for rev in "$@"; do
- printf "$rev: "
- hg id -nr $rev
- done
- true
-}
tipnode=`hg id -ir tip`
@@ -66,4 +74,20 @@ echo 'with a tag "foo^bar" pointing to r
echo 'with a tag "foo^bar" pointing to rev 2'
hg tag -l -r 2 "foo^bar"
lookup "foo^bar" "foo^bar^"
+echo
+echo 'branching points after merge'
+lookup "0~~" "1~~" "2~~" "3~~" "4~~" "5~~" "6~~"
+echo
+
+commit '7: start branch' 3
+commit '8: blah on branch'
+commit '9: again'
+
+hg log --template '#rev#:#node|short# #parents#\n'
+echo
+
+echo 'branching points after new branching'
+lookup "0~~" "1~~" "2~~" "3~~" "4~~" "5~~" "6~~" "7~~" "8~~" "9~~"
+
+
diff --git a/tests/test-parentrevspec.out b/tests/test-parentrevspec.out
--- a/tests/test-parentrevspec.out
+++ b/tests/test-parentrevspec.out
@@ -1,3 +1,16 @@ 6:755d1e0d79e9
+4:bb4475edb621 1:5d953a1917d1
+3:a3e00c7dbf11
+2:befc7d89d081
+1:5d953a1917d1
+0:837088b6e1d9
+
+branching points
+0~~: abort: unknown revision '0~~'!
+1~~: abort: unknown revision '1~~'!
+2~~: 2
+3~~: 2
+4~~: 4
+
6:755d1e0d79e9
5:9ce2ce29723a 3:a3e00c7dbf11 4:bb4475edb621
4:bb4475edb621 1:5d953a1917d1
@@ -42,3 +55,35 @@ with a tag "foo^bar" pointing to rev 2
with a tag "foo^bar" pointing to rev 2
foo^bar: 2
foo^bar^: abort: unknown revision 'foo^bar^'!
+
+branching points after merge
+0~~: 0
+1~~: 0
+2~~: 0
+3~~: 0
+4~~: 0
+5~~: 0
+6~~: 0
+
+9:ebb5b2a4ce17
+8:c8e3e6d2d6ef
+7:44190156be2e 3:a3e00c7dbf11
+6:755d1e0d79e9
+5:9ce2ce29723a 3:a3e00c7dbf11 4:bb4475edb621
+4:bb4475edb621 1:5d953a1917d1
+3:a3e00c7dbf11
+2:befc7d89d081
+1:5d953a1917d1
+0:837088b6e1d9
+
+branching points after new branching
+0~~: abort: unknown revision '0~~'!
+1~~: abort: unknown revision '1~~'!
+2~~: abort: unknown revision '2~~'!
+3~~: abort: unknown revision '3~~'!
+4~~: 4
+5~~: 4
+6~~: 4
+7~~: 7
+8~~: 7
+9~~: 7
More information about the Mercurial-devel
mailing list