10241 Commits

Author SHA1 Message Date
David Ostrovsky
af0e80b954 Bump JGit version to 3.2.0.201312181205-r
Change-Id: Ib8a26e39d8be17854701250eb32f1cc91615ac17
2014-01-05 20:11:01 +01:00
Shawn Pearce
1bcb2ca180 Merge "Move change id and status to left side of ChangeScreen2" 2014-01-03 22:49:17 +00:00
Shawn Pearce
0e401fc83d Merge "ChangeScreen2: Support [/] keys to navigate files in a cycle" 2014-01-03 22:08:04 +00:00
Shawn Pearce
a63e81919a Merge "SideBySide2: Fix max width of comment widget groups" 2014-01-03 22:04:19 +00:00
Shawn Pearce
763c5df979 SideBySide2: Fix max width of comment widget groups
The group should have a max-width of 650px. This allows the group
to show the right side drop shadow on a normally sized window,
making the comment appear to float a bit on the page.

The max width was incorrectly applied to the header line of the
comment, andwas not being used by the browser to size the group.

Change-Id: I564c7fd9b154d64cdf1b20836351f40954a4900d
2014-01-03 14:01:10 -08:00
Dave Borowitz
f9ae78e51a Inject ChangeNotes into ChangeControl
Almost all of the places that will need a ChangeNotes (when we start
reading from that class) should already have a ChangeControl, so this
is a convenient way to ship it around.

To deal with the migration, do not eagerly load ChangeNotes from the
constructor. We could lazily load on e.g. getApprovals(), but that
would require catching OrmException in more places.

Change-Id: I545b555e8369f7f0f775b5188079ea3e93ed9cef
2014-01-03 13:37:46 -08:00
Shawn Pearce
5300a4025e ChangeScreen2: Support [/] keys to navigate files in a cycle
When viewing the last file pressing ] takes the user up to the
change screen. Allow [ to return them to the last file, much as [
is an undo for an accidental ] between files.

Likewise allow ] to enter into the commit message.

Change-Id: Id1fac2cb0a34ecd87f2526400019bd65bd294186
2014-01-03 13:29:58 -08:00
Shawn Pearce
0ff2ac5be2 Merge "SideBySide2: Avoid duplicate draft creation by fixing race condition" 2014-01-03 21:04:52 +00:00
Shawn Pearce
5921c44338 SideBySide2: Avoid duplicate draft creation by fixing race condition
On slower networks/servers users can create duplicate drafts by:

 - start typing a new draft comment
 - press ctrl + s, u

The ctrl+s key combo starts an RPC to insert the new draft and
transfers focus to another part of the page where u is a valid
key binding to go up to the change. When the u key is processed
the SideBySide2 screen starts to go up, which tries to save all
pending drafts. This starts another RPC to insert the draft. Both
RPCs eventually complete and there are now two identical drafts on
the same line.

Fix this by having the draft box remember which CallbackGroup it
is currently processing for. If another save call arrives before
this is finished the groups are chained together. In the case
describe above the CallbackGroup for the "up to change/save all"
activity will become a listener on the existing save RPC's group,
receiving notification when the save completes.

Change-Id: Ia4ecbb82b6c2866b8faf3d5995c995dca77be28a
2014-01-03 13:01:15 -08:00
Dave Borowitz
aa3d825de3 Make ChangeData constructors private
Callers should always be using the factory method, except for a
particular kind of test within the same package.

Change-Id: I5cf55f57781b3667255797d198448bd7c1f21ade
2014-01-03 11:42:53 -08:00
Dave Borowitz
89aa86394e Record reviewer state in notes database
Stop implicitly adding/removing reviewers by adding an arbitrary
PatchSetApprovals with a 0 vote. This is ugly and error-prone,
especially when LabelTypes change.

Instead, use the existing ReviewerState enum, adding a REMOVED type
as a tombstone. When parsing, record these during the walk, and prune
all REMOVED tombstones after the fact.

