Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
spderosso committed Sep 9, 2015
2 parents 56664fa + 360bed9 commit 00df139
Show file tree
Hide file tree
Showing 29 changed files with 860 additions and 796 deletions.
2 changes: 1 addition & 1 deletion .travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

cd ~

git clone --depth=1 -b maint/v0.22 https://github.com/libgit2/libgit2.git
git clone --depth=1 -b maint/v0.23 https://github.com/libgit2/libgit2.git
cd libgit2/

mkdir build && cd build
Expand Down
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ before_script:
- git config --global user.email "travis@test.com"

script:
- nosetests
- nosetests --logging-level=WARN
# nose doesn't like the number on test_e2e so it's not detected by the
# previous command.
- nosetests gitless/tests/test_e2e.py
- nosetests gitless/tests/test_e2e.py --logging-level=WARN

branches:
only:
- develop

sudo: false
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ the Python Package Index).
To install from source you need to have Python (2.6, 2.7, 3.2+ or pypy)
installed.

Additionaly, you need to [install pygit2](
Additionaly, you need to [install pygit2 (v0.23.0)](
http://www.pygit2.org/install.html "pygit2 install").

Then, download the source code tarball available @
Expand All @@ -78,7 +78,7 @@ If you are a Python fan you might find it easier to install
Gitless via the Python Package Index. To do this, you need to have
Python (2.6, 2.7, 3.2+ or pypy) installed.

Additionaly, you need to [install pygit2](
Additionaly, you need to [install pygit2 (v0.23.0)](
http://www.pygit2.org/install.html "pygit2 install").

Then, just do:
Expand Down
2 changes: 1 addition & 1 deletion gitless/cli/commit_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
IS_PY2 = sys.version_info[0] == 2
ENCODING = getpreferredencoding() or 'utf-8'

_COMMIT_FILE = '.GL_COMMIT_EDIT_MSG'
_COMMIT_FILE = 'GL_COMMIT_EDIT_MSG'
_MERGE_MSG_FILE = 'MERGE_MSG'


Expand Down
3 changes: 2 additions & 1 deletion gitless/cli/file_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@

def parser(help_msg, subcmd):
def f(subparsers, repo):
p = subparsers.add_parser(subcmd, help=help_msg)
p = subparsers.add_parser(
subcmd, help=help_msg, description=help_msg.capitalize())
p.add_argument(
'files', nargs='+', help='the file(s) to {0}'.format(subcmd),
action=helpers.PathProcessor, repo=repo)
Expand Down
4 changes: 2 additions & 2 deletions gitless/cli/gl.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
INTERNAL_ERROR = 3
NOT_IN_GL_REPO = 4

VERSION = '0.8'
VERSION = '0.8.1'
URL = 'http://gitless.com'


Expand All @@ -51,7 +51,7 @@ def main():
'--version', action='version', version=(
'GL Version: {0}\nYou can check if there\'s a new version of Gitless '
'available at {1}'.format(VERSION, URL)))
subparsers = parser.add_subparsers(dest='subcmd_name')
subparsers = parser.add_subparsers(title='subcommands', dest='subcmd_name')
subparsers.required = True

sub_cmds = [
Expand Down
69 changes: 53 additions & 16 deletions gitless/cli/gl_branch.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@

from __future__ import unicode_literals

try:
from StringIO import StringIO
except ImportError:
from io import StringIO

from clint.textui import colored

from gitless import core
Expand All @@ -16,31 +21,41 @@

def parser(subparsers, _):
"""Adds the branch parser to the given subparsers object."""
desc = 'list, create, edit or delete branches'
branch_parser = subparsers.add_parser(
'branch', help='list, create, edit or delete branches')
'branch', help=desc, description=desc.capitalize())
branch_parser.add_argument(
'-r', '--remote',
help='list remote branches in addition to local branches',
action='store_true')

branch_parser.add_argument(
'-c', '--create', nargs='+', help='create branch(es)', dest='create_b')
'-c', '--create', nargs='+', help='create branch(es)', dest='create_b',
metavar='branch')
branch_parser.add_argument(
'-dp', '--divergent-point',
help='the commit from where to \'branch out\' (only relevant if a new '
'branch is created; defaults to HEAD)', default='HEAD',
dest='dp')
branch_parser.add_argument(
'-d', '--delete', nargs='+', help='delete branch(es)', dest='delete_b')
'-d', '--delete', nargs='+', help='delete branch(es)', dest='delete_b',
metavar='branch')

branch_parser.add_argument(
'-sh', '--set-head', help='set the head of the current branch',
dest='new_head', metavar='commit_id')
branch_parser.add_argument(
'-su', '--set-upstream',
help='set the upstream branch of the current branch',
dest='upstream_b')
dest='upstream_b', metavar='branch')
branch_parser.add_argument(
'-uu', '--unset-upstream',
help='unset the upstream branch of the current branch',
action='store_true')

