comparison mercurial/revset.py @ 17185:2c7c4824969e

revset: add origin() predicate This predicate is used to find the original source of csets created by a graft, transplant or rebase --keep. If a copied cset is itself copied, only the source of the original copy is selected. hg log -r origin() # all src csets, anywhere hg log -r origin(branch(default)) # all srcs of copies on default By following through different types of copy commands and only selecting the original cset, the implementation differences between the copy commands are hidden. (A graft of a graft preserves the original source in its 'extra' map, while transplant and rebase use the immediate source specified for the command). Given a repo with a cset S that is grafted to create G(S), which itself is grafted to become G(G(S)) o-S / o-o-G(S) \ o-G(G(S)) hg log -r origin( G(S) ) # { S } hg log -r origin( G(G(S)) ) # { S }, NOT { G(S) } Even if the last graft were a transplant hg log -r origin( T(G(S)) ) # { S } A rebase without --keep essentially strips the source, so providing the cset that results to this predicate will yield an empty set. Note that the convert extension does not currently update the 'extra' map in its destination csets, and therefore copies made prior to the convert will be unable to find their source.
author Matt Harbison <matt_harbison@yahoo.com>
date Sat, 07 Jul 2012 00:47:30 -0400
parents c621f84dbb35
children a3da6f298592
comparison
equal deleted inserted replaced
17184:5fa09a3b0034 17185:2c7c4824969e
886 """``obsolete()`` 886 """``obsolete()``
887 Mutable changeset with a newer version.""" 887 Mutable changeset with a newer version."""
888 getargs(x, 0, 0, _("obsolete takes no arguments")) 888 getargs(x, 0, 0, _("obsolete takes no arguments"))
889 return [r for r in subset if repo[r].obsolete()] 889 return [r for r in subset if repo[r].obsolete()]
890 890
891 def origin(repo, subset, x):
892 """``origin([set])``
893 Changesets that were specified as a source for the grafts, transplants or
894 rebases that created the given revisions. Omitting the optional set is the
895 same as passing all(). If a changeset created by these operations is itself
896 specified as a source for one of these operations, only the source changeset
897 for the first operation is selected.
898 """
899 if x is not None:
900 args = set(getset(repo, range(len(repo)), x))
901 else:
902 args = set(getall(repo, range(len(repo)), x))
903
904 def _firstsrc(rev):
905 src = _getrevsource(repo, rev)
906 if src is None:
907 return None
908
909 while True:
910 prev = _getrevsource(repo, src)
911
912 if prev is None:
913 return src
914 src = prev
915
916 o = set([_firstsrc(r) for r in args])
917 return [r for r in subset if r in o]
918
891 def outgoing(repo, subset, x): 919 def outgoing(repo, subset, x):
892 """``outgoing([path])`` 920 """``outgoing([path])``
893 Changesets not found in the specified destination repository, or the 921 Changesets not found in the specified destination repository, or the
894 default push location. 922 default push location.
895 """ 923 """
1390 "max": maxrev, 1418 "max": maxrev,
1391 "merge": merge, 1419 "merge": merge,
1392 "min": minrev, 1420 "min": minrev,
1393 "modifies": modifies, 1421 "modifies": modifies,
1394 "obsolete": obsolete, 1422 "obsolete": obsolete,
1423 "origin": origin,
1395 "outgoing": outgoing, 1424 "outgoing": outgoing,
1396 "p1": p1, 1425 "p1": p1,
1397 "p2": p2, 1426 "p2": p2,
1398 "parents": parents, 1427 "parents": parents,
1399 "present": present, 1428 "present": present,