Patchwork [4,of,6,V2] obsolete: add revset and test for divergent changesets

login
register
mail settings
Submitter Pierre-Yves David
Date Dec. 13, 2012, 2:51 p.m.
Message ID <9c04c46919d1bef1e6da.1355410311@crater1.logilab.fr>
Download mbox | patch
Permalink /patch/81/
State Accepted
Commit bea754715961e7e838065646e000f12cb79a3b99
Headers show

Comments

Pierre-Yves David - Dec. 13, 2012, 2:51 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1355278375 -3600
# Node ID 9c04c46919d1bef1e6daa813f3a59bd56a421608
# Parent  cfc7306dbdc75659ca4c85a14720f8de87cd797e
obsolete: add revset and test for divergent changesets

This changesets add a new `divergent()` revset similar to `unstable()` and
`bumped()` one. Introducting this revset allows actuall test of the divergent
detection.

Patch

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -639,10 +639,19 @@  def destination(repo, subset, x):
             r = src
             src = _getrevsource(repo, r)
 
     return [r for r in subset if r in dests]
 
+def divergent(repo, subset, x):
+    """``divergent()``
+    Final successors of changesets with an alternative set of final successors.
+    """
+    # i18n: "divergent" is a keyword
+    getargs(x, 0, 0, _("divergent takes no arguments"))
+    divergent = obsmod.getrevs(repo, 'divergent')
+    return [r for r in subset if r in divergent]
+
 def draft(repo, subset, x):
     """``draft()``
     Changeset in draft phase."""
     # i18n: "draft" is a keyword
     getargs(x, 0, 0, _("draft takes no arguments"))
@@ -1534,10 +1543,11 @@  symbols = {
     "date": date,
     "desc": desc,
     "descendants": descendants,
     "_firstdescendants": _firstdescendants,
     "destination": destination,
+    "divergent": divergent,
     "draft": draft,
     "extinct": extinct,
     "extra": extra,
     "file": hasfile,
     "filelog": filelog,
diff --git a/tests/test-obsolete-divergent.t b/tests/test-obsolete-divergent.t
--- a/tests/test-obsolete-divergent.t
+++ b/tests/test-obsolete-divergent.t
@@ -79,10 +79,13 @@  A_1 have two direct and divergent succes
       82623d38b9ba
   82623d38b9ba
       82623d38b9ba
   392fd25390da
       392fd25390da
+  $ hg log -r 'divergent()'
+  2:82623d38b9ba A_1
+  3:392fd25390da A_2
   $ cd ..
 
 
 indirect divergence with known changeset
 -------------------------------------------
@@ -114,10 +117,13 @@  indirect divergence with known changeset
       82623d38b9ba
   392fd25390da
       01f36c5a8fda
   01f36c5a8fda
       01f36c5a8fda
+  $ hg log -r 'divergent()'
+  2:82623d38b9ba A_1
+  4:01f36c5a8fda A_3
   $ cd ..
 
 
 indirect divergence with known changeset
 -------------------------------------------
@@ -143,10 +149,13 @@  indirect divergence with known changeset
       82623d38b9ba
   82623d38b9ba
       82623d38b9ba
   392fd25390da
       392fd25390da
+  $ hg log -r 'divergent()'
+  2:82623d38b9ba A_1
+  3:392fd25390da A_2
   $ cd ..
 
 do not take unknown node in account if they are final
 -----------------------------------------------------
 
@@ -193,10 +202,11 @@  divergence that converge again is not di
       01f36c5a8fda
   392fd25390da
       01f36c5a8fda
   01f36c5a8fda
       01f36c5a8fda
+  $ hg log -r 'divergent()'
   $ cd ..
 
 split is not divergences
 -----------------------------
 
@@ -218,10 +228,11 @@  split is not divergences
       82623d38b9ba 392fd25390da
   82623d38b9ba
       82623d38b9ba
   392fd25390da
       392fd25390da
+  $ hg log -r 'divergent()'
 
 Even when subsequente rewriting happen
 
   $ mkcommit A_3
   created new head
@@ -264,10 +275,11 @@  Even when subsequente rewriting happen
       01f36c5a8fda
   6a411f0d7a0a
       e442cfc57690
   e442cfc57690
       e442cfc57690
+  $ hg log -r 'divergent()'
 
 Check more complexe obsolescence graft (with divergence)
 
   $ mkcommit B_0; hg up 0
   0 files updated, 0 files merged, 2 files removed, 0 files unresolved
@@ -332,10 +344,15 @@  Check more complexe obsolescence graft (
       7ae126973a96
   14608b260df8
       14608b260df8
   bed64f5d2f5a
       bed64f5d2f5a
+  $ hg log -r 'divergent()'
+  4:01f36c5a8fda A_3
+  8:7ae126973a96 A_7
+  9:14608b260df8 A_8
+  10:bed64f5d2f5a A_9
 
 fix the divergence
 
   $ mkcommit A_A; hg up 0
   created new head
@@ -391,10 +408,11 @@  fix the divergence
       a139f71be9da
   bed64f5d2f5a
       a139f71be9da
   a139f71be9da
       a139f71be9da
+  $ hg log -r 'divergent()'
 
   $ cd ..
 
 
 Subset does not diverge