Submitter | Stanislau Hlebik |
---|---|
Date | Aug. 23, 2016, 10:22 a.m. |
Message ID | <a7c8796d3636837bc90c.1471947762@dev1918.lla1.facebook.com> |
Download | mbox | patch |
Permalink | /patch/16392/ |
State | Accepted |
Headers | show |
Comments
On 08/23/2016 12:22 PM, Stanislau Hlebik wrote: > # HG changeset patch > # User Stanislau Hlebik <stash@fb.com> > # Date 1471003467 25200 > # Fri Aug 12 05:04:27 2016 -0700 > # Node ID a7c8796d3636837bc90c2bc3712a0da5e44ebe75 > # Parent 37b6f0ec6241a62de90737409458cd622e2fac0d > listkeypattern: add pattern parameter to listkeys There is no reason for listkey to gain a pattern argument here. The only planned user of this is bookmark (and it is out or core). So we'll extend bundle2 with bookmark specific capability and extend that. That does not requires to extend listkey and we should therefore refrain to do so. Cheers,
Patch
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -1907,10 +1907,21 @@ self._afterlock(runhook) return ret - def listkeys(self, namespace): + def listkeys(self, namespace, patterns=None): self.hook('prelistkeys', throw=True, namespace=namespace) self.ui.debug('listing keys for "%s"\n' % namespace) values = pushkey.list(self, namespace) + if patterns: + matchers = [] + for pattern in patterns: + kind, p, matcher = util.stringmatcher(pattern) + matchers.append(matcher) + filtered = {} + for key, value in values.iteritems(): + if any(m for m in matchers if m(key)): + filtered[key] = value + values = filtered + self.hook('listkeys', namespace=namespace, values=values) return values