Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
ccc712b1
Commit
ccc712b1
authored
Mar 07, 2013
by
Sato Hiroyuki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refacor: removing the times array, because that is same with @commits array.
parent
8c5003cf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
21 deletions
+31
-21
app/models/network/graph.rb
app/models/network/graph.rb
+31
-21
No files found.
app/models/network/graph.rb
View file @
ccc712b1
...
@@ -23,13 +23,21 @@ module Network
...
@@ -23,13 +23,21 @@ module Network
# Get commits from repository
# Get commits from repository
#
#
def
collect_commits
def
collect_commits
@commits
=
Grit
::
Commit
.
find_all
(
@repo
,
nil
,
{
date_order:
true
,
max_count:
self
.
class
.
max_count
,
skip:
to_commit
}).
dup
# Decorate with app/model/network/commit.rb
refs_cache
=
build_refs_cache
refs_cache
=
build_refs_cache
@commits
.
map!
{
|
commit
|
Network
::
Commit
.
new
(
commit
,
refs_cache
[
commit
.
id
])
}
@commits
Grit
::
Commit
.
find_all
(
@repo
,
nil
,
{
date_order:
true
,
max_count:
self
.
class
.
max_count
,
skip:
count_to_display_commit_in_center
}
)
.
map
do
|
commit
|
# Decorate with app/model/network/commit.rb
Network
::
Commit
.
new
(
commit
,
refs_cache
[
commit
.
id
])
end
end
end
# Method is adding time and space on the
# Method is adding time and space on the
...
@@ -40,14 +48,13 @@ module Network
...
@@ -40,14 +48,13 @@ module Network
#
#
# @return [Array<TimeDate>] list of commit dates corelated with time on commits
# @return [Array<TimeDate>] list of commit dates corelated with time on commits
def
index_commits
def
index_commits
days
,
times
=
[],
[]
days
=
[]
map
=
{}
map
=
{}
commits
.
reverse
.
each_with_index
do
|
c
,
i
|
@
commits
.
reverse
.
each_with_index
do
|
c
,
i
|
c
.
time
=
i
c
.
time
=
i
days
[
i
]
=
c
.
committed_date
days
[
i
]
=
c
.
committed_date
map
[
c
.
id
]
=
c
map
[
c
.
id
]
=
c
times
[
i
]
=
c
end
end
@_reserved
=
{}
@_reserved
=
{}
...
@@ -62,17 +69,16 @@ module Network
...
@@ -62,17 +69,16 @@ module Network
end
end
# find parent spaces for not overlap lines
# find parent spaces for not overlap lines
time
s
.
each
do
|
c
|
@commit
s
.
each
do
|
c
|
c
.
parent_spaces
.
concat
(
find_free_parent_spaces
(
c
,
map
,
times
))
c
.
parent_spaces
.
concat
(
find_free_parent_spaces
(
c
,
map
))
end
end
days
days
end
end
# Skip count that the target commit is displayed in center.
# Skip count that the target commit is displayed in center.
def
to_commit
def
count_to_display_commit_in_center
commits
=
Grit
::
Commit
.
find_all
(
@repo
,
nil
,
{
date_order:
true
})
commit_index
=
Grit
::
Commit
.
find_all
(
@repo
,
nil
,
{
date_order:
true
}).
index
do
|
c
|
commit_index
=
commits
.
index
do
|
c
|
c
.
id
==
@commit
.
id
c
.
id
==
@commit
.
id
end
end
...
@@ -85,7 +91,7 @@ module Network
...
@@ -85,7 +91,7 @@ module Network
end
end
def
commits_sort_by_ref
def
commits_sort_by_ref
commits
.
sort
do
|
a
,
b
|
@
commits
.
sort
do
|
a
,
b
|
if
include_ref?
(
a
)
if
include_ref?
(
a
)
-
1
-
1
elsif
include_ref?
(
b
)
elsif
include_ref?
(
b
)
...
@@ -108,7 +114,7 @@ module Network
...
@@ -108,7 +114,7 @@ module Network
heads
.
include?
(
@ref
)
heads
.
include?
(
@ref
)
end
end
def
find_free_parent_spaces
(
commit
,
map
,
times
)
def
find_free_parent_spaces
(
commit
,
map
)
spaces
=
[]
spaces
=
[]
commit
.
parents
.
each
do
|
p
|
commit
.
parents
.
each
do
|
p
|
...
@@ -122,9 +128,9 @@ module Network
...
@@ -122,9 +128,9 @@ module Network
end
end
space
=
if
commit
.
space
>=
parent
.
space
then
space
=
if
commit
.
space
>=
parent
.
space
then
find_free_parent_space
(
range
,
parent
.
space
,
-
1
,
commit
.
space
,
times
)
find_free_parent_space
(
range
,
parent
.
space
,
-
1
,
commit
.
space
)
else
else
find_free_parent_space
(
range
,
commit
.
space
,
-
1
,
parent
.
space
,
times
)
find_free_parent_space
(
range
,
commit
.
space
,
-
1
,
parent
.
space
)
end
end
mark_reserved
(
range
,
space
)
mark_reserved
(
range
,
space
)
...
@@ -135,19 +141,19 @@ module Network
...
@@ -135,19 +141,19 @@ module Network
spaces
spaces
end
end
def
find_free_parent_space
(
range
,
space_base
,
space_step
,
space_default
,
times
)
def
find_free_parent_space
(
range
,
space_base
,
space_step
,
space_default
)
if
is_overlap?
(
range
,
times
,
space_default
)
then
if
is_overlap?
(
range
,
space_default
)
then
find_free_space
(
range
,
space_step
,
space_base
,
space_default
)
find_free_space
(
range
,
space_step
,
space_base
,
space_default
)
else
else
space_default
space_default
end
end
end
end
def
is_overlap?
(
range
,
times
,
overlap_space
)
def
is_overlap?
(
range
,
overlap_space
)
range
.
each
do
|
i
|
range
.
each
do
|
i
|
if
i
!=
range
.
first
&&
if
i
!=
range
.
first
&&
i
!=
range
.
last
&&
i
!=
range
.
last
&&
times
[
i
].
spaces
.
include?
(
overlap_space
)
then
@commits
[
reversed_index
(
i
)
].
spaces
.
include?
(
overlap_space
)
then
return
true
;
return
true
;
end
end
...
@@ -282,5 +288,9 @@ module Network
...
@@ -282,5 +288,9 @@ module Network
end
end
refs_cache
refs_cache
end
end
def
reversed_index
(
index
)
-
index
-
1
end
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment