def rfc822(self):
"Format as an RFC822 timestamp."
return time.strftime("%a %d %b %Y %H:%M:%S", time.localtime(self.timestamp)) + " " + self.timezone
- def delta(self, other):
- return other.timestamp - self.timestamp
- def __str__(self):
- "Format as a git timestamp."
- return str(self.timestamp) + " " + self.timezone
- def __cmp__(self, other):
- return cmp(self.timestamp, other.timestamp)
class Attribution:
"Represents an attribution of a repo action to a person and time."
self.date = Date(person.strip().split("|")[2])
except (ValueError, IndexError):
raise FatalException("malformed attribution %s" % person)
- def __eq__(self, other):
- "Compare attributions after canonicalization."
- return (self.name == other.name
- and self.email == other.email
- and self.date == other.date)
- def __str__(self):
- return self.name + " <" + self.email + "> " + str(self.date)
class Blob:
"Represent a detached blob of data referenced by a mark."
self.color = None
def blobfile(self):
return self.repo.subdir() + "/blob-" + `id(self)` + "-" + self.mark
- def release(self):
- os.remove(self.blobfile())
- self.path = None # Marked for deletion
- def __str__(self):
- with open(self.blobfile()) as dp:
- content = dp.read()
- return "blob\nmark %s\ndata %d\n%s\n" % (self.mark, len(content), content)
class Tag:
"Represents an annotated tag."
self.committish = committish
self.tagger = tagger
self.comment = content
- self.color = None
- def __str__(self):
- st = "tag %s\nfrom %s\n" % (self.name, self.committish)
- if self.tagger:
- st += "tagger %s\n" % self.tagger
- st += "data %d\n%s\n" % (len(self.comment), self.comment,)
- return st
class Reset:
"Represents a branch creation."
self.branch = None # branch name
self.fileops = [] # blob and file operation list
self.properties = {} # commit properties (extension)
- def children(self):
- "Get a list of this commit's children."
- return filter(lambda e:self.mark in e.parent_marks,self.repo.commits())
- def parents(self):
- "Get a list of this commit's parents."
- return filter(lambda e:e.mark in self.parent_marks,self.repo.commits())
class Passthrough:
"Represents a passthrough line."
self.branches = set([])
self.import_line = 0
self.inline_count = 0
- self.preserve_set = set([])
- self.case_coverage = set([])
self.basedir = os.getcwd()
def cleanup(self):
nuke(self.subdir(), "rcs-fast-import: cleaning up %s" % self.subdir())
except KeyboardInterrupt:
nuke(self.subdir(), "rcs-fast-import: import interrupted, removing %s" % self.subdir())
raise KeyboardInterrupt
- def commits(self):
- "Return a list of the repository commit objects."
- return filter(lambda e: isinstance(e, Commit), self.events)
# Container emulation methods
def __len__(self):
return len(self.events)
raise FatalException("%s%s returned error." \
% (self.cmd, self.legend))
return False
+
def do_or_die(cmd, legend=""):
"Either execute a command or raise a fatal exception."
if legend: