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

« back to all changes in this revision

Viewing changes to src/parser/diff/ArcanistDiffChangeType.php

  • Committer: Package Import Robot
  • Author(s): Richard Sellam
  • Date: 2014-11-01 23:20:06 UTC
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: package-import@ubuntu.com-20141101232006-mvlnp0cil67tsboe
Tags: upstream-0~git20141101/arcanist
Import upstream version 0~git20141101, component arcanist

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
 
 
3
/**
 
4
 * Defines constants for file types and operations in changesets.
 
5
 */
 
6
final class ArcanistDiffChangeType {
 
7
 
 
8
  const TYPE_ADD        = 1;
 
9
  const TYPE_CHANGE     = 2;
 
10
  const TYPE_DELETE     = 3;
 
11
  const TYPE_MOVE_AWAY  = 4;
 
12
  const TYPE_COPY_AWAY  = 5;
 
13
  const TYPE_MOVE_HERE  = 6;
 
14
  const TYPE_COPY_HERE  = 7;
 
15
  const TYPE_MULTICOPY  = 8;
 
16
  const TYPE_MESSAGE    = 9;
 
17
  const TYPE_CHILD      = 10;
 
18
 
 
19
  const FILE_TEXT       = 1;
 
20
  const FILE_IMAGE      = 2;
 
21
  const FILE_BINARY     = 3;
 
22
  const FILE_DIRECTORY  = 4;
 
23
  const FILE_SYMLINK    = 5;
 
24
  const FILE_DELETED    = 6;
 
25
  const FILE_NORMAL     = 7;
 
26
 
 
27
  public static function getSummaryCharacterForChangeType($type) {
 
28
    static $types = array(
 
29
      self::TYPE_ADD        => 'A',
 
30
      self::TYPE_CHANGE     => 'M',
 
31
      self::TYPE_DELETE     => 'D',
 
32
      self::TYPE_MOVE_AWAY  => 'V',
 
33
      self::TYPE_COPY_AWAY  => 'P',
 
34
      self::TYPE_MOVE_HERE  => 'V',
 
35
      self::TYPE_COPY_HERE  => 'P',
 
36
      self::TYPE_MULTICOPY  => 'P',
 
37
      self::TYPE_MESSAGE    => 'Q',
 
38
      self::TYPE_CHILD      => '@',
 
39
    );
 
40
    return idx($types, coalesce($type, '?'), '~');
 
41
  }
 
42
 
 
43
  public static function getShortNameForFileType($type) {
 
44
    static $names = array(
 
45
      self::FILE_TEXT       => null,
 
46
      self::FILE_DIRECTORY  => 'dir',
 
47
      self::FILE_IMAGE      => 'img',
 
48
      self::FILE_BINARY     => 'bin',
 
49
      self::FILE_SYMLINK    => 'sym',
 
50
    );
 
51
    return idx($names, coalesce($type, '?'), '???');
 
52
  }
 
53
 
 
54
  public static function isOldLocationChangeType($type) {
 
55
    static $types = array(
 
56
      ArcanistDiffChangeType::TYPE_MOVE_AWAY  => true,
 
57
      ArcanistDiffChangeType::TYPE_COPY_AWAY  => true,
 
58
      ArcanistDiffChangeType::TYPE_MULTICOPY  => true,
 
59
    );
 
60
    return isset($types[$type]);
 
61
  }
 
62
 
 
63
  public static function isNewLocationChangeType($type) {
 
64
    static $types = array(
 
65
      ArcanistDiffChangeType::TYPE_MOVE_HERE  => true,
 
66
      ArcanistDiffChangeType::TYPE_COPY_HERE  => true,
 
67
    );
 
68
    return isset($types[$type]);
 
69
  }
 
70
 
 
71
  public static function isDeleteChangeType($type) {
 
72
    static $types = array(
 
73
      ArcanistDiffChangeType::TYPE_DELETE     => true,
 
74
      ArcanistDiffChangeType::TYPE_MOVE_AWAY  => true,
 
75
      ArcanistDiffChangeType::TYPE_MULTICOPY  => true,
 
76
    );
 
77
    return isset($types[$type]);
 
78
  }
 
79
 
 
80
  public static function isCreateChangeType($type) {
 
81
    static $types = array(
 
82
      ArcanistDiffChangeType::TYPE_ADD        => true,
 
83
      ArcanistDiffChangeType::TYPE_COPY_HERE  => true,
 
84
      ArcanistDiffChangeType::TYPE_MOVE_HERE  => true,
 
85
    );
 
86
    return isset($types[$type]);
 
87
  }
 
88
 
 
89
  public static function isModifyChangeType($type) {
 
90
    static $types = array(
 
91
      ArcanistDiffChangeType::TYPE_CHANGE     => true,
 
92
    );
 
93
    return isset($types[$type]);
 
94
  }
 
95
 
 
96
  public static function getFullNameForChangeType($type) {
 
97
    static $types = array(
 
98
      self::TYPE_ADD        => 'Added',
 
99
      self::TYPE_CHANGE     => 'Modified',
 
100
      self::TYPE_DELETE     => 'Deleted',
 
101
      self::TYPE_MOVE_AWAY  => 'Moved Away',
 
102
      self::TYPE_COPY_AWAY  => 'Copied Away',
 
103
      self::TYPE_MOVE_HERE  => 'Moved Here',
 
104
      self::TYPE_COPY_HERE  => 'Copied Here',
 
105
      self::TYPE_MULTICOPY  => 'Deleted After Multiple Copy',
 
106
      self::TYPE_MESSAGE    => 'Commit Message',
 
107
      self::TYPE_CHILD      => 'Contents Modified',
 
108
    );
 
109
    return idx($types, coalesce($type, '?'), 'Unknown');
 
110
  }
 
111
 
 
112
}