Ok, I've managed to hack up a quick fix for this, but... It does look a
bit ugly. Feels like there's too much repetitive code in there as well.
The patch is attached to the mail.

Looking at what the server does when you pass in a path that is
directory in both changesets, it really should not throw an internal
error for it. It should probably just do a diff on two changesets that
are basically empty (like the whole NodeDoesNotExistError handling), or
try to display some form of information to user (or maybe give a 404 or
something similar).

So, before I start delving into this with proper patch, any opinions on
it? :)

Best regards,
Branko

-- 
Branko Majic
XMPP: bra...@majic.rs
Please use only Free formats when sending attachments to me.

Бранко Мајић
XMPP: bra...@majic.rs
Молим вас да додатке шаљете искључиво у слободним форматима.
diff --git a/kallithea/controllers/files.py b/kallithea/controllers/files.py
--- a/kallithea/controllers/files.py
+++ b/kallithea/controllers/files.py
@@ -657,9 +657,6 @@
                 c.changeset_1 = c.db_repo_scm_instance.get_changeset(diff1)
                 try:
                     node1 = c.changeset_1.get_node(f_path)
-                    if node1.is_dir():
-                        raise NodeError('%s path is a %s not a file'
-                                        % (node1, type(node1)))
                 except NodeDoesNotExistError:
                     c.changeset_1 = EmptyChangeset(cs=diff1,
                                                    revision=c.changeset_1.revision,
@@ -673,9 +670,6 @@
                 c.changeset_2 = c.db_repo_scm_instance.get_changeset(diff2)
                 try:
                     node2 = c.changeset_2.get_node(f_path)
-                    if node2.is_dir():
-                        raise NodeError('%s path is a %s not a file'
-                                        % (node2, type(node2)))
                 except NodeDoesNotExistError:
                     c.changeset_2 = EmptyChangeset(cs=diff2,
                                                    revision=c.changeset_2.revision,
@@ -684,6 +678,24 @@
             else:
                 c.changeset_2 = EmptyChangeset(repo=c.db_repo_scm_instance)
                 node2 = FileNode(f_path, '', changeset=c.changeset_2)
+
+            if node1.is_dir() and node2.is_dir():
+                raise NodeError('%s path is a %s not a file'
+                                % (node2, type(node2)))
+
+            if node1.is_dir():
+                c.changeset_1 = EmptyChangeset(cs=diff1,
+                                               revision=c.changeset_1.revision,
+                                               repo=c.db_repo_scm_instance)
+                node1 = FileNode(f_path, '', changeset=c.changeset_1)
+
+            if node2.is_dir():
+                c.changeset_2 = EmptyChangeset(cs=diff2,
+                                               revision=c.changeset_2.revision,
+                                               repo=c.db_repo_scm_instance)
+                node2 = FileNode(f_path, '', changeset=c.changeset_2)
+
+
         except ChangesetDoesNotExistError as e:
             msg = _('Such revision does not exist for this repository')
             webutils.flash(msg, category='error')

Attachment: pgpTxNQi7Uafp.pgp
Description: OpenPGP digital signature

_______________________________________________
kallithea-general mailing list
kallithea-general@sfconservancy.org
https://lists.sfconservancy.org/mailman/listinfo/kallithea-general

Reply via email to