tests/test-bundle2-pushback.t
author Denis Laxalde <denis.laxalde@logilab.fr>
Tue, 17 Oct 2017 21:15:31 +0200
changeset 34857 84c6b9384d6a
parent 33965 0124cf4af3b7
child 36255 1ee1a42bfdae
permissions -rw-r--r--
log: add -L/--line-range option to follow file history by line range We add an experimental -L/--line-range option to 'hg log' taking file patterns along with a line range using the (new) FILE,FROMLINE-TOLINE syntax where FILE may be a pattern (matching exactly one file). The resulting history is similar to what the "followlines" revset except that, if --patch is specified, only diff hunks within specified line range are shown. Basically, this brings the CLI on par with what currently only exists in hgweb through line selection in "file" and "annotate" views resulting in a file log with filtered patch to only display followed line range. The option may be specified multiple times and can be combined with --rev and regular file patterns to further restrict revisions. Usage of this option requires --follow; revisions are shown in descending order and renames are followed. Only the --graph option is currently not supported. The UI is the result of a consensus from review feedback at: https://www.mercurial-scm.org/pipermail/mercurial-devel/2017-October/106749.html The implementation spreads between commands.log() and cmdutil module. In commands.log(), the main loop may now use a "hunksfilter" factory (similar to "filematcher") that, for a given "rev", produces a filtering function for diff hunks for a given file context object. The logic to build revisions from -L/--line-range options lives in cmdutil.getloglinerangerevs() which produces "revs", "filematcher" and "hunksfilter" information. Revisions obtained by following files' line range are filtered if they do not match the revset specified by --rev option. If regular FILE arguments are passed along with -L options, both filematchers are combined into a new matcher. .. feature:: Add an experimental -L/--line-range FILE,FROMLINE-TOLINE option to 'hg log' command to follow the history of files by line range. In combination with -p/--patch option, only diff hunks within specified line range will be displayed. Feedback, especially on UX aspects, is welcome.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
23439
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
     1
  $ cat > bundle2.py << EOF
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
     2
  > """A small extension to test bundle2 pushback parts.
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
     3
  > Current bundle2 implementation doesn't provide a way to generate those
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
     4
  > parts, so they must be created by extensions.
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
     5
  > """
33965
0124cf4af3b7 tests: update test-bundle2-pushback to pass the import checker
Augie Fackler <raf@durin42.com>
parents: 33262
diff changeset
     6
  > from __future__ import absolute_import
0124cf4af3b7 tests: update test-bundle2-pushback to pass the import checker
Augie Fackler <raf@durin42.com>
parents: 33262
diff changeset
     7
  > from mercurial import bundle2, exchange, pushkey, util
23439
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
     8
  > def _newhandlechangegroup(op, inpart):
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
     9
  >     """This function wraps the changegroup part handler for getbundle.
24686
e0e28e910fa3 bundle2: rename format, parts and config to final names
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23439
diff changeset
    10
  >     It issues an additional pushkey part to send a new
23439
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    11
  >     bookmark back to the client"""
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    12
  >     result = bundle2.handlechangegroup(op, inpart)
24686
e0e28e910fa3 bundle2: rename format, parts and config to final names
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23439
diff changeset
    13
  >     if 'pushback' in op.reply.capabilities:
23439
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    14
  >         params = {'namespace': 'bookmarks',
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    15
  >                   'key': 'new-server-mark',
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    16
  >                   'old': '',
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    17
  >                   'new': 'tip'}
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    18
  >         encodedparams = [(k, pushkey.encode(v)) for (k,v) in params.items()]
24686
e0e28e910fa3 bundle2: rename format, parts and config to final names
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23439
diff changeset
    19
  >         op.reply.newpart('pushkey', mandatoryparams=encodedparams)
23439
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    20
  >     else:
24686
e0e28e910fa3 bundle2: rename format, parts and config to final names
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23439
diff changeset
    21
  >         op.reply.newpart('output', data='pushback not enabled')
23439
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    22
  >     return result
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    23
  > _newhandlechangegroup.params = bundle2.handlechangegroup.params
24686
e0e28e910fa3 bundle2: rename format, parts and config to final names
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23439
diff changeset
    24
  > bundle2.parthandlermapping['changegroup'] = _newhandlechangegroup
23439
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    25
  > EOF
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    26
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    27
  $ cat >> $HGRCPATH <<EOF
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    28
  > [ui]
33262
8e6f4939a69a tests: replace yet more calls to `python` with $PYTHON
Augie Fackler <augie@google.com>
parents: 29686
diff changeset
    29
  > ssh = $PYTHON "$TESTDIR/dummyssh"
23439
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    30
  > username = nobody <no.reply@example.com>
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    31
  > 
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    32
  > [alias]
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    33
  > tglog = log -G -T "{desc} [{phase}:{node|short}]"
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    34
  > EOF
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    35
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    36
Set up server repository
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    37
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    38
  $ hg init server
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    39
  $ cd server
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    40
  $ echo c0 > f0
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    41
  $ hg commit -Am 0
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    42
  adding f0
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    43
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    44
Set up client repository
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    45
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    46
  $ cd ..
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    47
  $ hg clone ssh://user@dummy/server client -q
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    48
  $ cd client
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    49
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    50
Enable extension
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    51
  $ cat >> $HGRCPATH <<EOF
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    52
  > [extensions]
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    53
  > bundle2=$TESTTMP/bundle2.py
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    54
  > EOF
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    55
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    56
Without config
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    57
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    58
  $ cd ../client
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    59
  $ echo c1 > f1
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    60
  $ hg commit -Am 1
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    61
  adding f1
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    62
  $ hg push
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    63
  pushing to ssh://user@dummy/server
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    64
  searching for changes
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    65
  remote: adding changesets
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    66
  remote: adding manifests
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    67
  remote: adding file changes
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    68
  remote: added 1 changesets with 1 changes to 1 files
25423
525fbf24b51b bundle2: stop capturing output for ssh again
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 24754
diff changeset
    69
  remote: pushback not enabled
23439
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    70
  $ hg bookmark
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    71
  no bookmarks set
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    72
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    73
  $ cd ../server
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    74
  $ hg tglog
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    75
  o  1 [public:2b9c7234e035]
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    76
  |
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    77
  @  0 [public:6cee5c8f3e5b]
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    78
  
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    79
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    80
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    81
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    82
With config
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    83
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    84
  $ cd ../client
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    85
  $ echo '[experimental]' >> .hg/hgrc
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    86
  $ echo 'bundle2.pushback = True' >> .hg/hgrc
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    87
  $ echo c2 > f2
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    88
  $ hg commit -Am 2
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    89
  adding f2
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    90
  $ hg push
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    91
  pushing to ssh://user@dummy/server
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    92
  searching for changes
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    93
  remote: adding changesets
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    94
  remote: adding manifests
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    95
  remote: adding file changes
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    96
  remote: added 1 changesets with 1 changes to 1 files
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    97
  $ hg bookmark
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    98
     new-server-mark           2:0a76dfb2e179
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
    99
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
   100
  $ cd ../server
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
   101
  $ hg tglog
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
   102
  o  2 [public:0a76dfb2e179]
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
   103
  |
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
   104
  o  1 [public:2b9c7234e035]
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
   105
  |
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
   106
  @  0 [public:6cee5c8f3e5b]
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
   107
  
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
   108
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
   109
743736fc7c41 bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
diff changeset
   110