def _update_tree_state_cache(self, path, tree_state): """ Update the state of the file(s) at tree_state['path'] """ while 1: try: # Update the index before getting status, otherwise we could # be reading stale status information _vc.popen(["git", "update-index", "--refresh"], cwd=self.location) # Get the status of files that are different in the "index" vs # the HEAD of the git repository proc = _vc.popen([self.CMD, "diff-index", "--name-status", \ "--cached", "HEAD", path], cwd=self.location) entries = proc.read().split("\n")[:-1] # Get the status of files that are different in the "index" vs # the files on disk proc = _vc.popen([self.CMD, "diff-files", "--name-status", \ "-0", path], cwd=self.location) entries += (proc.read().split("\n")[:-1]) proc = _vc.popen([self.CMD, "ls-files", "--others", \ "--ignored", "--exclude-standard", path], cwd=self.location) entries += ("I\t%s" % f for f in proc.read().split("\n")[:-1]) # An unmerged file or a file that has been modified, added to # git's index, then modified again would result in the file # showing up in both the output of "diff-files" and # "diff-index". The following command removes duplicate # file entries. entries = list(set(entries)) break except OSError, e: if e.errno != errno.EAGAIN: raise
def _lookup_tree_cache(self, rootdir): branch_root = _vc.popen([self.CMD, "root", rootdir]).read().rstrip('\n') while 1: try: proc = _vc.popen([self.CMD, "status", branch_root]) entries = proc.read().split("\n")[:-1] break except OSError, e: if e.errno != errno.EAGAIN: raise
def _get_dirsandfiles(self, directory, dirs, files): while 1: try: entries = _vc.popen([self.CMD, "status", "-A", "."], cwd=directory).read().split("\n")[:-1] break except OSError, e: if e.errno != errno.EAGAIN: raise
def _lookup_tree_cache(self, rootdir): while 1: try: entries = _vc.popen([self.CMD, "automate", "inventory"], cwd=self.root).read().split("\n")[:-1] break except OSError, e: if e.errno != errno.EAGAIN: raise
def _lookup_tree_cache(self, rootdir): while 1: try: entries = _vc.popen([self.CMD, "ls", "-l"], cwd=self.root).read().split("\n")[:-1] break except OSError, e: if e.errno != errno.EAGAIN: raise
def _lookup_tree_cache(self, rootdir): while 1: try: proc = _vc.popen([self.CMD, "status", "--untracked-files"], cwd=self.root) entries = proc.read().split("\n")[:-1] break except OSError, e: if e.errno != errno.EAGAIN: raise
def _update_tree_state_cache(self, path, tree_state): while 1: try: status_cmd = [self.CMD, "status", "-v", "--xml", path] tree = ElementTree.parse(_vc.popen(status_cmd)) break except OSError, e: if e.errno != errno.EAGAIN: raise
def _lookup_tree_cache(self, rootdir): whatsnew = {} commandline = [self.CMD, "changes", "-d", self.root] while 1: try: p = _vc.popen(commandline) break except OSError, e: if e.errno != errno.EAGAIN: raise
def _get_matches(self, directory): """return a list of tuples (file_path, status_code, revision)""" while 1: try: entries = _vc.popen([self.CMD, "status", "-Nv", directory]) break except OSError, e: if e.errno != errno.EAGAIN: raise
def _get_whatsnew(self, boring=False): whatsnew = {} commandline = [self.CMD, "whatsnew", "--summary", "-l", "--repodir=" + self.root] if boring: commandline.append("--boring") while 1: try: p = _vc.popen(commandline) break except OSError, e: if e.errno != errno.EAGAIN: raise
def _get_whatsnew(self, boring=False): whatsnew = {} commandline = [self.CMD, "whatsnew", "--summary", "-l" "--repodir="+self.root] if boring: commandline.append("--boring") while 1: try: p = _vc.popen(commandline) break except OSError, e: if e.errno != errno.EAGAIN: raise
def choose_monotone_version(self): try: # for monotone >= 0.26 self.VC_DIR = "_MTN" self.CMD = "mtn" self.interface_version = float(_vc.popen([self.CMD, "automate", "interface_version"]).read()) if self.interface_version > 9.0: print "WARNING: Unsupported interface version (please report any problems to the meld mailing list)" except (ValueError, OSError): # for monotone <= 0.25 self.VC_DIR = "MT" self.CMD = "monotone"
def choose_monotone_version(self): try: # for monotone >= 0.26 self.VC_DIR = "_MTN" self.CMD = "mtn" self.interface_version = float( _vc.popen([self.CMD, "automate", "interface_version"]).read()) if self.interface_version > 9.0: print "WARNING: Unsupported interface version (please report any problems to the meld mailing list)" except (ValueError, OSError): # for monotone <= 0.25 self.VC_DIR = "MT" self.CMD = "monotone"
def _get_dirsandfiles(self, directory, dirs, files): tree = self._get_tree_cache(directory) retfiles = [] retdirs = [] vcfiles = {} for path, state in tree.iteritems(): mydir, name = os.path.split(path) if path.endswith('/'): mydir, name = os.path.split(mydir) if mydir != directory: continue rev = "" while True: try: entries = _vc.popen([self.CMD, "finfo", "-s", path], cwd=self.root).read().split(" ", 1) # Process entries which have revision numbers. if entries[0] in ['renamed', 'edited', 'deleted', 'unchanged']: rev = entries[1].strip() break except OSError, e: if e.errno != errno.EAGAIN: raise options, tag = "", "" if path.endswith('/'): retdirs.append(_vc.Dir(path[:-1], name, state)) else: retfiles.append(_vc.File(path, name, state, rev, tag, options)) vcfiles[name] = 1
def _get_dirsandfiles(self, directory, dirs, files): tree = self._get_tree_cache(directory) retfiles = [] retdirs = [] vcfiles = {} for path, state in tree.iteritems(): mydir, name = os.path.split(path) if path.endswith('/'): mydir, name = os.path.split(mydir) if mydir != directory: continue rev = "" while True: try: entries = _vc.popen([self.CMD, "finfo", "-s", path], cwd=self.root).read().split(" ", 1) # Process entries which have revision numbers. if entries[0] in [ 'renamed', 'edited', 'deleted', 'unchanged' ]: rev = entries[1].strip() break except OSError, e: if e.errno != errno.EAGAIN: raise options, tag = "", "" if path.endswith('/'): retdirs.append(_vc.Dir(path[:-1], name, state)) else: retfiles.append(_vc.File(path, name, state, rev, tag, options)) vcfiles[name] = 1
def _update_tree_state_cache(self, path, tree_state): """ Update the state of the file(s) at tree_state['path'] """ while 1: try: # Update the index before getting status, otherwise we could # be reading stale status information _vc.popen(["git", "update-index", "--refresh"], cwd=self.location) # Get the status of files that are different in the "index" vs # the HEAD of the git repository proc = _vc.popen([self.CMD, "diff-index", "--name-status", \ "--cached", "HEAD", path], cwd=self.location) entries = proc.read().split("\n")[:-1] # Get the status of files that are different in the "index" vs # the files on disk proc = _vc.popen([self.CMD, "diff-files", "--name-status", \ "-0", path], cwd=self.location) entries += (proc.read().split("\n")[:-1]) # Identify ignored files proc = _vc.popen([self.CMD, "ls-files", "--others", \ "--ignored", "--exclude-standard", path], cwd=self.location) entries += ("I\t%s" % f for f in proc.read().split("\n")[:-1]) # Identify unversioned files proc = _vc.popen([self.CMD, "ls-files", "--others", \ "--exclude-standard", path], cwd=self.location) entries += ("?\t%s" % f for f in proc.read().split("\n")[:-1]) # An unmerged file or a file that has been modified, added to # git's index, then modified again would result in the file # showing up in both the output of "diff-files" and # "diff-index". The following command removes duplicate # file entries. entries = list(set(entries)) break except OSError, e: if e.errno != errno.EAGAIN: raise
def _get_matches(self, directory): entries = _vc.popen([self.CMD, "status"], cwd=directory).read() for line in entries.split("\n")[1:-1]: yield line[3:], line[0], ""