changeset 8117:1bc843007746

vcs: drop GitChangeset.id It seems to be like raw_id, except the odd feature that it sometimes would return 'tip'.
author Mads Kiilerich <mads@kiilerich.com>
date Wed, 25 Dec 2019 15:16:39 +0100
parents e4f743999d5c
children 5c4074db01d3
files kallithea/lib/annotate.py kallithea/lib/vcs/backends/base.py kallithea/lib/vcs/backends/git/changeset.py kallithea/lib/vcs/backends/hg/changeset.py kallithea/tests/vcs/test_changesets.py kallithea/tests/vcs/test_inmemchangesets.py
diffstat 6 files changed, 9 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/lib/annotate.py	Thu Jan 02 22:18:59 2020 +0100
+++ b/kallithea/lib/annotate.py	Wed Dec 25 15:16:39 2019 +0100
@@ -69,7 +69,7 @@
 
             def changeset_to_anchor(changeset):
                 return '<a href="/changesets/%s/">%s</a>\n' % \
-                       (changeset.id, changeset.id)
+                       (changeset.raw_id, changeset.raw_id)
 
         :param annotate_from_changeset_func: see above
         :param order: (default: ``['ls', 'annotate', 'code']``); order of
--- a/kallithea/lib/vcs/backends/base.py	Thu Jan 02 22:18:59 2020 +0100
+++ b/kallithea/lib/vcs/backends/base.py	Wed Dec 25 15:16:39 2019 +0100
@@ -320,9 +320,6 @@
         ``repository``
             repository object within which changeset exists
 
-        ``id``
-            may be ``raw_id`` or i.e. for mercurial's tip just ``tip``
-
         ``raw_id``
             raw changeset representation (i.e. full 40 length sha for git
             backend)
@@ -414,13 +411,6 @@
         raise NotImplementedError
 
     @LazyProperty
-    def id(self):
-        """
-        Returns string identifying this changeset.
-        """
-        raise NotImplementedError
-
-    @LazyProperty
     def raw_id(self):
         """
         Returns raw string identifying this changeset.
@@ -650,7 +640,7 @@
         """
         Returns dictionary with changeset's attributes and their values.
         """
-        data = get_dict_for_attrs(self, ['id', 'raw_id', 'short_id',
+        data = get_dict_for_attrs(self, ['raw_id', 'short_id',
             'revision', 'date', 'message'])
         data['author'] = {'name': self.author_name, 'email': self.author_email}
         data['added'] = [safe_unicode(node.path) for node in self.added]
--- a/kallithea/lib/vcs/backends/git/changeset.py	Thu Jan 02 22:18:59 2020 +0100
+++ b/kallithea/lib/vcs/backends/git/changeset.py	Wed Dec 25 15:16:39 2019 +0100
@@ -32,7 +32,6 @@
         except KeyError:
             raise RepositoryError("Cannot get object with id %s" % revision)
         self.raw_id = ascii_str(commit.id)
-        self.id = self.raw_id
         self.short_id = self.raw_id[:12]
         self._commit = commit  # a Dulwich Commmit with .id
         self._tree_id = commit.tree
@@ -289,16 +288,15 @@
         iterating commits.
         """
         self._get_filectx(path)
-        cs_id = safe_str(self.id)
         f_path = safe_str(path)
 
         if limit is not None:
             cmd = ['log', '-n', str(safe_int(limit, 0)),
-                   '--pretty=format:%H', '-s', cs_id, '--', f_path]
+                   '--pretty=format:%H', '-s', self.raw_id, '--', f_path]
 
         else:
             cmd = ['log',
-                   '--pretty=format:%H', '-s', cs_id, '--', f_path]
+                   '--pretty=format:%H', '-s', self.raw_id, '--', f_path]
         so = self.repository.run_git_command(cmd)
         ids = re.findall(r'[0-9a-fA-F]{40}', so)
         return [self.repository.get_changeset(sha) for sha in ids]
@@ -311,7 +309,7 @@
         """
         self._get_filectx(path)
         from dulwich.walk import Walker
-        include = [self.id]
+        include = [self.raw_id]
         walker = Walker(self.repository._repo.object_store, include,
                         paths=[path], max_entries=1)
         return [self.repository.get_changeset(ascii_str(x.commit.id.decode))
@@ -325,7 +323,7 @@
         # TODO: This function now uses os underlying 'git' command which is
         # generally not good. Should be replaced with algorithm iterating
         # commits.
-        cmd = ['blame', '-l', '--root', '-r', self.id, '--', path]
+        cmd = ['blame', '-l', '--root', '-r', self.raw_id, '--', path]
         # -l     ==> outputs long shas (and we need all 40 characters)
         # --root ==> doesn't put '^' character for boundaries
         # -r sha ==> blames for the given revision
--- a/kallithea/lib/vcs/backends/hg/changeset.py	Thu Jan 02 22:18:59 2020 +0100
+++ b/kallithea/lib/vcs/backends/hg/changeset.py	Wed Dec 25 15:16:39 2019 +0100
@@ -134,12 +134,6 @@
         return self._dir_paths + self._file_paths
 
     @LazyProperty
-    def id(self):
-        if self.last:
-            return u'tip'
-        return self.short_id
-
-    @LazyProperty
     def short_id(self):
         return self.raw_id[:12]
 
--- a/kallithea/tests/vcs/test_changesets.py	Thu Jan 02 22:18:59 2020 +0100
+++ b/kallithea/tests/vcs/test_changesets.py	Wed Dec 25 15:16:39 2019 +0100
@@ -15,7 +15,6 @@
 
     def test_as_dict(self):
         changeset = BaseChangeset()
-        changeset.id = 'ID'
         changeset.raw_id = 'RAW_ID'
         changeset.short_id = 'SHORT_ID'
         changeset.revision = 1009
@@ -26,7 +25,6 @@
         changeset.changed = []
         changeset.removed = []
         assert changeset.as_dict() == {
-            'id': 'ID',
             'raw_id': 'RAW_ID',
             'short_id': 'SHORT_ID',
             'revision': 1009,
--- a/kallithea/tests/vcs/test_inmemchangesets.py	Thu Jan 02 22:18:59 2020 +0100
+++ b/kallithea/tests/vcs/test_inmemchangesets.py	Wed Dec 25 15:16:39 2019 +0100
@@ -153,7 +153,7 @@
 
         newtip = self.repo.get_changeset()
         assert tip != newtip
-        assert tip.id != newtip.id
+        assert tip.raw_id != newtip.raw_id
         assert newtip.get_node('foo/bar/baz').content == b'My **changed** content'
 
     def test_change_non_ascii(self):
@@ -179,7 +179,7 @@
 
         newtip = self.repo.get_changeset()
         assert tip != newtip
-        assert tip.id != newtip.id
+        assert tip.raw_id != newtip.raw_id
 
         assert newtip.get_node('żółwik/zwierzątko').content == b'My **changed** content'
         assert newtip.get_node('żółwik/zwierzątko_uni').content == b'My **changed** content'
@@ -237,7 +237,7 @@
 
         newtip = self.repo.get_changeset()
         assert tip != newtip
-        assert tip.id != newtip.id
+        assert tip.raw_id != newtip.raw_id
         with pytest.raises(NodeDoesNotExistError):
             newtip.get_node(node.path)