[PATCH] git: don't show errors when two heads are unrelated

Mads Kiilerich mads at kiilerich.com
Sun Jul 9 11:03:30 UTC 2017


That seems like a tricky case. Could we get test coverage?

Mads


On 9 Jul 2017 3:29 am, "Andrew Shadura" <andrew at shadura.me> wrote:

# HG changeset patch
# User Andrew Shadura <andrew at shadura.me>
# Date 1499563683 18000
#      Sat Jul 08 20:28:03 2017 -0500
# Node ID 2e81b5a48ffb50115e25b9b9eedb959aeedcecda
# Parent  cf3d4094791c2108392d7f76d958cd08a9c523f3
git: don't show errors when two heads are unrelated

When two heads belong to different parallel timelines, git merge-base exits
with an error code (this isn't mentioned in the manual page). It's better to
just say to the user there are no changesets to pull, which gives the user a
hint they can't do what they're trying to do, instead of just a word
"error",
which is confusing and not helpful at all.

diff --git a/kallithea/controllers/compare.py b/kallithea/controllers/
compare.py
--- a/kallithea/controllers/compare.py
+++ b/kallithea/controllers/compare.py
@@ -45,6 +45,7 @@ from kallithea.model.db import Repositor
 from kallithea.lib.diffs import LimitedDiffContainer
 from kallithea.controllers.changeset import _ignorews_url, _context_url
 from kallithea.lib.graphmod import graph_data
+from kallithea.lib.vcs.exceptions import RepositoryError

 log = logging.getLogger(__name__)

@@ -161,10 +162,13 @@ class CompareController(BaseRepoControll
                 )
                 other_changesets = [org_repo.get_changeset(cs)
                               for cs in re.findall(r'[0-9a-fA-F]{40}', so)]
-                so, se = org_repo.run_git_command(
-                    ['merge-base', org_rev, other_rev]
-                )
-                ancestors = [re.findall(r'[0-9a-fA-F]{40}', so)[0]]
+                try:
+                    so, se = org_repo.run_git_command(
+                        ['merge-base', org_rev, other_rev]
+                    )
+                except RepositoryError:
+                    other_changesets = []
+                ancestors = [re.findall(r'[0-9a-fA-F]{40}', so)[:1]]
             org_changesets = []

         else:
_______________________________________________
kallithea-general mailing list
kallithea-general at sfconservancy.org
https://lists.sfconservancy.org/mailman/listinfo/kallithea-general
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sfconservancy.org/pipermail/kallithea-general/attachments/20170709/3992c573/attachment.html>


More information about the kallithea-general mailing list