def status(self, path=None): '''Return status of repository or file. Without file argument: returns status of the repository: :First column: working directory status (D: dirty / space) :Second column: index status (I: index dirty / space) :Third column: presence of untracked files (U: untracked files / space) :None: repository clean With file argument: returns status of this file. Output is equivalent to the first two columns of ``git status --porcelain`` (except for merge statuses as they are not supported by libgit2). ''' if path: gitd = git_directory(self.directory) # We need HEAD as without it using fugitive to commit causes the # current file’s status (and only the current file) to not be updated # for some reason I cannot be bothered to figure out. return get_file_status( directory=self.directory, dirstate_file=join(gitd, 'index'), file_path=path, ignore_file_name='.gitignore', get_func=self.do_status, create_watcher=self.create_watcher, extra_ignore_files=tuple( join(gitd, x) for x in ('logs/HEAD', 'info/exclude')), ) return self.do_status(self.directory, path)
def status(self, path=None): '''Return status of repository or file. Without file argument: returns status of the repository: :First column: working directory status (D: dirty / space) :Second column: index status (I: index dirty / space) :Third column: presence of untracked files (U: untracked files / space) :None: repository clean With file argument: returns status of this file. Output is equivalent to the first two columns of "git status --porcelain" (except for merge statuses as they are not supported by libgit2). ''' if path: gitd = git_directory(self.directory) # We need HEAD as without it using fugitive to commit causes the # current file's status (and only the current file) to not be updated # for some reason I cannot be bothered to figure out. return get_file_status( directory=self.directory, dirstate_file=os.path.join(gitd, 'index'), file_path=path, ignore_file_name='.gitignore', get_func=self.do_status, create_watcher=self.create_watcher, extra_ignore_files=tuple(os.path.join(gitd, x) for x in ('logs/HEAD', 'info/exclude')), ) return self.do_status(self.directory, path)
def do_status(directory, path, func): if path: gitd = os.path.join(directory, '.git') if os.path.isfile(gitd): with open(gitd, 'rb') as f: raw = f.read().partition(b':')[2].strip() gitd = os.path.abspath(os.path.join(directory, raw)) return get_file_status(directory, os.path.join(gitd, 'index'), path, '.gitignore', func, extra_ignore_files=('.git/info/exclude',)) return func(directory, path)
def do_status(directory, path, func): if path: gitd = git_directory(directory) # We need HEAD as without it using fugitive to commit causes the # current file's status (and only the current file) to not be updated # for some reason I cannot be bothered to figure out. return get_file_status( directory, os.path.join(gitd, 'index'), path, '.gitignore', func, extra_ignore_files=tuple(os.path.join(gitd, x) for x in ('logs/HEAD', 'info/exclude'))) return func(directory, path)
def do_status(directory, path, func): if path: gitd = os.path.join(directory, '.git') if os.path.isfile(gitd): with open(gitd, 'rb') as f: raw = f.read().partition(b':')[2].strip() gitd = os.path.abspath(os.path.join(directory, raw)) # We need HEAD as without it using fugitive to commit causes the # current file's status (and only the current file) to not be updated # for some reason I cannot be bothered to figure out. return get_file_status( directory, os.path.join(gitd, 'index'), path, '.gitignore', func, extra_ignore_files=tuple(os.path.join(gitd, x) for x in ('logs/HEAD', 'info/exclude'))) return func(directory, path)
def do_status(directory, path, func): if path: gitd = os.path.join(directory, '.git') if os.path.isfile(gitd): with open(gitd, 'rb') as f: raw = f.read().partition(b':')[2].strip() gitd = os.path.abspath(os.path.join(directory, raw)) return get_file_status(directory, os.path.join(gitd, 'index'), path, '.gitignore', func, extra_ignore_files=('.git/info/exclude', )) return func(directory, path)
def status(self, path=None): '''Return status of repository or file. Without file argument: returns status of the repository: :"D?": dirty (tracked modified files: added, removed, deleted, modified), :"?U": untracked-dirty (added, but not tracked files) :None: clean (status is empty) With file argument: returns status of this file: The status codes are those returned by bzr status -S ''' if path is not None: return get_file_status(self.directory, os.path.join(self.directory, '.bzr', 'checkout', 'dirstate'), path, '.bzrignore', self.do_status) return self.do_status(self.directory, path)
def status(self, path=None): '''Return status of repository or file. Without file argument: returns status of the repository: :"D?": dirty (tracked modified files: added, removed, deleted, modified), :"?U": untracked-dirty (added, but not tracked files) :None: clean (status is empty) With file argument: returns status of this file: "M"odified, "A"dded, "R"emoved, "D"eleted (removed from filesystem, but still tracked), "U"nknown, "I"gnored, (None)Clean. ''' if path: return get_file_status(self.directory, os.path.join(self.directory, '.hg', 'dirstate'), path, '.hgignore', self.do_status) return self.do_status(self.directory, path)
def status(self, path=None): '''Return status of repository or file. Without file argument: returns status of the repository: :"D?": dirty (tracked modified files: added, removed, deleted, modified), :"?U": untracked-dirty (added, but not tracked files) :None: clean (status is empty) With file argument: returns status of this file: The status codes are those returned by bzr status -S ''' if path is not None: return get_file_status( self.directory, os.path.join(self.directory, '.bzr', 'checkout', 'dirstate'), path, '.bzrignore', self.do_status) return self.do_status(self.directory, path)
def status(self, path=None): '''Return status of repository or file. Without file argument: returns status of the repository: :"D?": dirty (tracked modified files: added, removed, deleted, modified), :"?U": untracked-dirty (added, but not tracked files) :None: clean (status is empty) With file argument: returns status of this file: "M"odified, "A"dded, "R"emoved, "D"eleted (removed from filesystem, but still tracked), "U"nknown, "I"gnored, (None)Clean. ''' if path: return get_file_status( self.directory, os.path.join(self.directory, '.hg', 'dirstate'), path, '.hgignore', self.do_status) return self.do_status(self.directory, path)
def do_status(directory, path, func): if path: gitd = os.path.join(directory, '.git') if os.path.isfile(gitd): with open(gitd, 'rb') as f: raw = f.read().partition(b':')[2].strip() gitd = os.path.abspath(os.path.join(directory, raw)) # We need HEAD as without it using fugitive to commit causes the # current file's status (and only the current file) to not be updated # for some reason I cannot be bothered to figure out. return get_file_status(directory, os.path.join(gitd, 'index'), path, '.gitignore', func, extra_ignore_files=tuple( os.path.join(gitd, x) for x in ('logs/HEAD', 'info/exclude'))) return func(directory, path)
def status(self, path=None): """Return status of repository or file. Without file argument: returns status of the repository: :"D?": dirty (tracked modified files: added, removed, deleted, modified), :"?U": untracked-dirty (added, but not tracked files) :None: clean (status is empty) With file argument: returns status of this file: The status codes are those returned by bzr status -S """ if path is not None: return get_file_status( directory=self.directory, dirstate_file=os.path.join(self.directory, ".bzr", "checkout", "dirstate"), file_path=path, ignore_file_name=".bzrignore", get_func=self.do_status, create_watcher=self.create_watcher, ) return self.do_status(self.directory, path)
def status(self, path=None): '''Return status of repository or file. Without file argument: returns status of the repository: :'D?': dirty (tracked modified files: added, removed, deleted, modified), :'?U': untracked-dirty (added, but not tracked files) :None: clean (status is empty) With file argument: returns status of this file: The status codes are those returned by bzr status -S ''' if path is not None: return get_file_status( directory=self.directory, dirstate_file=join(self.directory, '.bzr', 'checkout', 'dirstate'), file_path=path, ignore_file_name='.bzrignore', get_func=self.do_status, create_watcher=self.create_watcher, ) return self.do_status(self.directory, path)
def status(self, path=None): '''Return status of repository or file. Without file argument: returns status of the repository: :'D?': dirty (tracked modified files: added, removed, deleted, modified), :'?U': untracked-dirty (added, but not tracked files) :None: clean (status is empty) With file argument: returns status of this file: `M`odified, `A`dded, `R`emoved, `D`eleted (removed from filesystem, but still tracked), `U`nknown, `I`gnored, (None)Clean. ''' if path: return get_file_status( directory=self.directory, dirstate_file=join(self.directory, '.hg', 'dirstate'), file_path=path, ignore_file_name='.hgignore', get_func=self.do_status, create_watcher=self.create_watcher, ) return self.do_status(self.directory, path)
def status_string(self, path=None): '''Return status of repository or file. Without file argument: returns status of the repository: :'D?': dirty (tracked modified files: added, removed, deleted, modified), :'?U': untracked-dirty (added, but not tracked files) :None: clean (status is empty) With file argument: returns status of this file: `M`odified, `A`dded, `R`emoved, `D`eleted (removed from filesystem, but still tracked), `U`nknown, `I`gnored, (None)Clean. ''' if path: return get_file_status( directory=self.directory, dirstate_file=join(self.directory, '.hg', 'dirstate'), file_path=path, ignore_file_name='.hgignore', get_func=self.do_status, create_watcher=self.create_watcher, ) return self.do_status(self.directory, path)
def status_string(self, path=None): '''Return status of repository or file. Without file argument: returns status of the repository: :'D?': dirty (tracked modified files: added, removed, deleted, modified), :'?U': untracked-dirty (added, but not tracked files) :None: clean (status is empty) With file argument: returns status of this file: The status codes are those returned by bzr status -S ''' if path is not None: return get_file_status( directory=self.directory, dirstate_file=join(self.directory, '.bzr', 'checkout', 'dirstate'), file_path=path, ignore_file_name='.bzrignore', get_func=self.do_status, create_watcher=self.create_watcher, ) return self.do_status(self.directory, path)