tests/test-narrow-expanddirstate.t
author Raphaël Gomès <rgomes@octobus.net>
Thu, 10 Aug 2023 11:01:07 +0200
changeset 50978 27e773aa607d
parent 50799 02eae2df911a
permissions -rw-r--r--
rust: implement the `Graph` trait for all revlogs This is trivial and makes all the algorithms relying on the trait usable for more use cases.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36079
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
     1
  $ . "$TESTDIR/narrow-library.sh"
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
     2
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
     3
  $ hg init master
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
     4
  $ cd master
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
     5
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
     6
  $ mkdir inside
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
     7
  $ echo inside > inside/f1
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
     8
  $ mkdir outside
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
     9
  $ echo outside > outside/f2
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    10
  $ mkdir patchdir
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    11
  $ echo patch_this > patchdir/f3
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    12
  $ hg ci -Aqm 'initial'
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    13
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    14
  $ cd ..
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    15
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    16
  $ hg clone --narrow ssh://user@dummy/master narrow --include inside
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    17
  requesting all changes
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    18
  adding changesets
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    19
  adding manifests
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    20
  adding file changes
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    21
  added 1 changesets with 1 changes to 1 files
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    22
  new changesets dff6a2a6d433
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    23
  updating to branch default
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    24
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    25
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    26
  $ cd narrow
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    27
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    28
  $ mkdir outside
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    29
  $ echo other_contents > outside/f2
38837
fa64a229f24b tests: avoid unnecessarily looking inside .hg/ in test-narrow*
Martin von Zweigbergk <martinvonz@google.com>
parents: 38128
diff changeset
    30
  $ hg tracked | grep outside
36079
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    31
  [1]
38837
fa64a229f24b tests: avoid unnecessarily looking inside .hg/ in test-narrow*
Martin von Zweigbergk <martinvonz@google.com>
parents: 38128
diff changeset
    32
  $ hg files | grep outside
36079
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    33
  [1]
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    34
  $ hg status
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    35
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    36
`hg status` did not add outside.
38837
fa64a229f24b tests: avoid unnecessarily looking inside .hg/ in test-narrow*
Martin von Zweigbergk <martinvonz@google.com>
parents: 38128
diff changeset
    37
  $ hg tracked | grep outside
36079
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    38
  [1]
38837
fa64a229f24b tests: avoid unnecessarily looking inside .hg/ in test-narrow*
Martin von Zweigbergk <martinvonz@google.com>
parents: 38128
diff changeset
    39
  $ hg files | grep outside
36079
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    40
  [1]
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    41
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    42
Unfortunately this is not really a candidate for adding to narrowhg proper,
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    43
since it depends on some other source for providing the manifests (when using
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    44
treemanifests) and file contents. Something like a virtual filesystem and/or
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    45
remotefilelog. We want to be useful when not using those systems, so we do not
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    46
have this method available in narrowhg proper at the moment.
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    47
  $ cat > "$TESTTMP/expand_extension.py" <<EOF
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    48
  > import os
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    49
  > import sys
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    50
  > 
36347
f6ddbcff5d7b tests: port extension in test-narrow-expanddirstate.t to Python 3
Augie Fackler <augie@google.com>
parents: 36161
diff changeset
    51
  > from mercurial import encoding
36079
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    52
  > from mercurial import extensions
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    53
  > from mercurial import localrepo
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    54
  > from mercurial import match as matchmod
36160
9fd8c2a3db5a narrowspec: move module into core
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36079
diff changeset
    55
  > from mercurial import narrowspec
36079
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    56
  > from mercurial import patch
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    57
  > from mercurial import util as hgutil
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    58
  > 
41040
92fde28860bb tests: update narrowspec when narrowspec, not dirstate, is accessed
Martin von Zweigbergk <martinvonz@google.com>
parents: 38837
diff changeset
    59
  > narrowspecexpanded = False
