def dirty(repo, filepath): if not hasattr(repo, '__getitem__'): vim_throw('statuns', repo.path) m=match.match(None, None, [filepath], exact=True) status=repo.status(match=m, unknown=True) if any(status[:-2]): vim.command('let r=1')
def update(repo, rev='tip', force=False): if not hasattr(repo, '__getitem__'): vim_throw('upduns', repo.path) rev = g_cs(repo, rev).hex() args = [repo.ui, repo, rev] kwargs = {'clean': bool(force)} run_in_dir(repo.root, commands.update, *args, **kwargs)
def dirty(repo, filepath): if not hasattr(repo, '__getitem__'): vim_throw('statuns', repo.path) m = match.match(None, None, [filepath], exact=True) status = repo.status(match=m, unknown=True) if any(status[:-2]): vim.command('let r=1')
def update(repo, rev='tip', force=False): if not hasattr(repo, '__getitem__'): vim_throw('upduns', repo.path) rev=g_cs(repo, rev).hex() args=[repo.ui, repo, rev] kwargs={'clean': bool(force)} run_in_dir(repo.root, commands.update, *args, **kwargs)
def get_status(repo, rev1=None, rev2=None, files=None, clean=None, ignored=None): if rev1 is None and rev2 is None: rev1 = '.' if hasattr(repo, 'status'): if not files: m = None else: m = match.match(None, None, files, exact=True) status = repo.status(rev1, rev2, match=m, clean=clean, ignored=ignored, unknown=True) return { 'modified': status[0], 'added': status[1], 'removed': status[2], 'deleted': status[3], 'unknown': status[4], 'ignored': status[5], 'clean': status[6], } else: vim_throw('statuns', repo.path)
def g_revid(repo, rev): try: if isinstance(rev, int) or isinstance(rev, long): return repo.branch.get_rev_id(rev) else: return RevisionSpec.from_string(rev).in_history(repo.branch).rev_id except (NoSuchRevision, InvalidRevisionSpec): vim_throw('norev', rev, repo.basedir)
def g_revid(repo, rev): try: if isinstance(rev, int) or isinstance(rev, long): return repo.branch.get_rev_id(rev) else: return RevisionSpec.from_string(rev).in_history(repo.branch).rev_id except (NoSuchRevision, InvalidRevisionSpec): vim_throw('norev', rev, repo.basedir)
def dodiff(ui, repo, rev1, rev2, files, opts): if not hasattr(repo, '__getitem__'): vim_throw('diffuns', repo.path) args = [ui, repo] + files kwargs = opts if rev2: kwargs['rev'] = [rev2] if rev1: kwargs['rev'].append(rev1) else: if rev1: kwargs['change'] = rev1 run_in_dir(repo.root, commands.diff, *args, **kwargs)
def dodiff(ui, repo, rev1, rev2, files, opts): if not hasattr(repo, '__getitem__'): vim_throw('diffuns', repo.path) args=[ui, repo]+files kwargs=opts if rev2: kwargs['rev']=[rev2] if rev1: kwargs['rev'].append(rev1) else: if rev1: kwargs['change']=rev1 run_in_dir(repo.root, commands.diff, *args, **kwargs)
def g_cs(repo, rev): try: # TODO Check this. Currently it works only in development branch r = repo.revparse_single(rev) except Exception: # FIXME be more specific vim_throw('norev', rev, repo.path) while not isinstance(r, git.Commit): if isinstance(r, git.Tag): r = repo[r.target] else: vim_throw('uresrev', repr(r), rev, repo.path) return r
def get_branch(repo): try: ref = repo.lookup_reference('HEAD') except KeyError: vim_throw('nohead', path) try: target = ref.target except ValueError: return '' if isinstance(target, (str, unicode)) and target.startswith('refs/heads/'): return target[11:] else: return ''
def get_branch(repo): try: ref = repo.lookup_reference('HEAD') except KeyError: vim_throw('nohead', path) try: target = ref.target except ValueError: return '' if target.startswith('refs/heads/'): return target[11:] else: return ''
def get_status(repo, rev1=None, rev2=None, files=None, clean=None, ignored=None): if rev1 is None and rev2 is None: rev1='.' if hasattr(repo, 'status'): if not files: m=None else: m=match.match(None, None, files, exact=True) status=repo.status(rev1, rev2, match=m, clean=clean, ignored=ignored, unknown=True) return {'modified': status[0], 'added': status[1], 'removed': status[2], 'deleted': status[3], 'unknown': status[4], 'ignored': status[5], 'clean': status[6],} else: vim_throw('statuns', repo.path)
def git_hash(repo, rev): hggitpath = None hggitname = None for hggitname in ['hggit', 'git']: hggitpath = repo.ui.config('extensions', hggitname) if hggitpath is not None: break if hggitpath is None: vim_throw('nohggitc') import sys sys.path.insert(0, hggitpath) try: try: if hggitname == 'hggit': from hggit.git_handler import GitHandler elif hggitname == 'git': from git.git_handler import GitHandler except ImportError: vim_throw('nohggit') git = GitHandler(repo, repo.ui) cs = g_cs(repo, rev) r = git.map_git_get(cs.hex()) if r is None: vim_throw('nogitrev', cs.hex(), repo.path) return {'git_hex': r} finally: sys.path.pop(0)
def git_hash(repo, rev): hggitpath=None hggitname=None for hggitname in ['hggit', 'git']: hggitpath=repo.ui.config('extensions', hggitname) if hggitpath is not None: break if hggitpath is None: vim_throw('nohggitc') import sys sys.path.insert(0, hggitpath) try: try: if hggitname=='hggit': from hggit.git_handler import GitHandler elif hggitname=='git': from git.git_handler import GitHandler except ImportError: vim_throw('nohggit') git=GitHandler(repo, repo.ui) cs=g_cs(repo, rev) r=git.map_git_get(cs.hex()) if r is None: vim_throw('nogitrev', cs.hex(), repo.path) return {'git_hex': r} finally: sys.path.pop(0)
def g_cs(repo, rev): if hasattr(repo, 'revparse_single'): try: # TODO Check this. Currently it works only in development branch r = repo.revparse_single(rev) except Exception: # FIXME be more specific vim_throw('norev', rev, repo.path) else: try: ref = repo.lookup_reference(rev) r = repo[ref.resolve().oid] except KeyError: try: r = repo[unicode(rev, 'utf-8')] except KeyError: vim_throw('norev', rev, repo.path) while not isinstance(r, git.Commit): if isinstance(r, git.Tag): r = repo[r.target] else: vim_throw('uresrev', repr(r), rev, repo.path) return r
def g_cs(repo, rev): if hasattr(repo, 'revparse_single'): try: # TODO Check this. Currently it works only in development branch r = repo.revparse_single(rev) except Exception: # FIXME be more specific vim_throw('norev', rev, repo.path) else: try: ref = repo.lookup_reference(rev) r = repo[ref.resolve().oid] except KeyError: try: r = repo[unicode(rev, 'utf-8')] except KeyError: vim_throw('norev', rev, repo.path) while not isinstance(r, git.Commit): if isinstance(r, git.Tag): r = repo[r.target] else: vim_throw('uresrev', repr(r), rev, repo.path) return r
def g_repo(path): try: return WorkingTree.open(path) except NotBranchError: vim_throw('norepo', path)
def g_repo(path): try: return hg.repository(PrintUI(), path) except error.RepoError: vim_throw('norepo', path)
def g_repo(path): try: return git.Repository(path) except KeyError: vim_throw('norepo', path)
def g_repo(path): try: return hg.repository(PrintUI(), path) except error.RepoError: vim_throw('norepo', path)
def g_cs(repo, rev): try: return repo[rev] except RepoLookupError: vim_throw('norev', rev, repo.path)
def g_repo(path): try: return WorkingTree.open(path) except NotBranchError: vim_throw('norepo', path)
def g_cs(repo, rev): try: return repo[rev] except RepoLookupError: vim_throw('norev', rev, repo.path)
def g_fctx(cs, filepath): try: return cs.filectx(filepath) except error.LookupError: vim_throw('nofile', filepath, cs.hex(), cs._repo.path)
def g_fctx(cs, filepath): try: return cs.filectx(filepath) except error.LookupError: vim_throw('nofile', filepath, cs.hex(), cs._repo.path)
def g_repo(path): try: return git.Repository(path) except KeyError: vim_throw('norepo', path)