Mercurial > kallithea
changeset 2384:5563af834d92 beta
Added diff option into git and hg changeset objects, representing git formated patch against parent1
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Mon, 04 Jun 2012 17:26:34 +0200 |
parents | e576410f911d |
children | a455b2c79c85 |
files | rhodecode/lib/vcs/backends/git/changeset.py rhodecode/lib/vcs/backends/git/repository.py rhodecode/lib/vcs/backends/hg/changeset.py |
diffstat | 3 files changed, 16 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/rhodecode/lib/vcs/backends/git/changeset.py Mon Jun 04 03:55:28 2012 +0200 +++ b/rhodecode/lib/vcs/backends/git/changeset.py Mon Jun 04 17:26:34 2012 +0200 @@ -194,6 +194,11 @@ return _prev(self, branch) + def diff(self, ignore_whitespace=True, context=3): + return ''.join(self.repository.get_diff(self, self.parents[0], + ignore_whitespace=ignore_whitespace, + context=context)) + def get_file_mode(self, path): """ Returns stat mode of the file at the given ``path``.
--- a/rhodecode/lib/vcs/backends/git/repository.py Mon Jun 04 03:55:28 2012 +0200 +++ b/rhodecode/lib/vcs/backends/git/repository.py Mon Jun 04 17:26:34 2012 +0200 @@ -437,6 +437,12 @@ if ignore_whitespace: flags.append('-w') + if hasattr(rev1, 'raw_id'): + rev1 = getattr(rev1, 'raw_id') + + if hasattr(rev2, 'raw_id'): + rev2 = getattr(rev2, 'raw_id') + if rev1 == self.EMPTY_CHANGESET: rev2 = self.get_changeset(rev2).raw_id cmd = ' '.join(['show'] + flags + [rev2])
--- a/rhodecode/lib/vcs/backends/hg/changeset.py Mon Jun 04 03:55:28 2012 +0200 +++ b/rhodecode/lib/vcs/backends/hg/changeset.py Mon Jun 04 17:26:34 2012 +0200 @@ -136,6 +136,11 @@ return _prev(self, branch) + def diff(self, ignore_whitespace=True, context=3): + return ''.join(self._ctx.diff(git=True, + ignore_whitespace=ignore_whitespace, + context=context)) + def _fix_path(self, path): """ Paths are stored without trailing slash so we need to get rid off it if