You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by jo...@apache.org on 2012/12/05 18:27:48 UTC

[8/34] git commit: [#5037] ticket:209 fix hg.commits paths handling

[#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 <je...@gmail.com>
Authored: Fri Nov 16 10:41:31 2012 +0000
Committer: Cory Johns <jo...@geek.net>
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