36079
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    60
  > def expandnarrowspec(ui, repo, newincludes=None):
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    61
  >   if not newincludes:
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    62
  >     return
41040
92fde28860bb tests: update narrowspec when narrowspec, not dirstate, is accessed
Martin von Zweigbergk <martinvonz@google.com>
parents: 38837
diff changeset
    63
  >   if getattr(repo, '_narrowspecexpanded', False):
92fde28860bb tests: update narrowspec when narrowspec, not dirstate, is accessed
Martin von Zweigbergk <martinvonz@google.com>
parents: 38837
diff changeset
    64
  >     return
92fde28860bb tests: update narrowspec when narrowspec, not dirstate, is accessed
Martin von Zweigbergk <martinvonz@google.com>
parents: 38837
diff changeset
    65
  >   repo._narrowspecexpanded = True
36079
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    66
  >   import sys
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    67
  >   newincludes = set([newincludes])
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    68
  >   includes, excludes = repo.narrowpats
36160
9fd8c2a3db5a narrowspec: move module into core
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36079
diff changeset
    69
  >   currentmatcher = narrowspec.match(repo.root, includes, excludes)
36079
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    70
  >   includes = includes | newincludes
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    71
  >   if not repo.currenttransaction():
36347
f6ddbcff5d7b tests: port extension in test-narrow-expanddirstate.t to Python 3
Augie Fackler <augie@google.com>
parents: 36161
diff changeset
    72
  >     ui.develwarn(b'expandnarrowspec called outside of transaction!')
36079
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    73
  >   repo.setnarrowpats(includes, excludes)
41236
44a51c1c8e17 narrow: move copytonarrowspec() out of setnarrowpats()
Martin von Zweigbergk <martinvonz@google.com>
parents: 41040
diff changeset
    74
  >   narrowspec.copytoworkingcopy(repo)
36160
9fd8c2a3db5a narrowspec: move module into core
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36079
diff changeset
    75
  >   newmatcher = narrowspec.match(repo.root, includes, excludes)
36079
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    76
  >   added = matchmod.differencematcher(newmatcher, currentmatcher)
49961
7a8bfc05b691 dirstate: rename parentchange to changing_parents
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49960
diff changeset
    77
  >   with repo.dirstate.changing_parents(repo):
47740
28d5e05c139a narrow: stop using `normallookup` during a test
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41236
diff changeset
    78
  >       for f in repo[b'.'].manifest().walk(added):
28d5e05c139a narrow: stop using `normallookup` during a test
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41236
diff changeset
    79
  >           repo.dirstate.update_file(
28d5e05c139a narrow: stop using `normallookup` during a test
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41236
diff changeset
    80
  >               f,
28d5e05c139a narrow: stop using `normallookup` during a test
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41236
diff changeset
    81
  >               p1_tracked=True,
28d5e05c139a narrow: stop using `normallookup` during a test
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41236
diff changeset
    82
  >               wc_tracked=True,
28d5e05c139a narrow: stop using `normallookup` during a test
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41236
diff changeset
    83
  >               possibly_dirty=True,
28d5e05c139a narrow: stop using `normallookup` during a test
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41236
diff changeset
    84
  >           )
36079
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    85
  > 
41040
92fde28860bb tests: update narrowspec when narrowspec, not dirstate, is accessed
Martin von Zweigbergk <martinvonz@google.com>
parents: 38837
diff changeset
    86
  > def reposetup(ui, repo):
92fde28860bb tests: update narrowspec when narrowspec, not dirstate, is accessed
Martin von Zweigbergk <martinvonz@google.com>
parents: 38837
diff changeset
    87
  >   class expandingrepo(repo.__class__):
92fde28860bb tests: update narrowspec when narrowspec, not dirstate, is accessed
Martin von Zweigbergk <martinvonz@google.com>
parents: 38837
diff changeset
    88
  >     def narrowmatch(self, *args, **kwargs):
