Patchwork [2,of,2] unionrepo: override the _phasecache() to return a union phasecaches of two repos

login
register
mail settings
Submitter elson.wei@gmail.com
Date March 28, 2014, 1:33 a.m.
Message ID <209c9e7394bb8b59b010.1395970398@ElsonWei-NB.PrimeVOLT>
Download mbox | patch
Permalink /patch/4095/
State Changes Requested
Headers show

Comments

elson.wei@gmail.com - March 28, 2014, 1:33 a.m.
# HG changeset patch
# User Wei, Elson <elson.wei@gmail.com>
# Date 1395970218 -28800
#      Fri Mar 28 09:30:18 2014 +0800
# Node ID 209c9e7394bb8b59b01048abe2cc225456132eca
# Parent  077d695569cc1c6012b3aa6fb742b9dac22b133d
unionrepo: override the _phasecache() to return a union phasecaches of two repos

The phase roots of the repo2 are not loaded. All revisions in repo2 will become
'public'.
Mads Kiilerich - April 1, 2014, 1:36 a.m.
On 03/28/2014 02:33 AM, elson.wei@gmail.com wrote:
> # HG changeset patch
> # User Wei, Elson <elson.wei@gmail.com>
> # Date 1395970218 -28800
> #      Fri Mar 28 09:30:18 2014 +0800
> # Node ID 209c9e7394bb8b59b01048abe2cc225456132eca
> # Parent  077d695569cc1c6012b3aa6fb742b9dac22b133d
> unionrepo: override the _phasecache() to return a union phasecaches of two repos

I am sure you are onto something here. Phases were not considered when 
unionrepo was created and it will thus probably not do "the right thing".

One tricky case would be if a changeset has different phases in the two 
repositories. I don't what the result of that should be.

In which situation did you see the missing unionrepo as a problem?

> The phase roots of the repo2 are not loaded. All revisions in repo2 will become
> 'public'.

Is that a description of the situation before or after this patch? 
Please make that more clear in the description.

> diff --git a/tests/test-unionrepo.t b/tests/test-unionrepo.t
> --- a/tests/test-unionrepo.t
> +++ b/tests/test-unionrepo.t
> @@ -148,3 +148,9 @@
>     2:68c0685446a3  repo1-2
>     1:8a58db72e69d  repo1-1
>     0:f093fec0529b  repo1-0
> +
> +check the phase
> +
> +  $ hg -R union:repo1+repo2 phase -r 0:1
> +  0: draft
> +  1: draft

Testing shows that this test case gave the same result before the change 
and after. It is thus not really a convincing test case.

It do also not match the "All revisions in repo2 will become 'public'" 
description. Why is that?

Inserting test code like
   $ hg -R repo1 log -G -r null: --template '{rev}: {phase} {node|short} 
{desc|firstline}\n'
   $ hg -R repo2 log -G -r null: --template '{rev}: {phase} {node|short} 
{desc|firstline}\n'
   $ hg -R union:repo1+repo2 log -G -r null: --template '{rev}: {phase} 
{node|short} {desc|firstline}\n'
   $ hg -R union:repo2+repo1 log -G -r null: --template '{rev}: {phase} 
{node|short} {desc|firstline}\n'
without your change shows that the phase of changes from the 2nd repo 
varies. Why is that? It would be good to have a bit of a description of 
the problem you are solving so we can learn and verify that it really 
has been solved.

/Mads

Patch

diff --git a/mercurial/unionrepo.py b/mercurial/unionrepo.py
--- a/mercurial/unionrepo.py
+++ b/mercurial/unionrepo.py
@@ -15,7 +15,7 @@ 
 from i18n import _
 import os
 import util, mdiff, cmdutil, scmutil
-import localrepo, changelog, manifest, filelog, revlog
+import localrepo, changelog, manifest, filelog, revlog, phases
 
 class unionrevlog(revlog.revlog):
     def __init__(self, opener, indexfile, revlog2, linkmapper):
@@ -177,6 +177,12 @@ 
         self.repo2 = localrepo.localrepository(ui, path2)
 
     @localrepo.unfilteredpropertycache
+    def _phasecache(self):
+        cache = phases.phasecache(self, self._phasedefaults)
+        cache.union(phases.phasecache(self.repo2, self._phasedefaults))
+        return cache
+
+    @localrepo.unfilteredpropertycache
     def changelog(self):
         return unionchangelog(self.sopener, self.repo2.sopener)
 
diff --git a/tests/test-unionrepo.t b/tests/test-unionrepo.t
--- a/tests/test-unionrepo.t
+++ b/tests/test-unionrepo.t
@@ -148,3 +148,9 @@ 
   2:68c0685446a3  repo1-2
   1:8a58db72e69d  repo1-1
   0:f093fec0529b  repo1-0
+
+check the phase
+
+  $ hg -R union:repo1+repo2 phase -r 0:1
+  0: draft
+  1: draft