Change-Id: Iffb0517eb0162eb6cce66bf36d905a6eb60e75da
2014-01-03 11:03:25 -08:00
Shawn Pearce
037c382545 Move change id and status to left side of ChangeScreen2
Some users have reported missing the subject line and only reading
the commit message body on ChangeScreen2.  The subject is bold and on
a "trimColor" (e.g. grey) background while the message body is on the
page background color (e.g. white).  This coloring makes the subject
appear to be unrelated to the message, and reviewers find themselves
missing important context when trying to understand the commit.

Move the subject line down into the commit message body area and
slide the change number and status into the left 1/3rd of header
line bar.

Change-Id: I61c3143c636e234776189d545def9ff528eaa2bf
2014-01-03 18:59:10 +00:00
Shawn Pearce
d2d4d1cead SideBySide2: Fix Reply/Done buttons in add regions
If two comments are placed on different lines in a single add
region the Reply/Done buttons on the first comment were broken.
The breakage was caused by the group's peer being replaced in sideA
by the second group's peer, so the first group's peer was never
attached to CM3.

Always attach both members at the same time, from either map.

Change-Id: Iccce04ef5f8758f35376829140e0e2f308d387a2
2014-01-03 10:56:25 -08:00
Shawn Pearce
ab6739b3d6 SideBySide2: Only restore selection at discard for new comments
If a reply is created and discarded, do not create a range
selection on the range supplied from the published comment.

Change-Id: Id8adfc080cba252d3d47bc7b0f5eacb03853aeb6
2014-01-03 10:56:25 -08:00
Dave Borowitz
86d070f83e Eliminate potential NPEs with ChangeData.getChange()
Callers were supposed to be calling hasChange() to determine whether
getChange() would return null, but none were. Remove this error-prone
pair of methods and just use change(), which includes lazy loading.
There are a few places where we need to catch an additional
OrmException but these are easy enough to fix.

Change-Id: I23335e362715f59e2c093ffec88427739ff0cffc
2014-01-03 09:10:45 -08:00
Colby Ranger
784a5b30a0 Defer handling onSuccess for large REST payloads
If an API returns a very large response, the parseJson call can take
75ms - 200ms to complete. Detect stalls greater than 75ms and defer
the onSuccess() handling to the next event loop so it isn't as
noticeable to the user.

Change-Id: Icc904f0c0e42b45771d5c3b003e89f845dbfb038
2014-01-03 08:45:32 -08:00
Dave Borowitz
23dc4d1bdc Store PatchSetApprovals in a git-notes-based database
Add a new ref namespace refs/changes/*/*/meta for storing the state of
a Gerrit change in Git. Information about the change is mostly stored
in commit messages, the entire history of which are read at load time
to populate information about the change. Eventually, information tied
to a particular patch set will be stored in a git note referring to
the patch set's commit.

This data format only allows fast access to data on a per-change
basis. Lookups by other keys (e.g. approvals by user) will depend on the
secondary index.

The commit message format is simple:

  Update patch set 1

  <optional cover message>

  Patch-Set: 1
  Label: Code-Review=+1

The subject line is machine-generated and callers should attempt to
make it descriptive, but this is not strictly required. The
cover message is user-provided (not implemented in this change). At
least the Patch-Set footer line is required for the time being; it is
likely we will want to enforce there always being at least one footer to
fend off user-provided cover messages that themselves contains
footers.

The author of the commit is the end-user performing the update, using
their full name and email address. The committer is the same user, but
includes the Gerrit account ID in the email address for
disambiguation. (Eventually, we may decide that the (name, email)
combination is enough to uniquely identify a user, but for now we
still require the account ID.)

On the code side, reading and writing changes from this ref is
implemented with two VersionedMetaData classes:

ChangeNotes implements the read operation. When a ChangeNotes is
loaded, it traverses the entire history of the ref and populates the
object with all relevant information. Traversing the entire history
should be a fast operation on most changes, which typically have
roughly tens of operations.

