Skip to content

Commit 00df139

Browse files
committed
Merge branch 'develop'
2 parents 56664fa + 360bed9 commit 00df139

29 files changed

+860
-796
lines changed

.travis.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
cd ~
44

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

88
mkdir build && cd build

.travis.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ before_script:
1919
- git config --global user.email "[email protected]"
2020

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

2727
branches:
2828
only:
2929
- develop
30+
31+
sudo: false

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ the Python Package Index).
6363
To install from source you need to have Python (2.6, 2.7, 3.2+ or pypy)
6464
installed.
6565

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

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

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

8484
Then, just do:

gitless/cli/commit_dialog.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
IS_PY2 = sys.version_info[0] == 2
2121
ENCODING = getpreferredencoding() or 'utf-8'
2222

23-
_COMMIT_FILE = '.GL_COMMIT_EDIT_MSG'
23+
_COMMIT_FILE = 'GL_COMMIT_EDIT_MSG'
2424
_MERGE_MSG_FILE = 'MERGE_MSG'
2525

2626

gitless/cli/file_cmd.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515

1616
def parser(help_msg, subcmd):
1717
def f(subparsers, repo):
18-
p = subparsers.add_parser(subcmd, help=help_msg)
18+
p = subparsers.add_parser(
19+
subcmd, help=help_msg, description=help_msg.capitalize())
1920
p.add_argument(
2021
'files', nargs='+', help='the file(s) to {0}'.format(subcmd),
2122
action=helpers.PathProcessor, repo=repo)

gitless/cli/gl.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
INTERNAL_ERROR = 3
3030
NOT_IN_GL_REPO = 4
3131

32-
VERSION = '0.8'
32+
VERSION = '0.8.1'
3333
URL = 'http://gitless.com'
3434

3535

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

5757
sub_cmds = [

gitless/cli/gl_branch.py

+53-16
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77

88
from __future__ import unicode_literals
99

10+
try:
11+
from StringIO import StringIO
12+
except ImportError:
13+
from io import StringIO
14+
1015
from clint.textui import colored
1116

1217
from gitless import core
@@ -16,31 +21,41 @@
1621

1722
def parser(subparsers, _):
1823
"""Adds the branch parser to the given subparsers object."""
24+
desc = 'list, create, edit or delete branches'
1925
branch_parser = subparsers.add_parser(
20-
'branch', help='list, create, edit or delete branches')
26+
'branch', help=desc, description=desc.capitalize())
2127
branch_parser.add_argument(
2228
'-r', '--remote',
2329
help='list remote branches in addition to local branches',
2430
action='store_true')
2531

2632
branch_parser.add_argument(
27-
'-c', '--create', nargs='+', help='create branch(es)', dest='create_b')
33+
'-c', '--create', nargs='+', help='create branch(es)', dest='create_b',
34+
metavar='branch')
2835
branch_parser.add_argument(
2936
'-dp', '--divergent-point',
3037
help='the commit from where to \'branch out\' (only relevant if a new '
3138
'branch is created; defaults to HEAD)', default='HEAD',
3239
dest='dp')
3340
branch_parser.add_argument(
34-
'-d', '--delete', nargs='+', help='delete branch(es)', dest='delete_b')
41+
'-d', '--delete', nargs='+', help='delete branch(es)', dest='delete_b',
42+
metavar='branch')
3543

44+
branch_parser.add_argument(
45+
'-sh', '--set-head', help='set the head of the current branch',
46+
dest='new_head', metavar='commit_id')
3647
branch_parser.add_argument(
3748
'-su', '--set-upstream',
3849
help='set the upstream branch of the current branch',
39-
dest='upstream_b')
50+
dest='upstream_b', metavar='branch')
4051
branch_parser.add_argument(
4152
'-uu', '--unset-upstream',
4253
help='unset the upstream branch of the current branch',
4354
action='store_true')
55+
56+
branch_parser.add_argument(
57+
'-v', '--verbose', help='be verbose, will output the head of each branch',
58+
action='store_true')
4459
branch_parser.set_defaults(func=main)
4560

4661

@@ -54,35 +69,38 @@ def main(args, repo):
5469
ret = _do_set_upstream(args.upstream_b, repo)
5570
elif args.unset_upstream:
5671
ret = _do_unset_upstream(repo)
72+
elif args.new_head:
73+
ret = _do_set_head(args.new_head, repo)
5774
else:
58-
_do_list(repo, args.remote)
75+
_do_list(repo, args.remote, v=args.verbose)
5976

