# HG changeset patch # User Pierre-Yves David # Date 1331211387 -3600 # Node ID 0599fb01dc41d28552da2456411fe24833445b73 # Parent c2f7a8530e51cb01b811f297975ec9f0f93cc4b1 add an obsolete parent revset and related alias diff -r c2f7a8530e51 -r 0599fb01dc41 enable.sh --- a/enable.sh Thu Mar 08 12:21:01 2012 +0100 +++ b/enable.sh Thu Mar 08 13:56:27 2012 +0100 @@ -3,6 +3,7 @@ here=`readlink -f "$0"` repo_root=`dirname "$here"` +# I gotta change this for cat soon echo "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" >&2 echo "XXX Add the line below to the [extensions] section of you hgrc XXX" >&2 echo "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" >&2 @@ -16,3 +17,19 @@ echo echo "# history rewriting UI" echo "evolve=${repo_root}/hgext/evolve.py" +echo +echo +echo '[alias]' +echo "### useful alias to check future amend result" +echo "# equivalent to the qdiff command for mq" +echo +echo "# diff" +echo 'pdiff=diff --rev .^' +echo +echo "# status" +echo 'pstatus=status --rev .^' +echo +echo "# diff with the previous amend" +echo "odiff=diff --rev 'limit(obsparents(.),1)' --rev ." + + diff -r c2f7a8530e51 -r 0599fb01dc41 hgext/obsolete.py --- a/hgext/obsolete.py Thu Mar 08 12:21:01 2012 +0100 +++ b/hgext/obsolete.py Thu Mar 08 13:56:27 2012 +0100 @@ -134,6 +134,24 @@ args = revset.getargs(x, 0, 0, 'unstable takes no arguments') return [r for r in subset if r in repo._extinctset] + +def _obsparents(repo, narrow, s): + cs = set() + nm = repo.changelog.nodemap + for r in s: + for p in repo._obssubrels.get(repo[r].node(), ()): + pr = nm.get(p, None) + if pr is not None: + cs.add(pr) + return cs + + +def revsetobsparents(repo, subset, x): + """obsolete parents of a changeset""" + s = revset.getset(repo, range(len(repo)), x) + cs = _obsparents(repo, subset, s) + return [r for r in subset if r in cs] + ### Other Extension compat ############################ @@ -160,6 +178,7 @@ revset.symbols["unstable"] = revsetunstable revset.symbols["suspended"] = revsetsuspended revset.symbols["extinct"] = revsetextinct + revset.symbols["obsparents"] = revsetobsparents try: diff -r c2f7a8530e51 -r 0599fb01dc41 tests/test-obsolete.t --- a/tests/test-obsolete.t Thu Mar 08 12:21:01 2012 +0100 +++ b/tests/test-obsolete.t Thu Mar 08 13:56:27 2012 +0100 @@ -6,6 +6,8 @@ > publish=False > [obsolete] > secret-unstable=no + > [alias] + > odiff=diff --rev 'limit(obsparents(.),1)' --rev . > [extensions] > EOF $ echo "obsolete=$(echo $(dirname $TESTDIR))/hgext/obsolete.py" >> $HGRCPATH @@ -51,6 +53,26 @@ 2 - 4538525df7e2 +Test that obsolete parent a properly computed + + $ qlog -r 'obsparents(.)' --hidden + 2 + - 4538525df7e2 + $ qlog -r . + 3 + - 0d3f46688ccc + $ hg odiff + diff -r 4538525df7e2 -r 0d3f46688ccc c + --- a/c Thu Jan 01 00:00:00 1970 +0000 + +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 + @@ -1,1 +0,0 @@ + -c + diff -r 4538525df7e2 -r 0d3f46688ccc obsol_c + --- /dev/null Thu Jan 01 00:00:00 1970 +0000 + +++ b/obsol_c Thu Jan 01 00:00:00 1970 +0000 + @@ -0,0 +1,1 @@ + +obsol_c + test obsolete changeset with no-obsolete descendant $ hg up 1 -q $ mkcommit "obsol_c'" # 4 (on 1)