Commits

Martin Geisler committed d8063b2

Add reason to changelog.hide

Comments (0)

Files changed (2)

 # User Martin Geisler <mg@aragost.com>
 # Date 1307118242 -7200
 # Node ID 548803925b1fcb2a63562439867f67b5a274caca
-# Parent  782b00a922bf44ffcf61f8e0106b7cd3629de390
+# Parent 33f620027b58c3c5fe9d0fbd9f759652519b427b
 changelog: add infrastructure for hiding changesets
 
 diff --git a/mercurial/changelog.py b/mercurial/changelog.py
 --- a/mercurial/changelog.py
 +++ b/mercurial/changelog.py
-@@ -107,6 +107,15 @@
+@@ -107,6 +107,29 @@
          self._realopener = opener
          self._delayed = False
          self._divert = False
-+        self._hidden = set()
++        self._hidden = {}
 +
-+    def hide(self, *revs):
-+        """Hide one or more revisions."""
-+        self._hidden.update(revs)
++    def hide(self, reason, *revs):
++        """Hide one or more revisions.
 +
-+    def hidden(self, rev):
++        reason: a string explaining why the changesets are hidden,
++        such as 'abandoned'.
++        """
++        self._hidden.setdefault(reason, set()).update(revs)
++
++    def show(self, reason, *revs):
++        """Show one or more revisions."""
++        self._hidden.get(reason, set()).difference_update(revs)
++
++    def hidden(self, rev, reason=None):
 +        """Is rev hidden?"""
-+        return rev in self._hidden
++        if reason:
++            return rev in self._hidden.get(reason, [])
++        else:
++            for reason in self._hidden:
++                if rev in self._hidden[reason]:
++                    return True
++            return False
  
      def delayupdate(self):
          "delay visibility of index updates to other readers"
      def extra(self):
          return self._changeset[5]
      def tags(self):
+diff --git a/tests/test-debugcomplete.t b/tests/test-debugcomplete.t
+--- a/tests/test-debugcomplete.t
++++ b/tests/test-debugcomplete.t
+@@ -194,7 +194,7 @@
+   export: output, switch-parent, rev, text, git, nodates
+   forget: include, exclude
+   init: ssh, remotecmd, insecure
+-  log: follow, follow-first, date, copies, keyword, rev, removed, only-merges, user, only-branch, branch, prune, patch, git, limit, no-merges, stat, style, template, include, exclude
++  log: follow, follow-first, date, copies, keyword, rev, removed, only-merges, user, only-branch, branch, prune, hidden, patch, git, limit, no-merges, stat, style, template, include, exclude
+   merge: force, tool, rev, preview
+   pull: update, force, rev, bookmark, branch, ssh, remotecmd, insecure
+   push: force, rev, bookmark, branch, new-branch, ssh, remotecmd, insecure
+hidden
 no-checkout
-hidden
 abandon-command
 abandoned-revset
 localrepo