6077
return ret
6178

6279

63-
def _do_list(repo, list_remote):
80+
def _do_list(repo, list_remote, v=False):
6481
pprint.msg('List of branches:')
65-
pprint.exp('do gl branch -c <b> to create branch b')
66-
pprint.exp('do gl branch -d <b> to delete branch b')
67-
pprint.exp('do gl switch <b> to switch to branch b')
82+
pprint.exp('do gl branch -c b to create branch b')
83+
pprint.exp('do gl branch -d b to delete branch b')
84+
pprint.exp('do gl switch b to switch to branch b')
6885
pprint.exp('* = current branch')
6986
pprint.blank()
7087

88+
7189
for b in (repo.lookup_branch(n) for n in repo.listall_branches()):
7290
current_str = '*' if b.is_current else ' '
73-
upstream_str = ''
74-
try:
75-
upstream_str = '(upstream is {0})'.format(b.upstream_name)
76-
except KeyError:
77-
pass
91+
upstream_str = '(upstream is {0})'.format(b.upstream) if b.upstream else ''
7892
color = colored.green if b.is_current else colored.yellow
7993
pprint.item(
8094
'{0} {1} {2}'.format(current_str, color(b.branch_name), upstream_str))
95+
if v:
96+
pprint.item(' ➜ head is {0}'.format(_ci_str(b.head)))
8197

8298
if list_remote:
8399
for r in repo.remotes:
84100
for b in (r.lookup_branch(n) for n in r.listall_branches()):
85101
pprint.item(' {0}'.format(colored.yellow(b.branch_name)))
102+
if v:
103+
pprint.item(' ➜ head is {0}'.format(_ci_str(b.head)))
86104

87105

88106
def _do_create(create_b, dp, repo):
@@ -91,7 +109,7 @@ def _do_create(create_b, dp, repo):
91109
try:
92110
target = repo.revparse_single(dp)
93111
except KeyError:
94-
raise ValueError('Invalid divergent point "{0}"'.format(dp))
112+
raise ValueError('Invalid divergent point {0}'.format(dp))
95113

96114
for b_name in create_b:
97115
r = repo
@@ -142,7 +160,7 @@ def _do_delete(delete_b, repo):
142160
except core.BranchIsCurrentError as e:
143161
pprint.err(e)
144162
pprint.err_exp(
145-
'do gl branch <b> to create or switch to another branch b and then '
163+
'do gl branch b to create or switch to another branch b and then '
146164
'gl branch -d {0} to remove branch {0}'.format(b))
147165
errors_found = True
148166

@@ -161,3 +179,22 @@ def _do_unset_upstream(repo):
161179
curr_b.upstream = None
162180
pprint.ok('Upstream unset for current branch {0}'.format(curr_b))
163181
return True
182+
183+
184+
def _do_set_head(commit_id, repo):
185+
try:
186+
commit = repo.revparse_single(commit_id)
187+
except KeyError:
188+
raise ValueError('Invalid head {0}'.format(commit_id))
189+
190+
curr_b = repo.current_branch
191+
curr_b.head = commit.id
192+
pprint.ok(
193+
'Head of current branch {0} is now {1}'.format(curr_b, _ci_str(commit)))
194+
return True
195+
196+
197+
def _ci_str(ci):
198+
ci_str = StringIO()
199+
pprint.commit(ci, compact=True, stream=ci_str.write)
200+
return ci_str.getvalue().strip()

gitless/cli/gl_checkout.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414

1515
def parser(subparsers, repo):
1616
"""Adds the checkout parser to the given subparsers object."""
17+
desc = 'checkout committed versions of files'
1718
checkout_parser = subparsers.add_parser(
18-
'checkout', help='checkout committed versions of files')
19+
'checkout', help=desc, description=desc.capitalize())
1920
checkout_parser.add_argument(
2021
'-cp', '--commit-point', help=(
2122
'the commit point to checkout the files at. Defaults to HEAD.'),

gitless/cli/gl_commit.py

+19-12
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@
1515

1616
def parser(subparsers, repo):
1717
"""Adds the commit parser to the given subparsers object."""
18+
desc = 'save changes to the local repository'
1819
commit_parser = subparsers.add_parser(
19-
'commit', help='record changes in the local repository',
20-
description=(
20+
'commit', help=desc, description=(
21+
desc.capitalize() + '. ' +
2122
'By default all tracked modified files are committed. To customize the'
22-
' set of files to be committed you can use the only, exclude, and '
23-
'include flags'))
23+
' set of files to be committed use the only, exclude, and include '
24+
'flags'))
2425
commit_parser.add_argument(
2526
'-m', '--message', help='Commit message', dest='m')
2627
helpers.oei_flags(commit_parser, repo)
@@ -32,7 +33,7 @@ def main(args, repo):
3233

