Mercurial > hg
view tests/test-rebase-emptycommit.t @ 38486:4c0683655599
namespaces: let namespaces override singlenode() definition
Some namespaces have multiple nodes per name (meaning that their
namemap() returns multiple nodes). One such namespace is the "topics"
namespace (from the evolve repo). We also have our own internal
namespace at Google (for review units) that has multiple nodes per
name. These namespaces may not want to use the default "pick highest
revnum" resolution that we currently use when resolving a name to a
single node. As an example, they may decide that `hg co <name>` should
check out a commit that's last in some sense even if an earlier commit
had just been amended and thus had a higher revnum [1]. This patch
gives the namespace the option to continue to return multiple nodes
and to override how the best node is picked. Allowing namespaces to
override that may also be useful as an optimization (it may be cheaper
for the namespace to find just that node).
I have been arguing (in D3715) for using all the nodes returned from
namemap() when resolving the symbol to a revset, so e.g. `hg log -r
stable` would resolve to *all* nodes on stable, not just the one with
the highest revnum (except that I don't actually think we should
change it for the branch namespace because of BC). Most people seem
opposed to that. If we decide not to do it, I think we can deprecate
the namemap() function in favor of the new singlenode() (I find it
weird to have namespaces, like the branch namespace, where namemap()
isn't nodemap()'s inverse). I therefore think this patch makes sense
regardless of what we decide on that issue.
[1] Actually, even the branch namespace would have wanted to override
singlenode() if it had supported multiple nodes. That's because
closes branch heads are mostly ignored, so "hg co default" will
not check out the highest-revnum node if that's a closed head.
Differential Revision: https://phab.mercurial-scm.org/D3852
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Tue, 26 Jun 2018 10:02:01 -0700 |
parents | 4441705b7111 |
children | 09680349cc2d |
line wrap: on
line source
$ cat >> $HGRCPATH<<EOF > [extensions] > rebase= > drawdag=$TESTDIR/drawdag.py > EOF $ hg init non-merge $ cd non-merge $ hg debugdrawdag<<'EOS' > F > | > E > | > D > | > B C > |/ > A > EOS $ for i in C D E F; do > hg bookmark -r $i -i BOOK-$i > done $ hg debugdrawdag<<'EOS' > E > | > D > | > B > EOS $ hg log -G -T '{rev} {desc} {bookmarks}' o 7 E | o 6 D | | o 5 F BOOK-F | | | o 4 E BOOK-E | | | o 3 D BOOK-D | | | o 2 C BOOK-C | | o | 1 B |/ o 0 A With --keep, bookmark should move $ hg rebase -r 3+4 -d E --keep rebasing 3:e7b3f00ed42e "D" (BOOK-D) note: rebase of 3:e7b3f00ed42e created no changes to commit rebasing 4:69a34c08022a "E" (BOOK-E) note: rebase of 4:69a34c08022a created no changes to commit $ hg log -G -T '{rev} {desc} {bookmarks}' o 7 E BOOK-D BOOK-E | o 6 D | | o 5 F BOOK-F | | | o 4 E | | | o 3 D | | | o 2 C BOOK-C | | o | 1 B |/ o 0 A Move D and E back for the next test $ hg bookmark BOOK-D -fqir 3 $ hg bookmark BOOK-E -fqir 4 Bookmark is usually an indication of a head. For changes that are introduced by an ancestor of bookmark B, after moving B to B-NEW, the changes are ideally still introduced by an ancestor of changeset on B-NEW. In the below case, "BOOK-D", and "BOOK-E" include changes introduced by "C". $ hg rebase -s 2 -d E rebasing 2:dc0947a82db8 "C" (BOOK-C C) rebasing 3:e7b3f00ed42e "D" (BOOK-D) note: rebase of 3:e7b3f00ed42e created no changes to commit rebasing 4:69a34c08022a "E" (BOOK-E) note: rebase of 4:69a34c08022a created no changes to commit rebasing 5:6b2aeab91270 "F" (BOOK-F F) saved backup bundle to $TESTTMP/non-merge/.hg/strip-backup/dc0947a82db8-52bb4973-rebase.hg $ hg log -G -T '{rev} {desc} {bookmarks}' o 5 F BOOK-F | o 4 C BOOK-C BOOK-D BOOK-E | o 3 E | o 2 D | o 1 B | o 0 A Merge and its ancestors all become empty $ hg init $TESTTMP/merge1 $ cd $TESTTMP/merge1 $ hg debugdrawdag<<'EOS' > E > /| > B C D > \|/ > A > EOS $ for i in C D E; do > hg bookmark -r $i -i BOOK-$i > done $ hg debugdrawdag<<'EOS' > H > | > D > | > C > | > B > EOS $ hg rebase -r '(A::)-(B::)-A' -d H rebasing 2:dc0947a82db8 "C" (BOOK-C) note: rebase of 2:dc0947a82db8 created no changes to commit rebasing 3:b18e25de2cf5 "D" (BOOK-D) note: rebase of 3:b18e25de2cf5 created no changes to commit rebasing 4:86a1f6686812 "E" (BOOK-E E) note: rebase of 4:86a1f6686812 created no changes to commit saved backup bundle to $TESTTMP/merge1/.hg/strip-backup/b18e25de2cf5-1fd0a4ba-rebase.hg $ hg log -G -T '{rev} {desc} {bookmarks}' o 4 H BOOK-C BOOK-D BOOK-E | o 3 D | o 2 C | o 1 B | o 0 A Part of ancestors of a merge become empty $ hg init $TESTTMP/merge2 $ cd $TESTTMP/merge2 $ hg debugdrawdag<<'EOS' > G > /| > E F > | | > B C D > \|/ > A > EOS $ for i in C D E F G; do > hg bookmark -r $i -i BOOK-$i > done $ hg debugdrawdag<<'EOS' > H > | > F > | > C > | > B > EOS $ hg rebase -r '(A::)-(B::)-A' -d H rebasing 2:dc0947a82db8 "C" (BOOK-C) note: rebase of 2:dc0947a82db8 created no changes to commit rebasing 3:b18e25de2cf5 "D" (BOOK-D D) rebasing 4:03ca77807e91 "E" (BOOK-E E) rebasing 5:ad6717a6a58e "F" (BOOK-F) note: rebase of 5:ad6717a6a58e created no changes to commit rebasing 6:c58e8bdac1f4 "G" (BOOK-G G) saved backup bundle to $TESTTMP/merge2/.hg/strip-backup/b18e25de2cf5-2d487005-rebase.hg $ hg log -G -T '{rev} {desc} {bookmarks}' o 7 G BOOK-G |\ | o 6 E BOOK-E | | o | 5 D BOOK-D BOOK-F |/ o 4 H BOOK-C | o 3 F | o 2 C | o 1 B | o 0 A