38128
1cba497491be narrow: only wrap dirstate functions once, instead of per-reposetup
Kyle Lippincott <spectral@google.com>
parents: 36347
diff changeset
    89
  >       with repo.wlock(), repo.lock(), repo.transaction(
1cba497491be narrow: only wrap dirstate functions once, instead of per-reposetup
Kyle Lippincott <spectral@google.com>
parents: 36347
diff changeset
    90
  >           b'expandnarrowspec'):
1cba497491be narrow: only wrap dirstate functions once, instead of per-reposetup
Kyle Lippincott <spectral@google.com>
parents: 36347
diff changeset
    91
  >         expandnarrowspec(ui, repo,
1cba497491be narrow: only wrap dirstate functions once, instead of per-reposetup
Kyle Lippincott <spectral@google.com>
parents: 36347
diff changeset
    92
  >                          encoding.environ.get(b'DIRSTATEINCLUDES'))
41040
92fde28860bb tests: update narrowspec when narrowspec, not dirstate, is accessed
Martin von Zweigbergk <martinvonz@google.com>
parents: 38837
diff changeset
    93
  >       return super(expandingrepo, self).narrowmatch(*args, **kwargs)
38128
1cba497491be narrow: only wrap dirstate functions once, instead of per-reposetup
Kyle Lippincott <spectral@google.com>
parents: 36347
diff changeset
    94
  >   repo.__class__ = expandingrepo
1cba497491be narrow: only wrap dirstate functions once, instead of per-reposetup
Kyle Lippincott <spectral@google.com>
parents: 36347
diff changeset
    95
  > 
1cba497491be narrow: only wrap dirstate functions once, instead of per-reposetup
Kyle Lippincott <spectral@google.com>
parents: 36347
diff changeset
    96
  > def extsetup(unused_ui):
1cba497491be narrow: only wrap dirstate functions once, instead of per-reposetup
Kyle Lippincott <spectral@google.com>
parents: 36347
diff changeset
    97
  >   def overridepatch(orig, ui, repo, *args, **kwargs):
36079
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    98
  >     with repo.wlock():
36347
f6ddbcff5d7b tests: port extension in test-narrow-expanddirstate.t to Python 3
Augie Fackler <augie@google.com>
parents: 36161
diff changeset
    99
  >       expandnarrowspec(ui, repo, encoding.environ.get(b'PATCHINCLUDES'))
38128
1cba497491be narrow: only wrap dirstate functions once, instead of per-reposetup
Kyle Lippincott <spectral@google.com>
parents: 36347
diff changeset
   100
  >       return orig(ui, repo, *args, **kwargs)
36079
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
   101
  > 
50799
02eae2df911a wrapfunction: use sysstr instead of bytes as argument in various tests
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49961
diff changeset
   102
  >   extensions.wrapfunction(patch, 'patch', overridepatch)
36079
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
   103
  > EOF
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
   104
  $ cat >> ".hg/hgrc" <<EOF
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
   105
  > [extensions]
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
   106
  > expand_extension = $TESTTMP/expand_extension.py
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
   107
  > EOF
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
   108
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
   109
Since we do not have the ability to rely on a virtual filesystem or
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
   110
remotefilelog in the test, we just fake it by copying the data from the 'master'
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
   111
