~ubuntu-branches/ubuntu/wily/phabricator/wily

« back to all changes in this revision

Viewing changes to phabricator/src/applications/herald/adapter/HeraldDifferentialRevisionAdapter.php

  • Committer: Package Import Robot
  • Author(s): Richard Sellam
  • Date: 2015-06-13 10:52:10 UTC
  • mfrom: (0.30.1) (0.29.1) (0.17.4) (2.1.9 sid)
  • Revision ID: package-import@ubuntu.com-20150613105210-5uirr7tvnk0n6e6y
Tags: 0~git20150613-1
* New snapshot release (closes: #787805)
* fixed typo in logrotate script (closes: #787645)

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 
6
6
  protected $revision;
7
7
 
8
 
  protected $explicitCCs;
9
8
  protected $explicitReviewers;
10
 
  protected $forbiddenCCs;
11
 
 
12
 
  protected $newCCs = array();
13
 
  protected $remCCs = array();
14
9
  protected $addReviewerPHIDs = array();
15
10
  protected $blockingReviewerPHIDs = array();
16
11
  protected $buildPlans = array();
110
105
    return $object;
111
106
  }
112
107
 
113
 
  public function setExplicitCCs($explicit_ccs) {
114
 
    $this->explicitCCs = $explicit_ccs;
115
 
    return $this;
116
 
  }
117
 
 
118
108
  public function setExplicitReviewers($explicit_reviewers) {
119
109
    $this->explicitReviewers = $explicit_reviewers;
120
110
    return $this;
121
111
  }
122
112
 
123
 
  public function setForbiddenCCs($forbidden_ccs) {
124
 
    $this->forbiddenCCs = $forbidden_ccs;
125
 
    return $this;
126
 
  }
127
 
 
128
 
  public function getCCsAddedByHerald() {
129
 
    return array_diff_key($this->newCCs, $this->remCCs);
130
 
  }
131
 
 
132
 
  public function getCCsRemovedByHerald() {
133
 
    return $this->remCCs;
134
 
  }
135
 
 
136
113
  public function getReviewersAddedByHerald() {
137
114
    return $this->addReviewerPHIDs;
138
115
  }
221
198
        return mpull($projects, 'getPHID');
222
199
      case self::FIELD_DIFF_FILE:
223
200
        return $this->loadAffectedPaths();
224
 
      case self::FIELD_CC:
225
 
        if (isset($this->explicitCCs)) {
226
 
          return array_keys($this->explicitCCs);
227
 
        } else {
228
 
          return $this->revision->getCCPHIDs();
229
 
        }
230
201
      case self::FIELD_REVIEWERS:
231
202
        if (isset($this->explicitReviewers)) {
232
203
          return array_keys($this->explicitReviewers);
297
268
    assert_instances_of($effects, 'HeraldEffect');
298
269
 
299
270
    $result = array();
300
 
    if ($this->explicitCCs) {
301
 
      $effect = new HeraldEffect();
302
 
      $effect->setAction(self::ACTION_ADD_CC);
303
 
      $effect->setTarget(array_keys($this->explicitCCs));
304
 
      $effect->setReason(
305
 
        pht(
306
 
          'CCs provided explicitly by revision author or carried over '.
307
 
        'from a previous version of the revision.'));
308
 
      $result[] = new HeraldApplyTranscript(
309
 
        $effect,
310
 
        true,
311
 
        pht('Added addresses to CC list.'));
312
 
    }
313
 
 
314
 
    $forbidden_ccs = array_fill_keys(
315
 
      nonempty($this->forbiddenCCs, array()),
316
 
      true);
317
271
 
318
272
    foreach ($effects as $effect) {
319
273
      $action = $effect->getAction();
320
274
      switch ($action) {
321
 
        case self::ACTION_NOTHING:
322
 
          $result[] = new HeraldApplyTranscript(
323
 
            $effect,
324
 
            true,
325
 
            pht('OK, did nothing.'));
326
 
          break;
327
 
        case self::ACTION_ADD_CC:
328
 
          $base_target = $effect->getTarget();
329
 
          $forbidden = array();
330
 
          foreach ($base_target as $key => $fbid) {
331
 
            if (isset($forbidden_ccs[$fbid])) {
332
 
              $forbidden[] = $fbid;
333
 
              unset($base_target[$key]);
334
 
            } else {
335
 
              $this->newCCs[$fbid] = true;
336
 
            }
337
 
          }
338
 
 
339
 
          if ($forbidden) {
340
 
            $failed = clone $effect;
341
 
            $failed->setTarget($forbidden);
342
 
            if ($base_target) {
343
 
              $effect->setTarget($base_target);
344
 
              $result[] = new HeraldApplyTranscript(
345
 
                $effect,
346
 
                true,
347
 
                pht(
348
 
                  'Added these addresses to CC list. '.
349
 
                  'Others could not be added.'));
350
 
            }
351
 
            $result[] = new HeraldApplyTranscript(
352
 
              $failed,
353
 
              false,
354
 
              pht('CC forbidden, these addresses have unsubscribed.'));
355
 
          } else {
356
 
            $result[] = new HeraldApplyTranscript(
357
 
              $effect,
358
 
              true,
359
 
              pht('Added addresses to CC list.'));
360
 
          }
361
 
          break;
362
 
        case self::ACTION_REMOVE_CC:
363
 
          foreach ($effect->getTarget() as $fbid) {
364
 
            $this->remCCs[$fbid] = true;
365
 
          }
366
 
          $result[] = new HeraldApplyTranscript(
367
 
            $effect,
368
 
            true,
369
 
            pht('Removed addresses from CC list.'));
370
 
          break;
371
275
        case self::ACTION_ADD_REVIEWERS:
372
276
          foreach ($effect->getTarget() as $phid) {
373
277
            $this->addReviewerPHIDs[$phid] = true;