ChangeUpdate implements the write operation. Unlike the traditional
database, where operations are organized around read-modify-write
operations on various entities spread across tables, a ChangeUpdate
encapsulates a set of updates that can be applied atomically. Because
each commit has a single author, timestamp, and patch set, these are
logically restricted to operations performed by a single user on a
single patch set. This corresponds better to the typical usage of the
database, where a single end-user is performing an operation on a
single change via a REST endpoint.

ChangeNotes and ChangeUpdate are separate VersionedMetaData subclasses
for a few reasons, mostly technical. First, it should not be necessary
in all cases to slurp all change data via ChangeNotes before preparing
a ChangeUpdate. Second, due to subtleties like LabelType sorting, it
would be tricky to make ChangeNotes mutable in such a way that the
result of reading it after one or more mutations would be the same as
if that change were read freshly from the git data. Keeping
ChangeNotes immutable and ChangeUpdate separate makes it less tempting
to assume this behavior.

This change implements only reading/writing for
ChangeNotes/ChangeUpdate; they are not yet used in any read/write code
paths in the server.

Change-Id: Id28978a92f3b197c8b5be6e2db0c1e3923f2211e
2014-01-03 08:31:47 -08:00
Shawn Pearce
4827706dbe Merge "Include modified B side lines when whitespace is ignored" 2014-01-03 15:56:25 +00:00
Shawn Pearce
6e9a9ff0d1 SideBySide2: Hide Reply/Done buttons when reply box exists
If a draft is already present and replying to this published comment,
hide its reply and done buttons until the draft is discarded or is
also published.

Change-Id: I9ca9dc6164c00d6af58f961e3ffb43b44b8e289d
2014-01-03 07:06:19 -08:00
Shawn Pearce
a710038e8c Merge "Fix examples of InitStep in plugin documentation" 2014-01-03 15:02:28 +00:00
Shawn Pearce
b0229c9cb6 Merge "SideBySide2: Display hint next to comment insert bubble" 2014-01-03 15:01:48 +00:00
Edwin Kempin
93e7d5de80 Fix examples of InitStep in plugin documentation
InitStep has a new postRun() method which must be implemented.

Modifications of the All-Projects project.config have to be done in
the postRun() method since during the run() method the site does not
exist yet if a new site is initialized.

Change-Id: I186817f76b328a344d1a04f982d5bc2973688c25
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
2014-01-03 09:55:48 +01:00
Edwin Kempin
62f600229b Merge "SideBySide2: Fix transfer of focus into comment box" 2014-01-03 08:20:01 +00:00
Edwin Kempin
bab36d4661 Merge "SideBySide2: Restore selection after discarding a new comment" 2014-01-03 08:14:44 +00:00
Shawn Pearce
a01bb3d795 SideBySide2: Move insert comment bubble on resize of draft box
If a draft comment box grows its text area and there is a selection
below the box, the insert comment bubble for that selected region
needs to move down the page.  Update the selection whenever the box
grows to force the bubble to slide.

Change-Id: I30a137a51a60a35c2c9234126ea854fb4c02b3c0
2014-01-02 23:18:23 -08:00
Shawn Pearce
a76c67a04c SideBySide2: Restore selection after discarding a new comment
If a comment is created and immediately destroyed (e.g.  press 'c'
then 'esc'), restore the range selection for the comment.  This allows
the user to quickly adjust the range and recreate the comment, fixing
simple errors where they missed a character or two at the end of the
selected range.

Change-Id: I70e74b40fa8635793360dca4f83fb63a01c9b750
2014-01-02 21:58:55 -08:00
Shawn Pearce
357c951522 SideBySide2: Fix transfer of focus into comment box
Focus needs to be transferred after the browser event loop returns.
I don't recall specifically why this is necessary, but without the
defer the new comment box does not have focus.

Setting the cursor position immediately after transferring focus
appears to work, so these tasks can be combined together.

