Return-Path: X-Original-To: apmail-incubator-allura-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-allura-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id AAC5BED9F for ; Wed, 5 Dec 2012 17:27:52 +0000 (UTC) Received: (qmail 1534 invoked by uid 500); 5 Dec 2012 17:27:52 -0000 Delivered-To: apmail-incubator-allura-commits-archive@incubator.apache.org Received: (qmail 1445 invoked by uid 500); 5 Dec 2012 17:27:51 -0000 Mailing-List: contact allura-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: allura-dev@incubator.apache.org Delivered-To: mailing list allura-commits@incubator.apache.org Received: (qmail 1094 invoked by uid 99); 5 Dec 2012 17:27:48 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 Dec 2012 17:27:48 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 1618D818D93; Wed, 5 Dec 2012 17:27:48 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: johnsca@apache.org To: allura-commits@incubator.apache.org X-Mailer: ASF-Git Admin Mailer Subject: [8/34] git commit: [#5037] ticket:209 fix hg.commits paths handling Message-Id: <20121205172748.1618D818D93@tyr.zones.apache.org> Date: Wed, 5 Dec 2012 17:27:48 +0000 (UTC) [#5037] ticket:209 fix hg.commits paths handling Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/e13fd336 Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/e13fd336 Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/e13fd336 Branch: refs/heads/cj/4691 Commit: e13fd336890b798888dbd4a95aee8d10f144a4c7 Parents: a33bfe7 Author: Igor Bondarenko Authored: Fri Nov 16 10:41:31 2012 +0000 Committer: Cory Johns Committed: Mon Dec 3 23:56:30 2012 +0000 ---------------------------------------------------------------------- Allura/allura/controllers/repository.py | 4 +- ForgeHg/forgehg/model/hg.py | 38 +++++++++++++++++++------- 2 files changed, 30 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e13fd336/Allura/allura/controllers/repository.py ---------------------------------------------------------------------- diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py index b4a852c..7a61445 100644 --- a/Allura/allura/controllers/repository.py +++ b/Allura/allura/controllers/repository.py @@ -428,8 +428,8 @@ class CommitBrowser(BaseController): limit=validators.Int(if_empty=25))) def log(self, limit=25, page=0, path=None, **kw): limit, page, start = g.handle_paging(limit, page, default=25) - if path and path[0] == "/": - path = path[1:] + if path: + path = path.lstrip('/') params = dict(path=path, rev=self._commit._id) commits = c.app.repo.commits(skip=start, limit=limit, **params) count = c.app.repo.commits_count(**params) http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e13fd336/ForgeHg/forgehg/model/hg.py ---------------------------------------------------------------------- diff --git a/ForgeHg/forgehg/model/hg.py b/ForgeHg/forgehg/model/hg.py index 4526078..32dfa8c 100644 --- a/ForgeHg/forgehg/model/hg.py +++ b/ForgeHg/forgehg/model/hg.py @@ -294,14 +294,23 @@ class HgImplementation(M.RepositoryImplementation): def commits(self, path=None, rev=None, skip=None, limit=None): if skip is None: skip = 0 - if path is not None: - path = os.path.join(self._repo.full_fs_path, path) - m = cmdutil.match(self._hg, [path]) + if path: + opts = {'pats': [path], 'default': 'path'} else: - m = cmdutil.match(self._hg) + opts = {} + try: + m = cmdutil.match(self._hg, **opts) + except Exception, e: + log.exception(e) + return [] revs = [] opts = {'rev': ['%s:0' % rev] if rev is not None else rev} - for ctx in cmdutil.walkchangerevs(self._hg, m, opts, lambda *a: None): + try: + revs_iter = cmdutil.walkchangerevs(self._hg, m, opts, lambda *a: None) + except Exception, e: + log.exception(e) + return [] + for ctx in revs_iter: if limit and limit == len(revs): return revs if skip == 0: @@ -311,14 +320,23 @@ class HgImplementation(M.RepositoryImplementation): return revs def commits_count(self, path=None, rev=None): - if path is not None: - path = os.path.join(self._repo.full_fs_path, path) - m = cmdutil.match(self._hg, [path]) + if path: + opts = {'pats': [path], 'default': 'path'} else: - m = cmdutil.match(self._hg) + opts = {} + try: + m = cmdutil.match(self._hg, **opts) + except Exception, e: + log.exception(e) + return 0 opts = {'rev': ['%s:0' % rev] if rev is not None else rev} + try: + revs_iter = cmdutil.walkchangerevs(self._hg, m, opts, lambda *a: None) + except Exception, e: + log.exception(e) + return 0 count = 0 - for ctx in cmdutil.walkchangerevs(self._hg, m, opts, lambda *a: None): + for ctx in revs_iter: count += 1 return count