branch_parser.add_argument(
'-v', '--verbose', help='be verbose, will output the head of each branch',
action='store_true')
branch_parser.set_defaults(func=main)


Expand All @@ -54,35 +69,38 @@ def main(args, repo):
ret = _do_set_upstream(args.upstream_b, repo)
elif args.unset_upstream:
ret = _do_unset_upstream(repo)
elif args.new_head:
ret = _do_set_head(args.new_head, repo)
else:
_do_list(repo, args.remote)
_do_list(repo, args.remote, v=args.verbose)

return ret


def _do_list(repo, list_remote):
def _do_list(repo, list_remote, v=False):
pprint.msg('List of branches:')
pprint.exp('do gl branch -c <b> to create branch b')
pprint.exp('do gl branch -d <b> to delete branch b')
pprint.exp('do gl switch <b> to switch to branch b')
pprint.exp('do gl branch -c b to create branch b')
pprint.exp('do gl branch -d b to delete branch b')
pprint.exp('do gl switch b to switch to branch b')
pprint.exp('* = current branch')
pprint.blank()


for b in (repo.lookup_branch(n) for n in repo.listall_branches()):
current_str = '*' if b.is_current else ' '
upstream_str = ''
try:
upstream_str = '(upstream is {0})'.format(b.upstream_name)
except KeyError:
pass
upstream_str = '(upstream is {0})'.format(b.upstream) if b.upstream else ''
color = colored.green if b.is_current else colored.yellow
pprint.item(
'{0} {1} {2}'.format(current_str, color(b.branch_name), upstream_str))
if v:
pprint.item(' ➜ head is {0}'.format(_ci_str(b.head)))

if list_remote:
for r in repo.remotes:
for b in (r.lookup_branch(n) for n in r.listall_branches()):
pprint.item(' {0}'.format(colored.yellow(b.branch_name)))
if v:
pprint.item(' ➜ head is {0}'.format(_ci_str(b.head)))


def _do_create(create_b, dp, repo):
Expand All @@ -91,7 +109,7 @@ def _do_create(create_b, dp, repo):
try:
target = repo.revparse_single(dp)
except KeyError:
raise ValueError('Invalid divergent point "{0}"'.format(dp))
raise ValueError('Invalid divergent point {0}'.format(dp))

for b_name in create_b:
r = repo
Expand Down Expand Up @@ -142,7 +160,7 @@ def _do_delete(delete_b, repo):
except core.BranchIsCurrentError as e:
pprint.err(e)
pprint.err_exp(
'do gl branch <b> to create or switch to another branch b and then '
'do gl branch b to create or switch to another branch b and then '
'gl branch -d {0} to remove branch {0}'.format(b))
errors_found = True

Expand All @@ -161,3 +179,22 @@ def _do_unset_upstream(repo):
curr_b.upstream = None
pprint.ok('Upstream unset for current branch {0}'.format(curr_b))
return True


def _do_set_head(commit_id, repo):
try:
commit = repo.revparse_single(commit_id)
except KeyError:
raise ValueError('Invalid head {0}'.format(commit_id))

curr_b = repo.current_branch
curr_b.head = commit.id
pprint.ok(
'Head of current branch {0} is now {1}'.format(curr_b, _ci_str(commit)))
return True


def _ci_str(ci):
ci_str = StringIO()
pprint.commit(ci, compact=True, stream=ci_str.write)
return ci_str.getvalue().strip()
3 changes: 2 additions & 1 deletion gitless/cli/gl_checkout.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@