Change-Id: Ic28a1ba8d346779f20b4aef0bd794469377c3ddc
2014-01-02 21:53:10 -08:00
Shawn Pearce
425a2be935 Include modified B side lines when whitespace is ignored
SideBySide2 needs the modified B side lines even if the lines are
"common" when compared to A using the selected whitespace ignore
option. The modified B lines must be used so the text aligns properly
with surrounding context, such as wrapping some unmodified code in
an if block.

Send these by splitting an "ab" block into "a, b, common:true",
allowing the UI to correctly reconstruct the B side.

Change-Id: I5e045c32d9e86434094e03e844fb80ef4186993f
2014-01-02 21:30:49 -08:00
Shawn Pearce
2064617e77 SideBySide2: Display hint next to comment insert bubble
The keyboard binding 'c' is very useful to insert a comment, as users
are about to start typing anyway.  Make this more widely known by
placing a text bubble next to the insert comment bubble with the
message "press [c] to comment".

The bubble is also clickable, giving the user a bigger target than the
16x16 icon that also appears above the insertion point.

Change-Id: Ibc1f874dd5f9c852a9316c11128a691f4c21c288
2014-01-02 17:50:25 -08:00
Dave Borowitz
742220978e Merge "Fix race conditions in LabelTypes map creation" 2014-01-03 00:02:58 +00:00
Dave Borowitz
9cad868a80 Fix race conditions in LabelTypes map creation
Change-Id: I9e6d51f73bd664e82d9f54d127bbdd5bc46ab382
2014-01-02 15:58:39 -08:00
Shawn Pearce
e40d4f1ae4 Merge "Fix grammar error in GetDiff" 2014-01-02 23:44:56 +00:00
Shawn Pearce
af958998d8 Fix grammar error in GetDiff
Change-Id: Ie3f51e93c1fe5b13a000fcc9ecc9372762755e14
2014-01-02 15:42:09 -08:00
Colby Ranger
a72c23cee3 Change the color of green for ~ in related changes.
The previous color looked too neon and this is a darker green.

Change-Id: Ief3d668b01efa73262b726f657467ff080419ff5
2014-01-02 10:53:28 -08:00
Shawn Pearce
ccbae73dff SideBySide2: Fix SkipBar expansion to cleanup SkipManager
When CM3 enters a skipped region the bars are removed. They also
must be removed from the SkipManager's collection.

Do not modify the CM3 selection when CM3 enters a skipped region.
This should only attempt to happen during a user click in the bar.

Change-Id: Ieebde1e1b1bdd9e4714849165def65e65b55668e
2014-01-02 10:03:26 -08:00
Shawn Pearce
3e15684ca7 Revert "SideBySide2: Track SkipBar instances by the starting line"
This reverts commit 1df5a8f00fbe69ec3b386ed3487a2ae0c229a966.

Tracking the bar using a SortedMap is not necessary.  The skip
bars are removed automatically by CM3 now when search enters into
a skipped region.

Change-Id: Ia3194692c7a8e7c098bc97d9dc2ebd3fa89fc5ca
2014-01-02 09:50:22 -08:00
Shawn Pearce
8dc27a1741 Merge "SideBySide2: Expand skipped regions on search result matches" 2014-01-02 17:01:18 +00:00
Shawn Pearce
8466617df4 SideBySide2: Expand skipped regions on search result matches
Allow CM3 to expand an entire skipped region of a single
search result is found within the region.

Change-Id: Iaaf139a2ff9a0d7a2c018b7195d093eac1634ab2
2014-01-02 09:00:11 -08:00
Shawn Pearce
86df86cff1 Merge "SideBySide2: Trim empty line from end of range selection" 2014-01-02 16:53:20 +00:00
Shawn Pearce
5a956528e2 Merge "SideBySide2: Fix up first line handling in scroll synchronizer" 2014-01-02 16:43:44 +00:00
Shawn Pearce
dfbe6d6ead Add MessageOfTheDay extension point for plugins
Allow plugins to contribute messages to the UI during initial page
load. Gerrit displays the messages in a butter bar at the top of
the page and allows users to hide them with the "Dismiss" button.

