Patchwork D1011: localrepo: add a _pinnedrevs attribute

login
register
mail settings
Submitter phabricator
Date Oct. 11, 2017, 7:10 p.m.
Message ID <differential-rev-PHID-DREV-b3sbkiyfkfotnro7h4zg-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/24751/
State Superseded
Headers show

Comments

phabricator - Oct. 11, 2017, 7:10 p.m.
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  We have repoview.pinnedrevs() which take a repository object and returns the
  hidden revisions which should not be filtered. To add more hidden revisions to
  prevent them from getting obsoleted, we need to wrap the pinnedrevs function.
  
  This patch adds repo._pinnedrevs which can be updated with the revisions which
  needs to be prevented from being filtered. After this patch
  repoview.pinnedrevs() updates repo._pinnedrevs and returns it.
  
  The functionality to add commits to _pinnedrevs without wrapping the function
  will be very helpful is adding support for accessing hidden commits.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1011

AFFECTED FILES
  mercurial/localrepo.py
  mercurial/repoview.py

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: mercurial-devel
phabricator - Oct. 12, 2017, 7:02 a.m.
dlax added inline comments.

INLINE COMMENTS

> repoview.py:38
>      pinned.update([par.rev() for par in repo[None].parents()])
>      pinned.update([cl.rev(bm) for bm in repo._bookmarks.values()])
>  

Updating a "private" attribute of an object outside the class is not nice.
Not sure about "our" common practice in this case, but maybe this could be handled through a property?

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1011

To: pulkit, #hg-reviewers
Cc: dlax, mercurial-devel
phabricator - Oct. 12, 2017, 5:28 p.m.
pulkit added inline comments.

INLINE COMMENTS

> dlax wrote in repoview.py:38
> Updating a "private" attribute of an object outside the class is not nice.
> Not sure about "our" common practice in this case, but maybe this could be handled through a property?

Hm, I will turn that attribute to public in next version.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1011

To: pulkit, #hg-reviewers
Cc: dlax, mercurial-devel
phabricator - Oct. 17, 2017, 12:22 p.m.
pulkit abandoned this revision.
pulkit added a comment.


  Resend the series as https://phab.mercurial-scm.org/D1140 - https://phab.mercurial-scm.org/D1144.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1011

To: pulkit, #hg-reviewers
Cc: dlax, mercurial-devel

Patch

diff --git a/mercurial/repoview.py b/mercurial/repoview.py
--- a/mercurial/repoview.py
+++ b/mercurial/repoview.py
@@ -33,7 +33,7 @@ 
     """
 
     cl = repo.changelog
-    pinned = set()
+    pinned = repo._pinnedrevs
     pinned.update([par.rev() for par in repo[None].parents()])
     pinned.update([cl.rev(bm) for bm in repo._bookmarks.values()])
 
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -505,6 +505,9 @@ 
         # generic mapping between names and nodes
         self.names = namespaces.namespaces()
 
+        # a set of hidden revisions which should not be filtered
+        self._pinnedrevs = set()
+
         # Key to signature value.
         self._sparsesignaturecache = {}
         # Signature to cached matcher instance.