tests/test-phabricator.t
changeset 44125 a5e3f38407cb
parent 43260 ec4dfcc39638
child 44127 59b3fe1e2021
equal deleted inserted replaced
44124:d56a2d6f34f0 44125:a5e3f38407cb
    18   > # it back. The VCR transcripts will be auto-sanitised to replace your real
    18   > # it back. The VCR transcripts will be auto-sanitised to replace your real
    19   > # token with this value.
    19   > # token with this value.
    20   > hgphab.phabtoken = cli-hahayouwish
    20   > hgphab.phabtoken = cli-hahayouwish
    21   > EOF
    21   > EOF
    22   $ VCR="$TESTDIR/phabricator"
    22   $ VCR="$TESTDIR/phabricator"
       
    23 
       
    24 Error is handled reasonably. We override the phabtoken here so that
       
    25 when you're developing changes to phabricator.py you can edit the
       
    26 above config and have a real token in the test but not have to edit
       
    27 this test.
       
    28   $ hg phabread --config auth.hgphab.phabtoken=cli-notavalidtoken \
       
    29   >  --test-vcr "$VCR/phabread-conduit-error.json" D4480 | head
       
    30   abort: Conduit Error (ERR-INVALID-AUTH): API token "cli-notavalidtoken" has the wrong length. API tokens should be 32 characters long.
       
    31 
       
    32 Basic phabread:
       
    33   $ hg phabread --test-vcr "$VCR/phabread-4480.json" D4480 | head
       
    34   # HG changeset patch
       
    35   # Date 1536771503 0
       
    36   # Parent  a5de21c9e3703f8e8eb064bd7d893ff2f703c66a
       
    37   exchangev2: start to implement pull with wire protocol v2
       
    38   
       
    39   Wire protocol version 2 will take a substantially different
       
    40   approach to exchange than version 1 (at least as far as pulling
       
    41   is concerned).
       
    42   
       
    43   This commit establishes a new exchangev2 module for holding
       
    44 
       
    45 phabupdate with an accept:
       
    46   $ hg phabupdate --accept D4564 \
       
    47   > -m 'I think I like where this is headed. Will read rest of series later.'\
       
    48   >  --test-vcr "$VCR/accept-4564.json"
       
    49   abort: Conduit Error (ERR-CONDUIT-CORE): Validation errors:
       
    50     - You can not accept this revision because it has already been closed. Only open revisions can be accepted.
       
    51   [255]
       
    52   $ hg phabupdate --accept D7913 -m 'LGTM' --test-vcr "$VCR/accept-7913.json"
       
    53 
       
    54 Create a differential diff:
       
    55   $ HGENCODING=utf-8; export HGENCODING
       
    56   $ echo alpha > alpha
       
    57   $ hg ci --addremove -m 'create alpha for phabricator test €'
       
    58   adding alpha
       
    59   $ hg phabsend -r . --test-vcr "$VCR/phabsend-create-alpha.json"
       
    60   D7915 - created - d386117f30e6: create alpha for phabricator test \xe2\x82\xac (esc)
       
    61   saved backup bundle to $TESTTMP/repo/.hg/strip-backup/d386117f30e6-24ffe649-phabsend.hg
       
    62   $ echo more >> alpha
       
    63   $ HGEDITOR=true hg ci --amend
       
    64   saved backup bundle to $TESTTMP/repo/.hg/strip-backup/347bf67801e5-3bf313e4-amend.hg
       
    65   $ echo beta > beta
       
    66   $ hg ci --addremove -m 'create beta for phabricator test'
       
    67   adding beta
       
    68   $ hg phabsend -r ".^::" --test-vcr "$VCR/phabsend-update-alpha-create-beta.json"
       
    69   D7915 - updated - c44b38f24a45: create alpha for phabricator test \xe2\x82\xac (esc)
       
    70   D7916 - created - 9e6901f21d5b: create beta for phabricator test
       
    71   saved backup bundle to $TESTTMP/repo/.hg/strip-backup/9e6901f21d5b-1fcd4f0e-phabsend.hg
       
    72   $ unset HGENCODING
       
    73 
       
    74 The amend won't explode after posting a public commit.  The local tag is left
       
    75 behind to identify it.
       
    76 
       
    77   $ echo 'public change' > beta
       
    78   $ hg ci -m 'create public change for phabricator testing'
       
    79   $ hg phase --public .
       
    80   $ echo 'draft change' > alpha
       
    81   $ hg ci -m 'create draft change for phabricator testing'
       
    82   $ hg phabsend --amend -r '.^::' --test-vcr "$VCR/phabsend-create-public.json"
       
    83   D7917 - created - 7b4185ab5d16: create public change for phabricator testing
       
    84   D7918 - created - 251c1c333fc6: create draft change for phabricator testing
       
    85   warning: not updating public commit 2:7b4185ab5d16
       
    86   saved backup bundle to $TESTTMP/repo/.hg/strip-backup/251c1c333fc6-41cb7c3b-phabsend.hg
       
    87   $ hg tags -v
       
    88   tip                                3:3244dc4a3334
       
    89   D7917                              2:7b4185ab5d16 local
       
    90 
       
    91   $ hg debugcallconduit user.search --test-vcr "$VCR/phab-conduit.json" <<EOF
       
    92   > {
       
    93   >     "constraints": {
       
    94   >         "isBot": true
       
    95   >     }
       
    96   > }
       
    97   > EOF
       
    98   {
       
    99     "cursor": {
       
   100       "after": null,
       
   101       "before": null,
       
   102       "limit": 100,
       
   103       "order": null
       
   104     },
       
   105     "data": [],
       
   106     "maps": {},
       
   107     "query": {
       
   108       "queryKey": null
       
   109     }
       
   110   }
       
   111 
       
   112 Template keywords
       
   113   $ hg log -T'{rev} {phabreview|json}\n'
       
   114   3 {"id": "D7918", "url": "https://phab.mercurial-scm.org/D7918"}
       
   115   2 {"id": "D7917", "url": "https://phab.mercurial-scm.org/D7917"}
       
   116   1 {"id": "D7916", "url": "https://phab.mercurial-scm.org/D7916"}
       
   117   0 {"id": "D7915", "url": "https://phab.mercurial-scm.org/D7915"}
       
   118 
       
   119   $ hg log -T'{rev} {if(phabreview, "{phabreview.url} {phabreview.id}")}\n'
       
   120   3 https://phab.mercurial-scm.org/D7918 D7918
       
   121   2 https://phab.mercurial-scm.org/D7917 D7917
       
   122   1 https://phab.mercurial-scm.org/D7916 D7916
       
   123   0 https://phab.mercurial-scm.org/D7915 D7915
       
   124 
       
   125 Commenting when phabsending:
       
   126   $ echo comment > comment
       
   127   $ hg ci --addremove -m "create comment for phabricator test"
       
   128   adding comment
       
   129   $ hg phabsend -r . -m "For default branch" --test-vcr "$VCR/phabsend-comment-created.json"
       
   130   D7919 - created - d5dddca9023d: create comment for phabricator test
       
   131   saved backup bundle to $TESTTMP/repo/.hg/strip-backup/d5dddca9023d-adf673ba-phabsend.hg
       
   132   $ echo comment2 >> comment
       
   133   $ hg ci --amend
       
   134   saved backup bundle to $TESTTMP/repo/.hg/strip-backup/f7db812bbe1d-8fcded77-amend.hg
       
   135   $ hg phabsend -r . -m "Address review comments" --test-vcr "$VCR/phabsend-comment-updated.json"
       
   136   D7919 - updated - 1849d7828727: create comment for phabricator test
       
   137 
       
   138 Phabsending a skipped commit:
       
   139   $ hg phabsend --no-amend -r . --test-vcr "$VCR/phabsend-skipped.json"
       
   140   D7919 - skipped - 1849d7828727: create comment for phabricator test
       
   141 
       
   142 Phabreading a DREV with a local:commits time as a string:
       
   143   $ hg phabread --test-vcr "$VCR/phabread-str-time.json" D1285
       
   144   # HG changeset patch
       
   145   # User Pulkit Goyal <7895pulkit@gmail.com>
       
   146   # Date 1509404054 -19800
       
   147   # Node ID 44fc1c1f1774a76423b9c732af6938435099bcc5
       
   148   # Parent  8feef8ef8389a3b544e0a74624f1efc3a8d85d35
       
   149   repoview: add a new attribute _visibilityexceptions and related API
       
   150   
       
   151   Currently we don't have a defined way in core to make some hidden revisions
       
   152   visible in filtered repo. Extensions to achieve the purpose of unhiding some
       
   153   hidden commits, wrap repoview.pinnedrevs() function.
       
   154   
       
   155   To make the above task simple and have well defined API, this patch adds a new
       
   156   attribute '_visibilityexceptions' to repoview class which will contains
       
   157   the hidden revs which should be exception.
       
   158   This will allow to set different exceptions for different repoview objects
       
   159   backed by the same unfiltered repo.
       
   160   
       
   161   This patch also adds API to add revs to the attribute set and get them.
       
   162   
       
   163   Thanks to Jun for suggesting the use of repoview class instead of localrepo.
       
   164   
       
   165   Differential Revision: https://phab.mercurial-scm.org/D1285
       
   166   diff --git a/mercurial/repoview.py b/mercurial/repoview.py
       
   167   --- a/mercurial/repoview.py
       
   168   +++ b/mercurial/repoview.py
       
   169   @@ * @@ (glob)
       
   170        subclasses of `localrepo`. Eg: `bundlerepo` or `statichttprepo`.
       
   171        """
       
   172    
       
   173   +    # hidden revs which should be visible
       
   174   +    _visibilityexceptions = set()
       
   175   +
       
   176        def __init__(self, repo, filtername):
       
   177            object.__setattr__(self, r'_unfilteredrepo', repo)
       
   178            object.__setattr__(self, r'filtername', filtername)
       
   179   @@ -231,6 +234,14 @@
       
   180                return self
       
   181            return self.unfiltered().filtered(name)
       
   182    
       
   183   +    def addvisibilityexceptions(self, revs):
       
   184   +        """adds hidden revs which should be visible to set of exceptions"""
       
   185   +        self._visibilityexceptions.update(revs)
       
   186   +
       
   187   +    def getvisibilityexceptions(self):
       
   188   +        """returns the set of hidden revs which should be visible"""
       
   189   +        return self._visibilityexceptions
       
   190   +
       
   191        # everything access are forwarded to the proxied repo
       
   192        def __getattr__(self, attr):
       
   193            return getattr(self._unfilteredrepo, attr)
       
   194   diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
       
   195   --- a/mercurial/localrepo.py
       
   196   +++ b/mercurial/localrepo.py
       
   197   @@ -570,6 +570,14 @@
       
   198        def close(self):
       
   199            self._writecaches()
       
   200    
       
   201   +    def addvisibilityexceptions(self, exceptions):
       
   202   +        # should be called on a filtered repository
       
   203   +        pass
       
   204   +
       
   205   +    def getvisibilityexceptions(self):
       
   206   +        # should be called on a filtered repository
       
   207   +        return set()
       
   208   +
       
   209        def _loadextensions(self):
       
   210            extensions.loadall(self.ui)
       
   211    
       
   212   
       
   213 
       
   214   $ cd ..