Esempio n. 1
0
File: merge.py Progetto: NogaOs/Swit
def get_merge_paths(user_input: str):
    """Returns the commit id and image path of the user image, HEAD, and their first mutual parent."""
    # Head:
    head_commit_id = helper.get_head_id()
    head_dir_path = path_to.images / head_commit_id
    # User Image:
    user_commit_id = helper.resolve_commit_id(user_input)
    user_dir_path = helper.get_valid_commit_path(user_commit_id, user_input)
    # Common Base Image:
    common_base_id = get_first_mutual_parent(head_commit_id, user_commit_id)
    common_base_dir_path = path_to.images / common_base_id

    return (head_commit_id, user_commit_id, head_dir_path, user_dir_path,
            common_base_dir_path)
Esempio n. 2
0
def inner_checkout(user_input: str, image_commit_id: str,
                   image_dir_path: Path) -> None:
    """Updates files in the repository and in staging area to match the version 
    in the specified image.
    Updates the activated file and references files.
    """
    head_id = get_head_id()
    status_info = status.get_status_info(head_id)
    to_be_committed, not_staged, untracked = status_info.items()
    handle_impossible_checkout(head_id, image_dir_path, to_be_committed,
                               not_staged)
    update_repo(untracked[1], image_dir_path)
    update_staging_area(image_dir_path)
    # Note: Updating activated.txt should remain before references.txt
    handle_activated_file(image_commit_id, user_input)
    handle_references_file(image_commit_id)
Esempio n. 3
0
def inner_status() -> None:
    """Prints a message to the user, including:
    - Changes to Be Committed:
        Files that have been added, but not committed yet.
    - Changes Not Staged for Commit:
        Files that have a different content from the indexed file.
    - Untracked Files:
        Files that were neither added nor committed.
    """
    try:
        head_id = get_head_id()
    except FileNotFoundError:
        raise CommitRequiredError(
            "Must commit at least once before executing status.")
    info = get_status_info(head_id)
    print_status(head_id, info)
Esempio n. 4
0
def inner_graph(is_all: bool, show_entire_id: bool) -> None:
    """Shows a graph of all parental hierarchy, starting from HEAD.
    If is_all is True, the graph will show ALL commits and the relations between them.
    If is_entire is True, it will show the entire id of each entry.
    """
    parents_by_image = get_parents_by_image()

    if is_all:
        edges = edgenerator(parents_by_image)
    else:
        head_id = get_head_id()
        edges = get_parent_edges_of(parents_by_image, head_id)

    if not show_entire_id:
        edges = [(x[:6], y[:6]) for x, y in edges]

    plot_graph(edges)
Esempio n. 5
0
File: merge.py Progetto: NogaOs/Swit
def get_commit_ids(user_input: str) -> Tuple[str, str, str]:
    """Returns the commit id of HEAD, of the chosen image, and common parent image."""
    head_commit_id = helper.get_head_id()
    user_commit_id = helper.resolve_commit_id(user_input)
    common_base_id = get_first_mutual_parent(head_commit_id, user_commit_id)
    return head_commit_id, user_commit_id, common_base_id