Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
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
0
Merge Requests
0
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
converse.js
Commits
c9e68026
Commit
c9e68026
authored
Dec 13, 2012
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Better variable names
parent
abc0eed8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
12 deletions
+12
-12
weblate/trans/simplediff.py
weblate/trans/simplediff.py
+12
-12
No files found.
weblate/trans/simplediff.py
View file @
c9e68026
...
@@ -19,27 +19,27 @@ def diff(old, new):
...
@@ -19,27 +19,27 @@ def diff(old, new):
ohash
.
setdefault
(
val
,[]).
append
(
i
)
ohash
.
setdefault
(
val
,[]).
append
(
i
)
# Find the largest substring common to old and new
# Find the largest substring common to old and new
last
R
ow
=
[
0
]
*
len
(
old
)
last
_r
ow
=
[
0
]
*
len
(
old
)
sub
StartOld
=
subStartNew
=
subL
ength
=
0
sub
_start_old
=
sub_start_new
=
sub_l
ength
=
0
for
j
,
val
in
enumerate
(
new
):
for
j
,
val
in
enumerate
(
new
):
thisRow
=
[
0
]
*
len
(
old
)
thisRow
=
[
0
]
*
len
(
old
)
for
k
in
ohash
.
setdefault
(
val
,[]):
for
k
in
ohash
.
setdefault
(
val
,[]):
thisRow
[
k
]
=
(
k
and
last
R
ow
[
k
-
1
])
+
1
thisRow
[
k
]
=
(
k
and
last
_r
ow
[
k
-
1
])
+
1
if
(
thisRow
[
k
]
>
sub
L
ength
):
if
(
thisRow
[
k
]
>
sub
_l
ength
):
sub
L
ength
=
thisRow
[
k
]
sub
_l
ength
=
thisRow
[
k
]
sub
StartOld
=
k
-
subL
ength
+
1
sub
_start_old
=
k
-
sub_l
ength
+
1
sub
StartNew
=
j
-
subL
ength
+
1
sub
_start_new
=
j
-
sub_l
ength
+
1
last
R
ow
=
thisRow
last
_r
ow
=
thisRow
if
sub
L
ength
==
0
:
if
sub
_l
ength
==
0
:
# If no common substring is found, assume that an insert and
# If no common substring is found, assume that an insert and
# delete has taken place...
# delete has taken place...
return
(
old
and
[(
'-'
,
old
)]
or
[])
+
(
new
and
[(
'+'
,
new
)]
or
[])
return
(
old
and
[(
'-'
,
old
)]
or
[])
+
(
new
and
[(
'+'
,
new
)]
or
[])
else
:
else
:
# ...otherwise, the common substring is considered to have no change,
# ...otherwise, the common substring is considered to have no change,
# and we recurse on the text before and after the substring
# and we recurse on the text before and after the substring
return
diff
(
old
[:
sub
StartOld
],
new
[:
subStartN
ew
])
+
\
return
diff
(
old
[:
sub
_start_old
],
new
[:
sub_start_n
ew
])
+
\
[(
'='
,
new
[
sub
StartNew
:
subStartNew
+
subL
ength
])]
+
\
[(
'='
,
new
[
sub
_start_new
:
sub_start_new
+
sub_l
ength
])]
+
\
diff
(
old
[
sub
StartOld
+
subLength
:],
new
[
subStartNew
+
subL
ength
:])
diff
(
old
[
sub
_start_old
+
sub_length
:],
new
[
sub_start_new
+
sub_l
ength
:])
def
stringDiff
(
old
,
new
):
def
stringDiff
(
old
,
new
):
...
...
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