Messages are hidden per-browser using a cookie named after the
message id, set to expire at a date supplied by the server. After
this date the same message could redisplay if the server sends the
same message again.

Change-Id: I0bcca845f501cbeb8c31356fff398c3adb43099a
2014-01-02 08:19:57 -08:00
Saša Živkov
17bb675699 Merge "Update org.pegdown:pegdown to 1.2.1" 2014-01-02 09:40:00 +00:00
Shawn Pearce
bfc20e1f0f SideBySide2: Trim empty line from end of range selection
When creating a new comment on a selected region, trim off any empty
line at the end of the selection.

This fixes a common problem when the user has selected an entire
paragraph of text and finished the selection at the start of the next
line, which logically appears to be the end of the paragraph.
Comments were inserting below this empty line, as the empty line was
set as the end of the range.

Change-Id: Ib5fc67f5a0c563b701c84d92e11886e0116e3a73
2014-01-01 14:14:28 -08:00
Shawn Pearce
7ba907963c SideBySide2: Fix up first line handling in scroll synchronizer
When a line is inserted at the start of the file the A side inserts a
padding widget above the line.  CM3 doesn't always include this widget
height in the heightAtLine() computation on the A side, causing the
files to become unaligned after scrolling down and then back up.

Special case the 0th line in the editors by assuming these will be
aligned at the very top of the page on either side and just use pixel
coordinates.

Change-Id: I91f7d8afe89fa7c22ec4dcf385d24a4a8d284421
2014-01-01 14:04:24 -08:00
Mani Chandel
1fdcc1ea25 ChangeScreen2: Make commit sha1 copyable
Make Commit-Id copyable similar to Change-ID
so that users can easily copy it.

Feature: Issue 2191
Change-Id: I5f0e955432307f8c32c733ea7e0ed2568c4dd82d
2013-12-31 17:27:51 +05:30
Shawn Pearce
9cc16a0301 Merge "SideBySide2: Track SkipBar instances by the starting line" 2013-12-31 01:15:24 +00:00
Shawn Pearce
1df5a8f00f SideBySide2: Track SkipBar instances by the starting line
Use a SortedMap to track the SkipBars, indexed by first line number
hidden by the bar. This simple refactoring allows for a future
change to find if a line is covered by a skip bar.

Change-Id: Iee71856e0c24140a10c0ee4938abfcef6490d6e9
2013-12-30 16:55:52 -08:00
Shawn Pearce
9dff161cf4 SideBySide2: Add shift-m to mark reviewed and open next file
In the old UI "M" marked the reviewed flag (if not already set)
and moved to the next file in the change. Implement a similar
behavior in the new SideBySide2 UI.

Bind as "shift m" instead of "M" due to vim mode using lowercase
"m" as a mark character, which some users may actually use to make
bookmarks during a review.

Change-Id: I1e7780e6265fa3380aae09c034583dec7ec4830a
2013-12-30 16:30:20 -08:00
Shawn Pearce
132194e80a SideBySide2: Bind shift-{n,p} to navigate comments
The old screen supported N and P to jump to next and previous
comments in the file, similar to n and p moving over modified
regions.

Bind shift-n and shift-p to navigate through comments.

Change-Id: I8fb788f438987e2448d39b62ced1e7615d32546e
2013-12-30 16:09:43 -08:00
Shawn Pearce
6f3453863a Pass only Change.Id for async background indexing
The background worker thread creates its own database connection
to read the record. The change could have been modified between
the time it is enqueued, and the time the indexing is processed.
Always read from the database in the background thread to ensure
the index gets the most recent possible data.

This may fix some index state errors on gerrit-review (and friends).

Change-Id: Ifab8d0ba7c9dcac54b7e168b86e9a82a3c681ea5
2013-12-30 14:42:08 -08:00