# HG changeset patch # User Greg Ward # Date 1238508604 14400 # Node ID 7e3d7dbe33861f5bcd08597085f61cca13a15c8f # Parent b2ee2f810f1e7249df1168ee32ac25246bd3ff21 Add __repr__() and __str__() to Command classes (for easier debugging). diff -r b2ee2f810f1e -r 7e3d7dbe3386 fastimport/commands.py --- a/fastimport/commands.py Wed Jul 16 13:04:41 2008 +0100 +++ b/fastimport/commands.py Tue Mar 31 10:10:04 2009 -0400 @@ -35,6 +35,12 @@ # List of field names not to display self._binary = [] + def __repr__(self): + return "<%s at %x: %s>" % (self.__class__.__name__, id(self), self) + + def __str__(self): + return self.name + def dump_str(self, names=None, child_lists=None, verbose=False): """Dump fields as a string. @@ -76,6 +82,9 @@ self.id = ':' + mark self._binary = ['data'] + def __str__(self): + return self.id + class CheckpointCommand(ImportCommand): @@ -104,6 +113,9 @@ else: self.id = ':' + mark + def __str__(self): + return "ref %s, mark %s" % (self.ref, self.mark) + def dump_str(self, names=None, child_lists=None, verbose=False): result = [ImportCommand.dump_str(self, names, verbose=verbose)] for f in self.file_iter(): @@ -141,6 +153,9 @@ self.tagger = tagger self.message = message + def __str__(self): + return self.id + class FileCommand(ImportCommand): """Base class for file commands.""" @@ -159,6 +174,9 @@ self.data = data self._binary = ['data'] + def __str__(self): + return self.path + class FileDeleteCommand(FileCommand): @@ -166,6 +184,9 @@ FileCommand.__init__(self, 'filedelete') self.path = path + def __str__(self): + return self.path + class FileCopyCommand(FileCommand): @@ -174,6 +195,9 @@ self.src_path = src_path self.dest_path = dest_path + def __str__(self): + return "%s -> %s" % (self.src_path, self.dest_path) + class FileRenameCommand(FileCommand): @@ -182,6 +206,9 @@ self.old_path = old_path self.new_path = new_path + def __str__(self): + return "%s -> %s" % (self.old_path, self.new_path) + class FileDeleteAllCommand(FileCommand):