3334
if not commit_files:
3435
pprint.err('No files to commit')
35-
pprint.err_exp('use gl track <f> if you want to track changes to file f')
36+
pprint.err_exp('use gl track f if you want to track changes to file f')
3637
return False
3738

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

5051
if curr_b.fuse_in_progress:
51-
pprint.blank()
52-
try:
53-
curr_b.fuse_continue(fuse_cb=pprint.FUSE_CB)
54-
pprint.ok('Fuse succeeded')
55-
except core.ApplyFailedError as e:
56-
pprint.ok('Fuse succeeded')
57-
raise e
52+
_op_continue(curr_b.fuse_continue, 'Fuse')
53+
elif curr_b.merge_in_progress:
54+
_op_continue(curr_b.merge_continue, 'Merge')
5855

5956
return True
6057

@@ -65,3 +62,13 @@ def _auto_track(files, curr_b):
6562
f = curr_b.status_file(fp)
6663
if f.type == core.GL_STATUS_UNTRACKED:
6764
curr_b.track_file(f.fp)
65+
66+
67+
def _op_continue(op, fn):
68+
pprint.blank()
69+
try:
70+
op(op_cb=pprint.OP_CB)
71+
pprint.ok('{0} succeeded'.format(op))
72+
except core.ApplyFailedError as e:
73+
pprint.ok('{0} succeeded'.format(op))
74+
raise e

gitless/cli/gl_diff.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515

1616
def parser(subparsers, repo):
1717
"""Adds the diff parser to the given subparsers object."""
18+
desc = 'show changes to files'
1819
diff_parser = subparsers.add_parser(
19-
'diff', help='show changes in files',
20-
description=(
20+
'diff', help=desc, description=(
21+
desc.capitalize() + '. ' +
2122
'By default all tracked modified files are diffed. To customize the '
22-
' set of files to diff you can use the only, exclude, and include '
23-
'flags'))
23+
' set of files to diff use the only, exclude, and include flags'))
2424
helpers.oei_flags(diff_parser, repo)
2525
diff_parser.set_defaults(func=main)
2626

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

5656
if os.path.getsize(tf.name) > 0:
57-
helpers.page(tf.name)
57+
helpers.page(tf.name, repo)
5858
os.remove(tf.name)
5959

6060
return success

gitless/cli/gl_fuse.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313

1414

1515
def parser(subparsers, repo):
16+
desc = 'fuse the divergent changes of a branch onto the current branch'
1617
fuse_parser = subparsers.add_parser(
17-
'fuse',
18-
help='fuse the divergent changes of a branch onto the current branch',
19-
description=(
18+
'fuse', help=desc, description=(
19+
desc.capitalize() + '. ' +
2020
'By default all divergent changes from the given source branch are '
21-
'fused. To customize the set of commmits to be fused you can use the '
22-
'only and exclude flags'))
21+
'fused. To customize the set of commmits to fuse use the only and '
22+
'exclude flags'))
2323
fuse_parser.add_argument(
2424
'src', nargs='?',
2525
help=(
@@ -50,7 +50,7 @@ def parser(subparsers, repo):
5050
def main(args, repo):
5151
current_b = repo.current_branch
5252
if args.abort:
53-
current_b.abort_fuse(fuse_cb=pprint.FUSE_CB)
53+
current_b.abort_fuse(op_cb=pprint.OP_CB)
5454
pprint.ok('Fuse aborted successfully')
5555
return True
5656

@@ -90,7 +90,7 @@ def valid_input(inp):
9090
try:
9191
current_b.fuse(
9292
src_branch, insertion_point, only=only, exclude=exclude,
93-
fuse_cb=pprint.FUSE_CB)
93+
op_cb=pprint.OP_CB)
9494
pprint.ok('Fuse succeeded')
9595
except core.ApplyFailedError as e:
9696
pprint.ok('Fuse succeeded')

0 commit comments

Comments
 (0)