def diff_file(self, revision, file_ext="old"): """Compare the current version of file with the given revision. The referenced file will have a name ending with file_ext""" if not self.rcs_dir: return local = self.local_checkout(revision) file_ext = file_ext.replace("/", ".").replace(":", "-") local2 = os.path.basename(local) + " " + file_ext local2 = os.path.join(self.rcs_dir, local2) shutil.move(local, local2) Vdiff.create(File(local2), File(self.file)) try: os.chmod(local2, 0o777) os.unlink(local2) except Exception: pass
def onclick(self, text): matched = re.match(file_line_re, text) buffer = EditorBuffer.get(File(matched.group(2))) MDI.get_by_child(buffer.current_view()).raise_window() line = int(matched.group(3)) column = matched.group(5) if column is not None: buffer.current_view().goto(buffer.at(line, int(column))) else: buffer.current_view().goto(buffer.at(line, 1))
def revert_file(self, revision): """Revert file to a local history revision""" if not self.rcs_dir: return Logger("LocalHist").log("revert " + self.file + " to " + revision) local = self.local_checkout(revision) if local: shutil.copymode(self.file, local) shutil.move(local, self.file) EditorBuffer.get(File(self.file), force=True)
def on_file_edited(hook, file): name = file.path l = len(name) # If the file that has been opened is not a changelog, return. if (name[l - 4:l] != '$log'): return # Get the basename of the log file to find the actual source. basename = name[max(name.rfind('\\'), name.rfind('/')) + 1:l - 4] # Eliminate potential $x trailing trail = basename.rfind('$') if trail != -1: basename = basename[0:trail] source = File(basename) buffer = EditorBuffer.get(source, False, False) log = EditorBuffer.get(file, False, False) # If the log is not empty, exit. if log.get_chars() != '': return # Query the Locations View for a list of visual differences for the source locations = Locations.list_locations("Visual differences", basename) prev = "" # Find out which is the "enclosing" program/package. loc = buffer.at(buffer.lines_count() - 1, 1) global_proc = loc.subprogram_name() i = 0 while i < len(locations) / 2: loc = buffer.at(locations[2 * i].line(), locations[2 * i].column()) prog = loc.subprogram_name() # If there are multiple changes within the same subprogram, display # the subprogram only once if (prog != prev) and (prog != global_proc): log.insert(log.end_of_buffer(), "(" + prog + "): \n") prev = prog i = i + 1 # Jump to the end of the first line log.current_view().goto(log.at(1, 1).end_of_line())
def on_node_clicked(self, node_name, attrs, value): attr = self.parse_attrs(attrs) if node_name == "project" or node_name == "dependency": EditorBuffer.get(File(attr["name"] + ".gpr")) elif node_name == "file": EditorBuffer.get(File(attr["src"]))