tests/test-shelve.t
branchstable
changeset 25855 96a38d44ba09
parent 25799 0eb093e40813
child 26507 ae29cffa05db
equal deleted inserted replaced
25745:501c51d60792 25855:96a38d44ba09
     3   > mq =
     3   > mq =
     4   > shelve =
     4   > shelve =
     5   > [defaults]
     5   > [defaults]
     6   > diff = --nodates --git
     6   > diff = --nodates --git
     7   > qnew = --date '0 0'
     7   > qnew = --date '0 0'
       
     8   > [shelve]
       
     9   > maxbackups = 2
     8   > EOF
    10   > EOF
     9 
    11 
    10   $ hg init repo
    12   $ hg init repo
    11   $ cd repo
    13   $ cd repo
    12   $ mkdir a b
    14   $ mkdir a b
    58    -e --edit                invoke editor on commit messages
    60    -e --edit                invoke editor on commit messages
    59    -l --list                list current shelves
    61    -l --list                list current shelves
    60    -m --message TEXT        use text as shelve message
    62    -m --message TEXT        use text as shelve message
    61    -n --name NAME           use the given name for the shelved commit
    63    -n --name NAME           use the given name for the shelved commit
    62    -p --patch               show patch
    64    -p --patch               show patch
       
    65    -i --interactive         interactive mode, only works while creating a shelve
    63       --stat                output diffstat-style summary of changes
    66       --stat                output diffstat-style summary of changes
    64    -I --include PATTERN [+] include names matching the given patterns
    67    -I --include PATTERN [+] include names matching the given patterns
    65    -X --exclude PATTERN [+] exclude names matching the given patterns
    68    -X --exclude PATTERN [+] exclude names matching the given patterns
    66       --mq                  operate on patch repository
    69       --mq                  operate on patch repository
    67   
    70   
    81   $ hg commit -q -m 'initial commit'
    84   $ hg commit -q -m 'initial commit'
    82 
    85 
    83   $ hg shelve
    86   $ hg shelve
    84   nothing changed
    87   nothing changed
    85   [1]
    88   [1]
       
    89 
       
    90 make sure shelve files were backed up
       
    91 
       
    92   $ ls .hg/shelve-backup
       
    93   default.hg
       
    94   default.patch
    86 
    95 
    87 create an mq patch - shelving should work fine with a patch applied
    96 create an mq patch - shelving should work fine with a patch applied
    88 
    97 
    89   $ echo n > n
    98   $ echo n > n
    90   $ hg add n
    99   $ hg add n
   151 delete our older shelved change
   160 delete our older shelved change
   152 
   161 
   153   $ hg shelve -d default
   162   $ hg shelve -d default
   154   $ hg qfinish -a -q
   163   $ hg qfinish -a -q
   155 
   164 
       
   165 ensure shelve backups aren't overwritten
       
   166 
       
   167   $ ls .hg/shelve-backup/
       
   168   default-1.hg
       
   169   default-1.patch
       
   170   default.hg
       
   171   default.patch
       
   172 
   156 local edits should not prevent a shelved change from applying
   173 local edits should not prevent a shelved change from applying
   157 
   174 
   158   $ printf "z\na\n" > a/a
   175   $ printf "z\na\n" > a/a
   159   $ hg unshelve --keep
   176   $ hg unshelve --keep
   160   unshelving change 'default-01'
   177   unshelving change 'default-01'
   165 
   182 
   166   $ hg revert --all -q
   183   $ hg revert --all -q
   167   $ rm a/a.orig b.rename/b c.copy
   184   $ rm a/a.orig b.rename/b c.copy
   168 
   185 
   169 apply it and make sure our state is as expected
   186 apply it and make sure our state is as expected
       
   187 
       
   188 (this also tests that same timestamp prevents backups from being
       
   189 removed, even though there are more than 'maxbackups' backups)
       
   190 
       
   191   $ f -t .hg/shelve-backup/default.hg
       
   192   .hg/shelve-backup/default.hg: file
       
   193   $ touch -t 200001010000 .hg/shelve-backup/default.hg
       
   194   $ f -t .hg/shelve-backup/default-1.hg
       
   195   .hg/shelve-backup/default-1.hg: file
       
   196   $ touch -t 200001010000 .hg/shelve-backup/default-1.hg
   170 
   197 
   171   $ hg unshelve
   198   $ hg unshelve
   172   unshelving change 'default-01'
   199   unshelving change 'default-01'
   173   $ hg status -C
   200   $ hg status -C
   174   M a/a
   201   M a/a
   176     b/b
   203     b/b
   177   A c.copy
   204   A c.copy
   178     c
   205     c
   179   R b/b
   206   R b/b
   180   $ hg shelve -l
   207   $ hg shelve -l
       
   208 
       
   209 (both of default.hg and default-1.hg should be still kept, because it
       
   210 is difficult to decide actual order of them from same timestamp)
       
   211 
       
   212   $ ls .hg/shelve-backup/
       
   213   default-01.hg
       
   214   default-01.patch
       
   215   default-1.hg
       
   216   default-1.patch
       
   217   default.hg
       
   218   default.patch
   181 
   219 
   182   $ hg unshelve
   220   $ hg unshelve
   183   abort: no shelved changes to apply!
   221   abort: no shelved changes to apply!
   184   [255]
   222   [255]
   185   $ hg unshelve foo
   223   $ hg unshelve foo
   230   A b.rename/b
   268   A b.rename/b
   231     b/b
   269     b/b
   232   A c.copy
   270   A c.copy
   233     c
   271     c
   234   R b/b
   272   R b/b
       
   273 
       
   274 ensure old shelve backups are being deleted automatically
       
   275 
       
   276   $ ls .hg/shelve-backup/
       
   277   default-01.hg
       
   278   default-01.patch
       
   279   wibble.hg
       
   280   wibble.patch
   235 
   281 
   236 cause unshelving to result in a merge with 'a' conflicting
   282 cause unshelving to result in a merge with 'a' conflicting
   237 
   283 
   238   $ hg shelve -q
   284   $ hg shelve -q
   239   $ echo c>>a/a
   285   $ echo c>>a/a
   780    create conflict
   826    create conflict
   781   branch: default
   827   branch: default
   782   bookmarks: *test
   828   bookmarks: *test
   783   commit: 2 unknown (clean)
   829   commit: 2 unknown (clean)
   784   update: (current)
   830   update: (current)
       
   831   phases: 5 draft
   785 
   832 
   786   $ hg shelve --delete --stat
   833   $ hg shelve --delete --stat
   787   abort: options '--delete' and '--stat' may not be used together
   834   abort: options '--delete' and '--stat' may not be used together
   788   [255]
   835   [255]
   789   $ hg shelve --delete --name NAME
   836   $ hg shelve --delete --name NAME
   811   x
   858   x
   812   x
   859   x
   813   $ cat foo/foo
   860   $ cat foo/foo
   814   foo
   861   foo
   815   a
   862   a
       
   863   $ hg shelve --interactive --config ui.interactive=false
       
   864   abort: running non-interactively
       
   865   [255]
   816   $ hg shelve --interactive << EOF
   866   $ hg shelve --interactive << EOF
   817   > y
   867   > y
   818   > y
   868   > y
   819   > n
   869   > n
   820   > EOF
   870   > EOF
   860   a
   910   a
   861   a
   911   a
   862   c
   912   c
   863   x
   913   x
   864   x
   914   x
   865   $ cd ..
   915 
       
   916 shelve --patch and shelve --stat should work with a single valid shelfname
       
   917 
       
   918   $ hg up --clean .
       
   919   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
   920   $ hg shelve --list
       
   921   $ echo 'patch a' > shelf-patch-a
       
   922   $ hg add shelf-patch-a
       
   923   $ hg shelve
       
   924   shelved as default
       
   925   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
       
   926   $ echo 'patch b' > shelf-patch-b
       
   927   $ hg add shelf-patch-b
       
   928   $ hg shelve
       
   929   shelved as default-01
       
   930   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
       
   931   $ hg shelve --patch default default-01
       
   932   abort: --patch expects a single shelf
       
   933   [255]
       
   934   $ hg shelve --stat default default-01
       
   935   abort: --stat expects a single shelf
       
   936   [255]
       
   937   $ hg shelve --patch default
       
   938   default         (* ago)    changes to 'create conflict' (glob)
       
   939   
       
   940   diff --git a/shelf-patch-a b/shelf-patch-a
       
   941   new file mode 100644
       
   942   --- /dev/null
       
   943   +++ b/shelf-patch-a
       
   944   @@ -0,0 +1,1 @@
       
   945   +patch a
       
   946   $ hg shelve --stat default
       
   947   default         (* ago)    changes to 'create conflict' (glob)
       
   948    shelf-patch-a |  1 +
       
   949    1 files changed, 1 insertions(+), 0 deletions(-)
       
   950   $ hg shelve --patch nonexistentshelf
       
   951   abort: cannot find shelf nonexistentshelf
       
   952   [255]
       
   953   $ hg shelve --stat nonexistentshelf
       
   954   abort: cannot find shelf nonexistentshelf
       
   955   [255]
       
   956