[PATCH 6 of 8 V2] revset: update destination() predicate to be symmetric with transitive origin()
Matt Harbison
matt_harbison at yahoo.com
Thu Jun 7 23:58:24 CDT 2012
# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1337918047 14400
# Node ID f49f64c658a1feb70aade60da4c764772d2d5162
# Parent 543798868ac78ed1c733cde9a3d37d1c50a07440
revset: update destination() predicate to be symmetric with transitive origin()
This collects the source markers transitively when starting with a destination.
Using the same examples from the previous version:
o-S
/
o-o-G(S)
\
o-G(G(S))
hg log -r destination( G(S) ) # { S }
hg log -r destination( G(G(S)) ) # { S }, NOT { G(S) } (unchanged)
Sources of transplants and rebases, or combinations of {graft|rebase|transplant}
are not naturally transitive, due to their implementations NOT preserving the
previous source marker. While graft preserves the source marker it left, it
does not preserve the marker when grafting a transplant or rebase. For example
o-S
/
o-o-T(S)
\
o-T(T(S))
hg log -r destination( T(S) ) # { S }
hg log -r destination( T(T(S)) ) # { S, T(S) } (was { T(S) })
diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -574,7 +574,18 @@
else:
s = tuple(p.rev() for p in repo[None].parents())
- return [r for r in (_getrevsource(repo, r) for r in s) if r is not None]
+ l = list()
+
+ for r in s:
+ src = _getrevsource(repo, r)
+
+ # follow the source(s) all the way back to the original, or to the point
+ # where the source has already been added
+ while src is not None and src not in l:
+ l.append(src)
+ src = _getrevsource(repo, src)
+
+ return l
def draft(repo, subset, x):
"""``draft()``
diff --git a/tests/test-revset.t b/tests/test-revset.t
--- a/tests/test-revset.t
+++ b/tests/test-revset.t
@@ -1026,6 +1026,13 @@
date: Thu Jan 01 00:00:00 1970 +0000
summary: transplant src
+ changeset: 4:3a74c3d1dc16
+ branch: b1
+ tag: tp_origin
+ user: test
+ date: Thu Jan 01 00:00:00 1970 +0000
+ summary: transplant src
+
$ hg log -r "destination(tagged(grafted_transplant))"
changeset: 18:7e3d7b573a92
tag: tp2
@@ -1033,6 +1040,20 @@
date: Thu Jan 01 00:00:00 1970 +0000
summary: transplant src
+ changeset: 10:9dc2dd8ef04a
+ branch: b2
+ tag: tp1
+ user: test
+ date: Thu Jan 01 00:00:00 1970 +0000
+ summary: transplant src
+
+ changeset: 4:3a74c3d1dc16
+ branch: b1
+ tag: tp_origin
+ user: test
+ date: Thu Jan 01 00:00:00 1970 +0000
+ summary: transplant src
+
$ hg log -r "destination(tagged(transplanted_graft))"
changeset: 16:181b4cc9a9ed
tag: graft2
@@ -1041,5 +1062,12 @@
date: Thu Jan 01 00:00:00 1970 +0000
summary: graft src
+ changeset: 2:1b6f6802c4d8
+ branch: b1
+ tag: graft_origin
+ user: test
+ date: Thu Jan 01 00:00:00 1970 +0000
+ summary: graft src
+
$ cd ..
More information about the Mercurial-devel
mailing list