9344 Commits

Author SHA1 Message Date
Edwin Kempin
0cca74b78a Merge "Format Java files with google-java-format" 2017-06-14 07:27:25 +00:00
Han-Wen Nienhuys
b0fb0a7a96 Remove 'final' from method signatures across gerrit.
Change-Id: I986a5507aa26ceb28305a7b08991e85238bde0e3
2017-06-14 09:18:42 +02:00
David Pursehouse
5770973c3b Format Java files with google-java-format
Change-Id: I8ca4179befdb4ef83d5c660873bdcb862306d0a8
2017-06-14 16:02:57 +09:00
David Pursehouse
64e43c24ef Merge changes from topic 'permission-backend'
* changes:
  Replace canUpload with CREATE_CHANGE
  Convert GetAccess and canAddRefs to PermissionBackend
  Convert forge author, committer, server to PermissionBackend
  Push option bypass-review disables validation
2017-06-14 06:55:26 +00:00
Edwin Kempin
22d4074dec Merge changes I3d83aa5d,Ifa9d80d2,I65222959,I7f576ea0,I2edaf059
* changes:
  Remove superfluous final in gerrit/server/patch/
  Remove superfluous final from server/query/change
  Remove superfluous final from server/query/
  Remove superfluous final from gerrit/httpd/
  Remove unneeded final modifiers from gerrit-server/src/main/java/com/google/gerrit/server/git/*.
2017-06-14 06:42:54 +00:00
Shawn Pearce
ca1113e5bd Replace canUpload with CREATE_CHANGE
Check RefPermission.CREATE_CHANGE before creating a change, instead of
relying on the legacy RefControl.canUpload(). This delegates creation
decisions through the PermissionBackend.

Change-Id: Ic76e96ca6079a179ae65fa2de436fb6df929b6d9
2017-06-14 13:59:39 +09:00
Shawn Pearce
10aae18ff1 Convert GetAccess and canAddRefs to PermissionBackend
Introduce a new ProjectPermission CREATE_REF which supports hinting if
the user may be permitted to create references within the project.

This is similar to RefPermission CREATE_CHANGE where the parent scope
may be needed to test support for creation of a child.

Unlike CREATE_CHANGE, application code does still check RefPermission
CREATE during operations on the actual proposed reference name.

Change-Id: I02204500265cb97c4fb92f40f01b6c738c06b5b1
2017-06-14 13:53:34 +09:00
Shawn Pearce
e2923f43ab Convert forge author, committer, server to PermissionBackend
Change-Id: I081392237957d3dc4afc703ca2256e27954d3774
2017-06-14 13:53:34 +09:00
Shawn Pearce
1e964ead8b Push option bypass-review disables validation
Add RefPermission BYPASS_REVIEW which can be selectively requested
with a push option, for example:

  git push -o bypass-review origin master

When set this option skips validating the new commits if the user has
BYPASS_REVIEW permission in the PermissionBackend. For the default
backend this is a set of permissions that must all be present in order
to use this option.

Gerrit still ignores the bypass-review option on refs/meta/config (as
it must validate the configuration parses), and on the refs/for/ magic
branch, where it needs to update code reviews.

Change-Id: I80ad4785226de7113f0bf6812c7709ba2c6ec73c
2017-06-14 13:53:34 +09:00
David Pursehouse
419ed573b9 BranchApi: Add method to get the branch's reflog
GetReflog uses Repository#getReflogReader, but this is not implemented
by DfsRepository which is used in the test framework. As a result, calls
to this API method from tests results in UnsupportedOperationException.

Modify GetReflog to catch the UOE and rethrow as MethodNotAllowed, so
we get a graceful failure rather than "internal server error".

In the tests, expect MethodNotAllowed, with a TODO to rework when/if
the implementation of getReflogReader is done in DfsRepository.

Change-Id: I0d0d718ca4e4ecf2c544ea6e912397c20e2fd7e3
2017-06-14 12:56:20 +09:00
David Pursehouse
f0d37e4f80 GetReflog: Move ReflogEntryInfo to a separate class in extension API
Change-Id: Ib9ab9b16cacaed88c5e1d901af37be086b635d0b
2017-06-14 12:53:42 +09:00
Han-Wen Nienhuys
45351acfd6 Remove superfluous final in gerrit/server/patch/
Change-Id: I3d83aa5d8a32a35157afacf8387e5b082719817f
2017-06-13 17:59:40 +02:00
Han-Wen Nienhuys
cc15dd2970 Remove superfluous final from server/query/change
Change-Id: Ifa9d80d26083dfe34eded8a960f9da92eab2aba9
2017-06-13 17:59:40 +02:00
Han-Wen Nienhuys
307eb1ed96 Remove superfluous final from server/query/
Change-Id: I65222959ecf27a3b1441d1badd8a68a1b735ebe1
2017-06-13 17:59:40 +02:00
Han-Wen Nienhuys
1a2f731637 Remove unneeded final modifiers from gerrit-server/src/main/java/com/google/gerrit/server/git/*.
Change-Id: I2edaf0599918c48f021abacaed198af67611773a
2017-06-13 17:59:40 +02:00
Han-Wen Nienhuys
61f6565591 Add a success and attempt metric for cross-project topic submissions.
Change-Id: Ice704290224064bca9f3389bec7419c21054baa0
2017-06-13 15:50:13 +02:00
Edwin Kempin
18962aa2b5 Merge "Make AccountCache available to Prolog predicates" 2017-06-13 13:27:59 +00:00
Edwin Kempin
f33e810d90 Merge "Accounts: Add method to get several accounts at once" 2017-06-13 12:40:46 +00:00
Edwin Kempin
c056334599 Make AccountCache available to Prolog predicates
Some plugins implement Prolog predicates that need to get accounts.
E.g. the find-owners plugin has a Prolog predicate that loads the
accounts for all approvals on a change.

SubmitRuleEvaluator sets ReviewDb as a stored value in the Prolog
environment and hence Prolog predicates in plugins have access to it.
When accounts are moved to NoteDb accounts are no longer accessible
through ReviewDb. Hence the Prolog predicates need a different way to
get accounts. For this we make the AccountCache available by setting it
as a stored value in the Prolog environment.

Using the account cache instead of accessing the database should also
improve performance of Prolog predicates that need to access accounts.

Change-Id: I363a8ee0400622b4cc25d44f1d6fc876c951d412
Signed-off-by: Edwin Kempin <ekempin@google.com>
2017-06-13 14:35:18 +02:00
Edwin Kempin
8c36cc8805 Merge "Accounts: Add method to get all accounts" 2017-06-13 11:52:40 +00:00
Edwin Kempin
5bd2a6d12a Accounts: Add method to get several accounts at once
Change-Id: I688c854dfdf5261f0b80d2c5a9dee7f0c6a37852
2017-06-13 13:48:52 +02:00
Alice Kober-Sotzek
03c48fc727 Merge "Add support for specifying the cherry-pick base commit" 2017-06-13 11:48:33 +00:00
Changcheng Xiao
e333258b94 Add support for specifying the cherry-pick base commit
This change extends the existing cherry-pick endpoints to allow
users to specify the base commit of the cherry-pick destination.

If the base commit represents a visible change revision on the
destination branch, the change status must be either 'New' or
'Merged'.

Alternatively, the base commit can be a merged commit on the
destination branch with no change associated with it.

Change-Id: I6721a2d88f4b73058dc1abf3e85c4184e46088c5
2017-06-13 12:57:15 +02:00
Edwin Kempin
75bd447d4c Accounts: Add method to get all accounts
Having this method allows us to implement loading all accounts from
NoteDb later.

Change-Id: Ifc1d1113f0687ae599a7cbad56cd50ae1c9a3608
Signed-off-by: Edwin Kempin <ekempin@google.com>
2017-06-13 11:47:32 +02:00
Wyatt Allen
c1373ecd66 Adjust email diff colors
Bug: Issue 6471
Change-Id: I8b2a60837350b741f0a77fe04acc90f42893c563
2017-06-12 15:02:03 -07:00
Dave Borowitz
bd947d4ae5 Merge "Remove Executor#unregisterWorkQueue"
* submodules:
* Update plugins/replication from branch 'master'
  - Merge "Stop using WorkQueue#unregisterWorkQueue."
  - PushOne: Remove redundant string concatenation
    
    Change-Id: Idfe060d260eb0343d0766f4c6d6cea6cfbf733bb
2017-06-12 17:05:45 +00:00
Han-Wen Nienhuys
bb798b00bb Remove Executor#unregisterWorkQueue
We use ScheduledThreadPoolExecutor#terminated to manage cleanup of
WorkQueue. Callers of unregisterWorkQueue should just delete the call.

Change-Id: I0208c8643bd71eb287ff553f80e7ffe547f3ffbe
2017-06-12 15:51:04 +02:00
Alice Kober-Sotzek
d1a2e07e4f Merge changes from topic 'improve-diff-for-rebase'
* changes:
  Highlight hunks which are due to rebase on PolyGerrit
  Copy due_to_rebase to subgroups in gr-diff-processor
  Move diff tests from RevisionIT to RevisionDiffIT
  Mark hunks which are present due to a rebase when diffing patch sets
2017-06-12 13:20:22 +00:00
David Pursehouse
f05ee3fc73 Merge branch 'stable-2.14'
* stable-2.14:
  Fix documentation of the review command
  Fix online reindexing for plugins-dependent rules
  De-couple PluginModule and PluginRestApiModule registration

Change-Id: Ic6dd1c019e7a451f325d378b071f2347f82c2e44
2017-06-12 20:03:04 +09:00
Luca Milanesio
c0ac1ba9c7 De-couple PluginModule and PluginRestApiModule registration
The registration of PluginModule and PluginRestApiModule needs to be
decoupled because they are conceptually separate, even if one (PluginModule)
needs to happen before the other (PluginRestApiModule).

This is a pre-requisite for the next change I87da6ac6 where the PluginModule
registration needs to be moved around without necessarily having an impact
on the PluginRestApiModule.

Change-Id: I80fee34e5bda5afb480c8d103e6e83b8ae11c8eb
2017-06-12 10:25:03 +01:00
Edwin Kempin
d56f26808c ExternalIdCacheImpl: Cache external IDs by email
The ExternalIdCache allows to get external IDs by account and by email.
So far in memory it only held a Multimap for external IDs by account.
When external IDs by email were requested it iterated over all external
IDs from the map looking for matches by email. Instead of iterating over
all external IDs each time external IDs by email are requested we now
have a seperate Multimap to store external IDs by email. This improves
lookup times by email at the cost of additional memory for caching
external IDs by email. Once lookup of external IDs by email is efficient
we can get rid of the AccountByEmailCache and rather lookup accounts by
email through the ExternalIdCache. This will be implemented in a
follow-up commit.

Change-Id: I33b4bc5d6e710eafbf136782a14e0d819edd74e0
Signed-off-by: Edwin Kempin <ekempin@google.com>
2017-06-09 16:10:37 +02:00
Edwin Kempin
6396d6ddc6 Add basic consistency checker for accounts
So far it only checks that preferred emails are backed by
corresponding external IDs. E.g. change I2b3c5c9d assumes that each
preferred email exists as external ID.

Change-Id: I824caa34545b1ba147fb71ede503104ba1d5481c
Signed-off-by: Edwin Kempin <ekempin@google.com>
2017-06-09 16:10:36 +02:00
Alice Kober-Sotzek
2f62486149 Mark hunks which are present due to a rebase when diffing patch sets
The diff between two patch sets contains hunks which weren't
introduced by either patch set if a rebase occurred between those
patch sets. Previous optimizations for this case simply omitted all
files which aren't touched by either of the patch sets.

This change goes one step further: All hunks which can clearly be
identified as being introduced by a rebase are marked. In case of
doubt (e.g. they overlap with a regular hunk), they aren't marked.

To be consistent with the previous behavior, we exclude all files from
the result which only contain hunks due to rebase. In some cases (e.g.
a patch set touches 'fileA' but all identified hunks were introduced
by the rebase), this rule can be stricter than the previously mentioned
(as the previous rule would still show file 'fileA' but we exclude it
now).

Hunks which are introduced by a rebase are identified by computing
the diff between the parents of the two patch sets and transforming
the result to differences in terms of treeA of patch set A and treeB
of patch set B. This follows a suggestion which was posted as a comment
(https://gerrit-review.googlesource.com/c/33091/5//COMMIT_MSG#7) in
change I63d3a21ad4f.

As we always determine which hunks are introduced by a rebase when
two commits are explicitly specified which don't share a common
parent, we will determine those hunks even when we compute the
diff between the parents of the patch sets provided that those
parents fulfill the condition of being separated by a rebase. Those
situations should be rare and hence we refrain from adding
optimizations for this case for the moment.

Bug: Issue 217
Change-Id: If06381d506d360f0e3d24d078dcb54692698e766
2017-06-09 13:38:43 +02:00
David Pursehouse
c93e48099b Merge "Make it configurable whether the first user should become admin" 2017-06-09 10:24:58 +00:00
Edwin Kempin
53d52ba6d6 Make it configurable whether the first user should become admin
By default the first user that logs in to Gerrit automatically becomes
administrator. This is useful to bootstrap the authentication database.
However in automated server setups it should be controlled explicitly
who becomes admin and then it makes sense to disable this functionality.
The default behaviour (make the first user admin) is not changed.

Change-Id: Ic9778824e96ce4f61d974412aaaa6b40e6b465ba
Signed-off-by: Edwin Kempin <ekempin@google.com>
2017-06-09 11:26:11 +02:00
Edwin Kempin
acefc3d425 AccountsUpdate: Move comment about reindexing to class JavaDoc
This is where it was meant to be.

Change-Id: Iefad88afed878a22888df1c0cd73a4d6ea6aaf6a
Signed-off-by: Edwin Kempin <ekempin@google.com>
2017-06-09 11:22:09 +02:00
Edwin Kempin
444a2d5b5e Allow using ExternalIdsUpdate and AccountsUpdate without reindex
At Google we need to use these classes in a context where reindex is not
possible. Hence reindexing for the classes must be optional.

Change-Id: Id1017853982c6ca4e1cfa024f73d20dffad82bd6
Signed-off-by: Edwin Kempin <ekempin@google.com>
2017-06-09 11:22:02 +02:00
Edwin Kempin
4847c3de4e Let ExternalIdsUpdate take care to evict accounts from the account cache
The account cache holds AccountState instances which contain the
external IDs of the accounts. Hence an account must be evicted from the
account cache when its external IDs are updated. At the moment it's the
responsibility of the caller to do the account eviction, but it can
easily be forgotten and it's more convenient if ExternalIdsUpdate takes
care of it. For some scenarios this may result in a few more cache
evictions (e.g. account creation), but for most operations the number of
account evictions should stay the same.

After updating external IDs the corresponding accounts also need to be
reindexed, but this is automatically done when accounts are evicted from
the account cache.

Change-Id: I1af02c7576eea81bb229a4663cb1e067ab137784
Signed-off-by: Edwin Kempin <ekempin@google.com>
2017-06-09 09:56:23 +02:00
Edwin Kempin
fbcd038e53 Don't index missing accounts
AccountCache#get returns an empty AccountState instance for missing
accounts. Rather use AccountCache#getOrNull and don't index missing
accounts.

Change-Id: I6984e3c9cfc452fb8991031e1a5283a6792b4d96
Signed-off-by: Edwin Kempin <ekempin@google.com>
2017-06-09 09:40:27 +02:00
Edwin Kempin
ef360d8541 AccountCache: Add getOrNull method that returns null for missing account
AccountCache#get returns an empty AccountState instance to represent a
missing account. Add a new AccountCache#getOrNull method that returns
null if an account is missing so that callers can special-case
non-existing accounts.

Change-Id: I51dcca79a4ec3ec71a09c9ec0da51fda03e19928
Signed-off-by: Edwin Kempin <ekempin@google.com>
2017-06-09 09:40:17 +02:00
Edwin Kempin
6e5864baea AccountCache: Document get and getIfPresent methods
Some callers make wrong assumptions about these methods. Documenting
these methods can help to avoid confusion.

Change-Id: I23b9f69c9e18c8de201f53d2a2db1f1e3aa7075c
Signed-off-by: Edwin Kempin <ekempin@google.com>
2017-06-09 09:38:04 +02:00
David Pursehouse
22ced9f093 Merge "Merge branch 'stable-2.14'" 2017-06-09 00:45:34 +00:00
Alice Kober-Sotzek
cfb5a76489 Merge changes from topic 'ccs'
* changes:
  Preserve ReviewerState when reverting a change
  Persist CCs on Git push
2017-06-08 14:37:19 +00:00
Patrick Hiesel
e403bcb8d1 Preserve ReviewerState when reverting a change
This commit fixes a bug that would falsely copy CCs as reviewers when
reverting a change.

Bug: Issue 6337
Change-Id: I7c659b4eb2aa98385d5e12c0323e645b1a5daf46
2017-06-08 14:47:08 +02:00
Patrick Hiesel
8e6dafd7ba Persist CCs on Git push
Previously, we have sent an initial email to CCs added upon push, but
have not persisted them. This change adds logic and tests to do so.

CCs have native support in NoteDb and legacy support in ReviewDb where
they are added as reviewers instead. This mirrors what we do in
PostReviewers and PostReview.

Change-Id: I4177526707141ffe676a5e4db534aeb740b7d53f
2017-06-08 14:44:39 +02:00
Patrick Hiesel
ba74460ffc Merge branch 'stable-2.14'
* stable-2.14:
  Use change number instead of change id for inbound email

Change-Id: Ieb2df971559c6f8bacf8e25a4eee73b63a774efc
2017-06-08 14:22:45 +02:00
David Pursehouse
ad6b3ccba5 Merge "Use change number instead of change id for inbound email" into stable-2.14 2017-06-08 12:09:05 +00:00
Saša Živkov
91c3c6140f Merge "PermissionBackend: Make considering admin credential configurable" 2017-06-08 11:12:13 +00:00
Patrick Hiesel
30ca4e0eee Use change number instead of change id for inbound email
Previously, we used the change id to identify a change from an inbound
email. This is error prone as the change id as such isn't unique without
a project and a branch (triplet). This change replaces this use with the
change number instead, which is unique by itself.

Bug: Issue 6449
Change-Id: I4f9696f48c2136d47ae94f59bf96a148ae598ebb
2017-06-08 09:57:34 +02:00
Edwin Kempin
7a8022c764 AccountAccess: Remove unused methods
The database indexes that were only needed to support these methods are
deleted.

Change-Id: Iefc47c2dbe404453636d347c4fc2f3bc9a5c1cd4
Signed-off-by: Edwin Kempin <ekempin@google.com>
2017-06-07 17:09:15 +02:00