repo.
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
   112
  $ cp -a ../master/.hg/store/data/* .hg/store/data
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
   113
Do that for patchdir as well.
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
   114
  $ cp -a ../master/patchdir .
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
   115
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
   116
`hg status` will now add outside, but not patchdir.
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
   117
  $ DIRSTATEINCLUDES=path:outside hg status
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
   118
  M outside/f2
38837
fa64a229f24b tests: avoid unnecessarily looking inside .hg/ in test-narrow*
Martin von Zweigbergk <martinvonz@google.com>
parents: 38128
diff changeset
   119
  $ hg tracked | grep outside
fa64a229f24b tests: avoid unnecessarily looking inside .hg/ in test-narrow*
Martin von Zweigbergk <martinvonz@google.com>
parents: 38128
diff changeset
   120
  I path:outside
fa64a229f24b tests: avoid unnecessarily looking inside .hg/ in test-narrow*
Martin von Zweigbergk <martinvonz@google.com>
parents: 38128
diff changeset
   121
  $ hg files | grep outside > /dev/null
fa64a229f24b tests: avoid unnecessarily looking inside .hg/ in test-narrow*
Martin von Zweigbergk <martinvonz@google.com>
parents: 38128
diff changeset
   122
  $ hg tracked | grep patchdir
36079
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
   123
  [1]
38837
fa64a229f24b tests: avoid unnecessarily looking inside .hg/ in test-narrow*
Martin von Zweigbergk <martinvonz@google.com>
parents: 38128
diff changeset
   124
  $ hg files | grep patchdir
36079
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
   125
  [1]
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
   126
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
   127
Get rid of the modification to outside/f2.
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
   128
  $ hg update -C .
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
   129
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
   130
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
   131
This patch will not apply cleanly at the moment, so `hg import` will break
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
   132
  $ cat > "$TESTTMP/foo.patch" <<EOF
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
   133
  > --- patchdir/f3
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
   134
  > +++ patchdir/f3
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
   135
  > @@ -1,1 +1,1 @@
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
   136
  > -this should be "patch_this", but its not, so patch fails
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
   137
  > +this text is irrelevant
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
   138
  > EOF
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
   139
  $ PATCHINCLUDES=path:patchdir hg import -p0 -e "$TESTTMP/foo.patch" -m ignored
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
   140
  applying $TESTTMP/foo.patch
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
   141
  patching file patchdir/f3
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
   142
  Hunk #1 FAILED at 0
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
   143
  1 out of 1 hunks FAILED -- saving rejects to file patchdir/f3.rej
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
   144
  abort: patch failed to apply
48363
6a454e7053a1 errors: return more detailed errors when failing to parse or apply patch
Martin von Zweigbergk <martinvonz@google.com>
parents: 47740
diff changeset
   145
  [20]
38837
fa64a229f24b tests: avoid unnecessarily looking inside .hg/ in test-narrow*
Martin von Zweigbergk <martinvonz@google.com>
parents: 38128
diff changeset
   146
  $ hg tracked | grep patchdir
36079
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
   147
  [1]
38837
fa64a229f24b tests: avoid unnecessarily looking inside .hg/ in test-narrow*
Martin von Zweigbergk <martinvonz@google.com>
parents: 38128
diff changeset
   148
  $ hg files | grep patchdir > /dev/null
36079
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
   149
  [1]
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
   150
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
   151
Let's make it apply cleanly and see that it *did* expand properly
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
   152
  $ cat > "$TESTTMP/foo.patch" <<EOF
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
   153
  > --- patchdir/f3
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
   154
  > +++ patchdir/f3
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
   155
  > @@ -1,1 +1,1 @@
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
   156
  > -patch_this
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
   157
  > +patched_this
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
   158
  > EOF
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
   159
  $ PATCHINCLUDES=path:patchdir hg import -p0 -e "$TESTTMP/foo.patch" -m message
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
   160
  applying $TESTTMP/foo.patch
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
   161
  $ cat patchdir/f3
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
   162
  patched_this
38837
fa64a229f24b tests: avoid unnecessarily looking inside .hg/ in test-narrow*
Martin von Zweigbergk <martinvonz@google.com>
parents: 38128
diff changeset
   163
  $ hg tracked | grep patchdir
fa64a229f24b tests: avoid unnecessarily looking inside .hg/ in test-narrow*
Martin von Zweigbergk <martinvonz@google.com>
parents: 38128
diff changeset
   164
  I path:patchdir
fa64a229f24b tests: avoid unnecessarily looking inside .hg/ in test-narrow*
Martin von Zweigbergk <martinvonz@google.com>
parents: 38128
diff changeset
   165
  $ hg files | grep patchdir > /dev/null