From 4f149daaccb06676dd34cf9eb8e1ee425418b854 Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Thu, 1 Nov 2018 10:29:13 -0700 Subject: [PATCH] filter-repo: aid debugging with a string representation of several classes Signed-off-by: Elijah Newren --- git-filter-repo | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/git-filter-repo b/git-filter-repo index d50d027..6c523de 100755 --- a/git-filter-repo +++ b/git-filter-repo @@ -16,6 +16,7 @@ import collections import fnmatch import os import re +import StringIO import subprocess import sys import time @@ -237,6 +238,18 @@ class _GitElement(object): """ raise SystemExit("Unimplemented function: %s.dump()" % type(self).__name__) + def __str__(self): + """ + Convert GitElement to string; used for debugging + """ + old_dumped = self.dumped + writeme = StringIO.StringIO() + self.dump(writeme) + output_lines = writeme.getvalue().splitlines() + writeme.close() + self.dumped = old_dumped + return "{}:\n {}".format(type(self).__name__, "\n ".join(output_lines)) + def skip(self, new_id=None): """ Ensures this element will not be written to output