| @@ -3,12 +3,9 @@ | |||||
| # Copyright (C) 2011-2018 Ben Kurtovic <ben.kurtovic@gmail.com> | # Copyright (C) 2011-2018 Ben Kurtovic <ben.kurtovic@gmail.com> | ||||
| # Released under the terms of the MIT License. See LICENSE for details. | # Released under the terms of the MIT License. See LICENSE for details. | ||||
| from __future__ import print_function | |||||
| import argparse | import argparse | ||||
| import os | import os | ||||
| import platform | import platform | ||||
| import sys | |||||
| from colorama import init as color_init, Style | from colorama import init as color_init, Style | ||||
| @@ -17,11 +14,6 @@ from gitup.config import (get_default_config_path, get_bookmarks, add_bookmarks, | |||||
| delete_bookmarks, list_bookmarks, clean_bookmarks) | delete_bookmarks, list_bookmarks, clean_bookmarks) | ||||
| from gitup.update import update_bookmarks, update_directories, run_command | from gitup.update import update_bookmarks, update_directories, run_command | ||||
| def _decode(path): | |||||
| """Decode the given string using the system's filesystem encoding.""" | |||||
| if sys.version_info.major > 2: | |||||
| return path | |||||
| return path.decode(sys.getfilesystemencoding()) | |||||
| def _build_parser(): | def _build_parser(): | ||||
| """Build and return the argument parser.""" | """Build and return the argument parser.""" | ||||
| @@ -39,7 +31,7 @@ def _build_parser(): | |||||
| group_m = parser.add_argument_group("miscellaneous") | group_m = parser.add_argument_group("miscellaneous") | ||||
| group_u.add_argument( | group_u.add_argument( | ||||
| 'directories_to_update', nargs="*", metavar="path", type=_decode, | |||||
| 'directories_to_update', nargs="*", metavar="path", | |||||
| help="""update this repository, or all repositories it contains | help="""update this repository, or all repositories it contains | ||||
| (if not a repo directly)""") | (if not a repo directly)""") | ||||
| group_u.add_argument( | group_u.add_argument( | ||||
| @@ -60,11 +52,9 @@ def _build_parser(): | |||||
| remote-tracking branches that no longer exist on their remote""") | remote-tracking branches that no longer exist on their remote""") | ||||
| group_b.add_argument( | group_b.add_argument( | ||||
| '-a', '--add', dest="bookmarks_to_add", nargs="+", metavar="path", | |||||
| type=_decode, help="add directory(s) as bookmarks") | |||||
| '-a', '--add', dest="bookmarks_to_add", nargs="+", metavar="path", help="add directory(s) as bookmarks") | |||||
| group_b.add_argument( | group_b.add_argument( | ||||
| '-d', '--delete', dest="bookmarks_to_del", nargs="+", metavar="path", | '-d', '--delete', dest="bookmarks_to_del", nargs="+", metavar="path", | ||||
| type=_decode, | |||||
| help="delete bookmark(s) (leaves actual directories alone)") | help="delete bookmark(s) (leaves actual directories alone)") | ||||
| group_b.add_argument( | group_b.add_argument( | ||||
| '-l', '--list', dest="list_bookmarks", action="store_true", | '-l', '--list', dest="list_bookmarks", action="store_true", | ||||
| @@ -73,7 +63,7 @@ def _build_parser(): | |||||
| '-n', '--clean', '--cleanup', dest="clean_bookmarks", | '-n', '--clean', '--cleanup', dest="clean_bookmarks", | ||||
| action="store_true", help="delete any bookmarks that don't exist") | action="store_true", help="delete any bookmarks that don't exist") | ||||
| group_b.add_argument( | group_b.add_argument( | ||||
| '-b', '--bookmark-file', nargs="?", metavar="path", type=_decode, | |||||
| '-b', '--bookmark-file', nargs="?", metavar="path", | |||||
| help="use a specific bookmark config file (default: {0})".format( | help="use a specific bookmark config file (default: {0})".format( | ||||
| get_default_config_path())) | get_default_config_path())) | ||||
| @@ -3,8 +3,6 @@ | |||||
| # Copyright (C) 2011-2018 Ben Kurtovic <ben.kurtovic@gmail.com> | # Copyright (C) 2011-2018 Ben Kurtovic <ben.kurtovic@gmail.com> | ||||
| # Released under the terms of the MIT License. See LICENSE for details. | # Released under the terms of the MIT License. See LICENSE for details. | ||||
| from __future__ import print_function | |||||
| from glob import glob | from glob import glob | ||||
| import os | import os | ||||
| @@ -5,12 +5,7 @@ | |||||
| import os | import os | ||||
| try: | |||||
| from configparser import ConfigParser, NoSectionError | |||||
| PY3K = True | |||||
| except ImportError: # Python 2 | |||||
| from ConfigParser import SafeConfigParser as ConfigParser, NoSectionError | |||||
| PY3K = False | |||||
| from configparser import ConfigParser, NoSectionError | |||||
| __all__ = ["run_migrations"] | __all__ = ["run_migrations"] | ||||
| @@ -37,16 +32,14 @@ def _migrate_old_format(): | |||||
| if not os.path.exists(old_path): | if not os.path.exists(old_path): | ||||
| return | return | ||||
| config = ConfigParser(delimiters="=") if PY3K else ConfigParser() | |||||
| config = ConfigParser(delimiters="=") | |||||
| config.optionxform = lambda opt: opt | config.optionxform = lambda opt: opt | ||||
| config.read(old_path) | config.read(old_path) | ||||
| try: | try: | ||||
| bookmarks = [path for path, _ in config.items("bookmarks")] | |||||
| bookmarks = [path.encode("utf8") for path, _ in config.items("bookmarks")] | |||||
| except NoSectionError: | except NoSectionError: | ||||
| bookmarks = [] | bookmarks = [] | ||||
| if PY3K: | |||||
| bookmarks = [path.encode("utf8") for path in bookmarks] | |||||
| new_path = os.path.join(os.path.split(old_path)[0], "bookmarks") | new_path = os.path.join(os.path.split(old_path)[0], "bookmarks") | ||||
| os.rename(old_path, new_path) | os.rename(old_path, new_path) | ||||
| @@ -3,8 +3,6 @@ | |||||
| # Copyright (C) 2011-2018 Ben Kurtovic <ben.kurtovic@gmail.com> | # Copyright (C) 2011-2018 Ben Kurtovic <ben.kurtovic@gmail.com> | ||||
| # Released under the terms of the MIT License. See LICENSE for details. | # Released under the terms of the MIT License. See LICENSE for details. | ||||
| from __future__ import print_function, unicode_literals | |||||
| from gitup import config | from gitup import config | ||||
| def test_empty_list(tmpdir, capsys): | def test_empty_list(tmpdir, capsys): | ||||
| @@ -3,8 +3,6 @@ | |||||
| # Copyright (C) 2011-2018 Ben Kurtovic <ben.kurtovic@gmail.com> | # Copyright (C) 2011-2018 Ben Kurtovic <ben.kurtovic@gmail.com> | ||||
| # Released under the terms of the MIT License. See LICENSE for details. | # Released under the terms of the MIT License. See LICENSE for details. | ||||
| from __future__ import print_function, unicode_literals | |||||
| import platform | import platform | ||||
| import subprocess | import subprocess | ||||
| import sys | import sys | ||||
| @@ -2,9 +2,7 @@ | |||||
| # | # | ||||
| # Copyright (C) 2011-2018 Ben Kurtovic <ben.kurtovic@gmail.com> | # Copyright (C) 2011-2018 Ben Kurtovic <ben.kurtovic@gmail.com> | ||||
| # Released under the terms of the MIT License. See LICENSE for details. | # Released under the terms of the MIT License. See LICENSE for details. | ||||
| from __future__ import print_function | |||||
| import logging | |||||
| from glob import glob | from glob import glob | ||||
| import os | import os | ||||
| import re | import re | ||||
| @@ -14,6 +12,8 @@ from colorama import Fore, Style | |||||
| from git import RemoteReference as RemoteRef, Repo, exc | from git import RemoteReference as RemoteRef, Repo, exc | ||||
| from git.util import RemoteProgress | from git.util import RemoteProgress | ||||
| logger = logging.getLogger(__name__) | |||||
| __all__ = ["update_bookmarks", "update_directories", "run_command"] | __all__ = ["update_bookmarks", "update_directories", "run_command"] | ||||
| BOLD = Style.BRIGHT | BOLD = Style.BRIGHT | ||||
| @@ -126,6 +126,7 @@ def _update_branch(repo, branch, is_active=False): | |||||
| try: | try: | ||||
| base = repo.git.merge_base(branch.commit, upstream.commit) | base = repo.git.merge_base(branch.commit, upstream.commit) | ||||
| except exc.GitCommandError as err: | except exc.GitCommandError as err: | ||||
| logger.debug(err) | |||||
| print(YELLOW + "skipped:", "can't find merge base with upstream.") | print(YELLOW + "skipped:", "can't find merge base with upstream.") | ||||
| return | return | ||||