소스 검색

Some fixes; go back to one-line-per-branch system.

tags/v0.2
Ben Kurtovic 10 년 전
부모
커밋
6c8e1be0fb
1개의 변경된 파일13개의 추가작업 그리고 16개의 파일을 삭제
  1. +13
    -16
      gitup/update.py

+ 13
- 16
gitup/update.py 파일 보기

@@ -85,7 +85,7 @@ def _fetch_remotes(remotes):
up_to_date = BLUE + "up to date" + RESET up_to_date = BLUE + "up to date" + RESET


for remote in remotes: for remote in remotes:
print(INDENT2, "Fetching", BOLD + remote.name, end=": ")
print(INDENT2, "Fetching", BOLD + remote.name, end="")
try: try:
results = remote.fetch(progress=_ProgressMonitor()) results = remote.fetch(progress=_ProgressMonitor())
except exc.GitCommandError as err: except exc.GitCommandError as err:
@@ -106,7 +106,7 @@ def _fetch_remotes(remotes):
desc = singular if len(names) == 1 else plural desc = singular if len(names) == 1 else plural
colored = GREEN + desc + RESET colored = GREEN + desc + RESET
rlist.append("{0} ({1})".format(colored, ", ".join(names))) rlist.append("{0} ({1})".format(colored, ", ".join(names)))
print((", ".join(rlist) if rlist else up_to_date) + ".")
print(":", (", ".join(rlist) if rlist else up_to_date) + ".")


def _is_up_to_date(repo, branch, upstream): def _is_up_to_date(repo, branch, upstream):
"""Return whether *branch* is up-to-date with its *upstream*.""" """Return whether *branch* is up-to-date with its *upstream*."""
@@ -121,17 +121,17 @@ def _rebase(repo, name):
except exc.GitCommandError as err: except exc.GitCommandError as err:
msg = err.stderr.replace("\n", " ").strip() msg = err.stderr.replace("\n", " ").strip()
if "unstaged changes" in msg: if "unstaged changes" in msg:
print(RED + " error:", "unstaged changes", end=")")
print(RED + " error:", "unstaged changes.")
elif "uncommitted changes" in msg: elif "uncommitted changes" in msg:
print(RED + " error:", "uncommitted changes", end=")")
print(RED + " error:", "uncommitted changes.")
else: else:
try: try:
repo.git.rebase("--abort") repo.git.rebase("--abort")
except exc.GitCommandError: except exc.GitCommandError:
pass pass
print(RED + " error:", msg if msg else "rebase conflict", end=")")
print(RED + " error:", msg if msg else "rebase conflict.")
else: else:
print("\b" * 6 + " " * 6 + "\b" * 6 + GREEN + "ed", end=")")
print("\b" * 6 + " " * 6 + "\b" * 6 + GREEN + "ed", end=".\n")


def _merge(repo, name): def _merge(repo, name):
"""Merge the branch *name* into the current HEAD of *repo*.""" """Merge the branch *name* into the current HEAD of *repo*."""
@@ -141,31 +141,31 @@ def _merge(repo, name):
except exc.GitCommandError as err: except exc.GitCommandError as err:
msg = err.stderr.replace("\n", " ").strip() msg = err.stderr.replace("\n", " ").strip()
if "local changes" in msg and "would be overwritten" in msg: if "local changes" in msg and "would be overwritten" in msg:
print(RED + " error:", "uncommitted changes", end=")")
print(RED + " error:", "uncommitted changes.")
else: else:
try: try:
repo.git.merge("--abort") repo.git.merge("--abort")
except exc.GitCommandError: except exc.GitCommandError:
pass pass
print(RED + " error:", msg if msg else "merge conflict", end=")")
print(RED + " error:", msg if msg else "merge conflict.")
else: else:
print("\b" * 6 + " " * 6 + "\b" * 6 + GREEN + "ed", end=")")
print("\b" * 6 + " " * 6 + "\b" * 6 + GREEN + "ed", end=".\n")


def _update_branch(repo, branch, merge, rebase, stasher=None): def _update_branch(repo, branch, merge, rebase, stasher=None):
"""Update a single branch.""" """Update a single branch."""
print(BOLD + branch.name, end=" (")
print(INDENT2, "Updating", BOLD + branch.name, end=": ")
upstream = branch.tracking_branch() upstream = branch.tracking_branch()
if not upstream: if not upstream:
print(YELLOW + "skipped:", "no upstream is tracked", end=")")
print(YELLOW + "skipped:", "no upstream is tracked.")
return return


try: try:
branch.commit, upstream.commit branch.commit, upstream.commit
except ValueError: except ValueError:
print(YELLOW + "skipped:", "branch has no revisions", end=")")
print(YELLOW + "skipped:", "branch has no revisions.")
return return
if _is_up_to_date(repo, branch, upstream): if _is_up_to_date(repo, branch, upstream):
print(BLUE + "up to date", end=")")
print(BLUE + "up to date", end=".\n")
return return


if stasher: if stasher:
@@ -179,19 +179,16 @@ def _update_branch(repo, branch, merge, rebase, stasher=None):


def _update_branches(repo, active, merge, rebase): def _update_branches(repo, active, merge, rebase):
"""Update a list of branches.""" """Update a list of branches."""
print(INDENT2, "Updating: ", end="")
_update_branch(repo, active, merge, rebase) _update_branch(repo, active, merge, rebase)
branches = set(repo.heads) - {active} branches = set(repo.heads) - {active}
if branches: if branches:
stasher = _Stasher(repo) stasher = _Stasher(repo)
try: try:
for branch in sorted(branches, key=lambda b: b.name): for branch in sorted(branches, key=lambda b: b.name):
print(", ", end="")
_update_branch(repo, branch, merge, rebase, stasher) _update_branch(repo, branch, merge, rebase, stasher)
finally: finally:
active.checkout() active.checkout()
stasher.restore() stasher.restore()
print(".")


def _update_repository(repo, current_only=False, rebase=False, merge=False): def _update_repository(repo, current_only=False, rebase=False, merge=False):
"""Update a single git repository by fetching remotes and rebasing/merging. """Update a single git repository by fetching remotes and rebasing/merging.


불러오는 중...
취소
저장