[PATCH 8 of 8 V2] revset: add destinations() predicate

Matt Harbison matt_harbison at yahoo.com
Fri Jun 8 04:58:26 UTC 2012


# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1338952066 14400
# Node ID ab5055cdaba23f44440162d2cfaad58242f6a6bd
# Parent  a205c9dbef81a2ca5e3af665441e102fc5e219c1
revset: add destinations() predicate

    hg log -r destinations(all())            # all duplicated csets
    hg log -r destinations(branch(default))  # all csets copied onto default

This lacks symmetry with origins() in that origins() will skip intermediate
csets while this will select all _csets_ that are copies, not just the ones that
aren't used for further copies.  It isn't clear that the more restrictive
definition is useful here, and the most likely case is a cset is copied only
once anyway.  Therefore, the lack of symmetry may not be very noticeable.

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -587,6 +587,15 @@
 
     return l
 
+def destinations(repo, subset, x):
+    """``destinations(set)``
+    Changesets in the set that are the result of a graft, transplant or a rebase
+    operation anywhere in the repository.
+    """
+    s = getset(repo, subset, x)
+
+    return [r for r in s if _getrevsource(repo, r) is not None]
+
 def draft(repo, subset, x):
     """``draft()``
     Changeset in draft phase."""
@@ -1399,6 +1408,7 @@
     "descendants": descendants,
     "_firstdescendants": _firstdescendants,
     "destination": destination,
+    "destinations": destinations,
     "draft": draft,
     "extra": extra,
     "file": hasfile,
diff --git a/tests/test-revset.t b/tests/test-revset.t
--- a/tests/test-revset.t
+++ b/tests/test-revset.t
@@ -1116,4 +1116,69 @@
   summary:     transplant src
   
 
+  $ hg log -r "destinations(all())"
+  changeset:   9:7610ec1f7794
+  branch:      b2
+  tag:         graft1
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     graft src
+  
+  changeset:   10:9dc2dd8ef04a
+  branch:      b2
+  tag:         tp1
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     transplant src
+  
+  changeset:   11:c370d648cc65
+  branch:      b2
+  tag:         rebase1
+  parent:      10:9dc2dd8ef04a
+  parent:      5:40fc8932f3d8
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     rebase src
+  
+  changeset:   12:75ffd482453b
+  branch:      b2
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     Added tag rebase_origin for changeset b2f0b3dc5301
+  
+  changeset:   16:181b4cc9a9ed
+  tag:         graft2
+  parent:      0:cb9a9f314b8b
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     graft src
+  
+  changeset:   18:7e3d7b573a92
+  tag:         tp2
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     transplant src
+  
+  changeset:   21:f98dc9871c13
+  branch:      b3
+  tag:         grafted_transplant
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     transplant src
+  
+  changeset:   23:72b482e582db
+  branch:      b3
+  tag:         transplanted_graft
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     graft src
+  
+  $ hg log -r "destinations(18::)"
+  changeset:   18:7e3d7b573a92
+  tag:         tp2
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     transplant src
+  
+
   $ cd ..



More information about the Mercurial-devel mailing list