def parser(subparsers, repo):
"""Adds the checkout parser to the given subparsers object."""
desc = 'checkout committed versions of files'
checkout_parser = subparsers.add_parser(
'checkout', help='checkout committed versions of files')
'checkout', help=desc, description=desc.capitalize())
checkout_parser.add_argument(
'-cp', '--commit-point', help=(
'the commit point to checkout the files at. Defaults to HEAD.'),
Expand Down
31 changes: 19 additions & 12 deletions gitless/cli/gl_commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@

def parser(subparsers, repo):
"""Adds the commit parser to the given subparsers object."""
desc = 'save changes to the local repository'
commit_parser = subparsers.add_parser(
'commit', help='record changes in the local repository',
description=(
'commit', help=desc, description=(
desc.capitalize() + '. ' +
'By default all tracked modified files are committed. To customize the'
' set of files to be committed you can use the only, exclude, and '
'include flags'))
' set of files to be committed use the only, exclude, and include '
'flags'))
commit_parser.add_argument(
'-m', '--message', help='Commit message', dest='m')
helpers.oei_flags(commit_parser, repo)
Expand All @@ -32,7 +33,7 @@ def main(args, repo):

if not commit_files:
pprint.err('No files to commit')
pprint.err_exp('use gl track <f> if you want to track changes to file f')
pprint.err_exp('use gl track f if you want to track changes to file f')
return False

msg = args.m if args.m else commit_dialog.show(commit_files, repo)
Expand All @@ -48,13 +49,9 @@ def main(args, repo):
pprint.commit(ci)

if curr_b.fuse_in_progress:
pprint.blank()
try:
curr_b.fuse_continue(fuse_cb=pprint.FUSE_CB)
pprint.ok('Fuse succeeded')
except core.ApplyFailedError as e:
pprint.ok('Fuse succeeded')
raise e
_op_continue(curr_b.fuse_continue, 'Fuse')
elif curr_b.merge_in_progress:
_op_continue(curr_b.merge_continue, 'Merge')

return True

Expand All @@ -65,3 +62,13 @@ def _auto_track(files, curr_b):
f = curr_b.status_file(fp)
if f.type == core.GL_STATUS_UNTRACKED:
curr_b.track_file(f.fp)


def _op_continue(op, fn):
pprint.blank()
try:
op(op_cb=pprint.OP_CB)
pprint.ok('{0} succeeded'.format(op))
except core.ApplyFailedError as e:
pprint.ok('{0} succeeded'.format(op))
raise e
10 changes: 5 additions & 5 deletions gitless/cli/gl_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@

def parser(subparsers, repo):
"""Adds the diff parser to the given subparsers object."""
desc = 'show changes to files'
diff_parser = subparsers.add_parser(
'diff', help='show changes in files',
description=(
'diff', help=desc, description=(
desc.capitalize() + '. ' +
'By default all tracked modified files are diffed. To customize the '
' set of files to diff you can use the only, exclude, and include '
'flags'))
' set of files to diff use the only, exclude, and include flags'))
helpers.oei_flags(diff_parser, repo)
diff_parser.set_defaults(func=main)

Expand Down Expand Up @@ -54,7 +54,7 @@ def main(args, repo):
pprint.diff(patch, stream=tf.write)

if os.path.getsize(tf.name) > 0:
helpers.page(tf.name)
helpers.page(tf.name, repo)
os.remove(tf.name)

return success
14 changes: 7 additions & 7 deletions gitless/cli/gl_fuse.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@


def parser(subparsers, repo):
desc = 'fuse the divergent changes of a branch onto the current branch'
fuse_parser = subparsers.add_parser(
'fuse',
help='fuse the divergent changes of a branch onto the current branch',
description=(
'fuse', help=desc, description=(
desc.capitalize() + '. ' +
'By default all divergent changes from the given source branch are '
'fused. To customize the set of commmits to be fused you can use the '
'only and exclude flags'))
'fused. To customize the set of commmits to fuse use the only and '
'exclude flags'))
fuse_parser.add_argument(
'src', nargs='?',
help=(
Expand Down Expand Up @@ -50,7 +50,7 @@ def parser(subparsers, repo):
def main(args, repo):
current_b = repo.current_branch
if args.abort:
current_b.abort_fuse(fuse_cb=pprint.FUSE_CB)
current_b.abort_fuse(op_cb=pprint.OP_CB)
pprint.ok('Fuse aborted successfully')
return True

Expand Down Expand Up @@ -90,7 +90,7 @@ def valid_input(inp):
try:
current_b.fuse(
src_branch, insertion_point, only=only, exclude=exclude,
fuse_cb=pprint.FUSE_CB)
op_cb=pprint.OP_CB)
pprint.ok('Fuse succeeded')
except core.ApplyFailedError as e:
pprint.ok('Fuse succeeded')
Expand Down

0 comments on commit 00df139

Please sign in to comment.