tests/test-amend-patch.t
changeset 3660 f018656ca3bf
child 3661 61fdd25542a6
equal deleted inserted replaced
3659:1e9b535cd9be 3660:f018656ca3bf
       
     1 ** Test for the `--patch` flag for `hg amend` command **
       
     2 
       
     3 Setup
       
     4 
       
     5   $ cat >> $HGRCPATH << EOF
       
     6   > [alias]
       
     7   > glog = log -GT "{rev}:{node|short} {desc}\n ({bookmarks}) {phase}"
       
     8   > [diff]
       
     9   > git = 1
       
    10   > [extensions]
       
    11   > EOF
       
    12   $ echo "evolve=$(echo $(dirname $TESTDIR))/hgext3rd/evolve/" >> $HGRCPATH
       
    13 
       
    14 Reposetup
       
    15 
       
    16   $ hg init repo
       
    17   $ cd repo
       
    18   $ echo foo > a
       
    19   $ hg ci -Aqm "added a"
       
    20   $ hg exp
       
    21   # HG changeset patch
       
    22   # User test
       
    23   # Date 0 0
       
    24   #      Thu Jan 01 00:00:00 1970 +0000
       
    25   # Node ID f7ad4196431346de3c33c52e75374fba45e04313
       
    26   # Parent  0000000000000000000000000000000000000000
       
    27   added a
       
    28   
       
    29   diff --git a/a b/a
       
    30   new file mode 100644
       
    31   --- /dev/null
       
    32   +++ b/a
       
    33   @@ -0,0 +1,1 @@
       
    34   +foo
       
    35 
       
    36 Testing of just changing the diff, not the patch metadata
       
    37 ==========================================================
       
    38 
       
    39 Testing the normal case
       
    40 -----------------------
       
    41 
       
    42   $ cat > editor.sh <<EOF
       
    43   > #!/bin/sh
       
    44   > cat > \$1 <<ENDOF
       
    45   > # HG changeset patch
       
    46   > # User test
       
    47   > # Date 0 0
       
    48   > #      Thu Jan 01 00:00:00 1970 +0000
       
    49   > # Node ID f7ad4196431346de3c33c52e75374fba45e04313
       
    50   > # Parent  0000000000000000000000000000000000000000
       
    51   > added a
       
    52   > diff --git a/a b/a
       
    53   > new file mode 100644
       
    54   > --- /dev/null
       
    55   > +++ b/a
       
    56   > @@ -0,0 +1,1 @@
       
    57   > +Gello
       
    58   > ENDOF
       
    59   > EOF
       
    60 
       
    61   $ HGEDITOR="sh ./editor.sh" hg amend --patch
       
    62 
       
    63 Making sure the amended commit is correct
       
    64 
       
    65   $ hg exp
       
    66   # HG changeset patch
       
    67   # User test
       
    68   # Date 0 0
       
    69   #      Thu Jan 01 00:00:00 1970 +0000
       
    70   # Node ID af624b221c0c0bec5d74e2650180dd3eddcb7c42
       
    71   # Parent  0000000000000000000000000000000000000000
       
    72   added a
       
    73   
       
    74   diff --git a/a b/a
       
    75   new file mode 100644
       
    76   --- /dev/null
       
    77   +++ b/a
       
    78   @@ -0,0 +1,1 @@
       
    79   +Gello
       
    80 
       
    81   $ hg glog
       
    82   @  1:af624b221c0c added a
       
    83       () draft
       
    84 
       
    85 Obsolsence history is fine
       
    86 
       
    87   $ hg obslog -p -r .
       
    88   @  af624b221c0c (1) added a
       
    89   |
       
    90   x  f7ad41964313 (0) added a
       
    91        rewritten(content) as af624b221c0c using amend by test (Thu Jan 01 00:00:00 1970 +0000)
       
    92          diff --git a/a b/a
       
    93          --- a/a
       
    94          +++ b/a
       
    95          @@ -1,1 +1,1 @@
       
    96          -foo
       
    97          +Gello
       
    98   
       
    99   
       
   100 Diff and status are good too
       
   101   $ hg diff
       
   102   $ hg status
       
   103   ? editor.sh
       
   104   $ cat a
       
   105   Gello
       
   106 
       
   107 Dirstate parents should be correctly set
       
   108   $ hg parents
       
   109   changeset:   1:af624b221c0c
       
   110   tag:         tip
       
   111   parent:      -1:000000000000
       
   112   user:        test
       
   113   date:        Thu Jan 01 00:00:00 1970 +0000
       
   114   summary:     added a
       
   115   
       
   116 Trying to amend with a wrong patch
       
   117 ----------------------------------
       
   118 
       
   119 Having context which was is not present
       
   120 
       
   121   $ cat > editor.sh <<EOF
       
   122   > #!/bin/sh
       
   123   > cat > \$1 <<ENDOF
       
   124   > # HG changeset patch
       
   125   > # User test
       
   126   > # Date 0 0
       
   127   > #      Thu Jan 01 00:00:00 1970 +0000
       
   128   > # Node ID c6ba250efbf73e671f2ca24b79db2c178ccbfff9
       
   129   > # Parent  0000000000000000000000000000000000000000
       
   130   > added a
       
   131   > diff --git a/a b/a
       
   132   > new file mode 100644
       
   133   > --- /dev/null
       
   134   > +++ b/a
       
   135   > @@ -0,0 +1,1 @@
       
   136   > I was not there before!
       
   137   > +Gello
       
   138   > ENDOF
       
   139   > EOF
       
   140 
       
   141   $ HGEDITOR="sh ./editor.sh" hg amend --patch
       
   142   abort: bad hunk #1 @@ -0,0 +1,1 @@
       
   143    (1 0 1 1)
       
   144   [255]
       
   145 
       
   146 Having deletions which dont exists
       
   147 
       
   148   $ cat > editor.sh <<EOF
       
   149   > #!/bin/sh
       
   150   > cat > \$1 <<ENDOF
       
   151   > # HG changeset patch
       
   152   > # User test
       
   153   > # Date 0 0
       
   154   > #      Thu Jan 01 00:00:00 1970 +0000
       
   155   > # Node ID af624b221c0c0bec5d74e2650180dd3eddcb7c42
       
   156   > # Parent  0000000000000000000000000000000000000000
       
   157   > added a
       
   158   > diff --git a/a b/a
       
   159   > new file mode 100644
       
   160   > --- /dev/null
       
   161   > +++ b/a
       
   162   > @@ -0,0 +1,1 @@
       
   163   > -I was not deleted before!
       
   164   > +Gello
       
   165   > ENDOF
       
   166   > EOF
       
   167 
       
   168   $ HGEDITOR="sh ./editor.sh" hg amend --patch
       
   169   abort: bad hunk #1 @@ -0,0 +1,1 @@
       
   170    (1 0 1 1)
       
   171   [255]
       
   172 
       
   173 Changing the file mode using amend --patch
       
   174 ------------------------------------------
       
   175 
       
   176   $ cat > editor.sh <<EOF
       
   177   > #!/bin/sh
       
   178   > cat > \$1 <<ENDOF
       
   179   > # HG changeset patch
       
   180   > # User test
       
   181   > # Date 0 0
       
   182   > #      Thu Jan 01 00:00:00 1970 +0000
       
   183   > # Node ID af624b221c0c0bec5d74e2650180dd3eddcb7c42
       
   184   > # Parent  0000000000000000000000000000000000000000
       
   185   > added a
       
   186   > diff --git a/a b/a
       
   187   > new file mode 100755
       
   188   > --- /dev/null
       
   189   > +++ b/a
       
   190   > @@ -0,0 +1,1 @@
       
   191   > +Gello
       
   192   > ENDOF
       
   193   > EOF
       
   194 
       
   195   $ HGEDITOR="sh ./editor.sh" hg amend --patch
       
   196 
       
   197   $ hg exp --git
       
   198   # HG changeset patch
       
   199   # User test
       
   200   # Date 0 0
       
   201   #      Thu Jan 01 00:00:00 1970 +0000
       
   202   # Node ID 3a99e4b7ac73da799e20ae56914e3dd5b1a22d4d
       
   203   # Parent  0000000000000000000000000000000000000000
       
   204   added a
       
   205   
       
   206   diff --git a/a b/a
       
   207   new file mode 100755
       
   208   --- /dev/null
       
   209   +++ b/a
       
   210   @@ -0,0 +1,1 @@
       
   211   +Gello
       
   212 
       
   213 Changing the file using amend --patch
       
   214 -------------------------------------
       
   215 
       
   216   $ cat > editor.sh <<EOF
       
   217   > #!/bin/sh
       
   218   > cat > \$1 <<ENDOF
       
   219   > # HG changeset patch
       
   220   > # User test
       
   221   > # Date 0 0
       
   222   > #      Thu Jan 01 00:00:00 1970 +0000
       
   223   > # Node ID 3a99e4b7ac73da799e20ae56914e3dd5b1a22d4d
       
   224   > # Parent  0000000000000000000000000000000000000000
       
   225   > added a
       
   226   > diff --git a/changedfile b/changedfile
       
   227   > new file mode 100755
       
   228   > --- /dev/null
       
   229   > +++ b/changedfile
       
   230   > @@ -0,0 +1,1 @@
       
   231   > +Gello
       
   232   > ENDOF
       
   233   > EOF
       
   234 
       
   235   $ HGEDITOR="sh ./editor.sh" hg amend --patch
       
   236 
       
   237   $ hg exp
       
   238   # HG changeset patch
       
   239   # User test
       
   240   # Date 0 0
       
   241   #      Thu Jan 01 00:00:00 1970 +0000
       
   242   # Node ID fc57c20be380f2878f4db139dad66d6cfb42ec62
       
   243   # Parent  0000000000000000000000000000000000000000
       
   244   added a
       
   245   
       
   246   diff --git a/changedfile b/changedfile
       
   247   new file mode 100755
       
   248   --- /dev/null
       
   249   +++ b/changedfile
       
   250   @@ -0,0 +1,1 @@
       
   251   +Gello
       
   252 
       
   253   $ hg status
       
   254   ? editor.sh
       
   255 
       
   256   $ ls
       
   257   changedfile
       
   258   editor.sh
       
   259 
       
   260 Handling both deletions and additions
       
   261 -------------------------------------
       
   262 
       
   263   $ echo foobar > changedfile
       
   264   $ hg ci -m "foobar to changedfile"
       
   265   $ hg exp
       
   266   # HG changeset patch
       
   267   # User test
       
   268   # Date 0 0
       
   269   #      Thu Jan 01 00:00:00 1970 +0000
       
   270   # Node ID 7969f70ffb81c3a6eee2d4f2f7032b694ce05349
       
   271   # Parent  fc57c20be380f2878f4db139dad66d6cfb42ec62
       
   272   foobar to changedfile
       
   273   
       
   274   diff --git a/changedfile b/changedfile
       
   275   --- a/changedfile
       
   276   +++ b/changedfile
       
   277   @@ -1,1 +1,1 @@
       
   278   -Gello
       
   279   +foobar
       
   280 
       
   281   $ cat > editor.sh <<EOF
       
   282   > #!/bin/sh
       
   283   > cat > \$1 <<ENDOF
       
   284   > # HG changeset patch
       
   285   > # User test
       
   286   > # Date 0 0
       
   287   > #      Thu Jan 01 00:00:00 1970 +0000
       
   288   > # Node ID 7969f70ffb81c3a6eee2d4f2f7032b694ce05349
       
   289   > # Parent  fc57c20be380f2878f4db139dad66d6cfb42ec62
       
   290   > foobar to changedfile
       
   291   > diff --git a/changedfile b/changedfile
       
   292   > --- a/changedfile
       
   293   > +++ b/changedfile
       
   294   > @@ -1,1 +1,1 @@
       
   295   > -Gello
       
   296   > +foobar
       
   297   > ENDOF
       
   298   > EOF
       
   299 
       
   300   $ HGEDITOR="sh ./editor.sh" hg amend --patch
       
   301   abort: nothing changed
       
   302   [255]
       
   303 
       
   304 Cannot change lines which are deleted
       
   305 
       
   306   $ cat > editor.sh <<EOF
       
   307   > #!/bin/sh
       
   308   > cat > \$1 <<ENDOF
       
   309   > # HG changeset patch
       
   310   > # User test
       
   311   > # Date 0 0
       
   312   > #      Thu Jan 01 00:00:00 1970 +0000
       
   313   > # Node ID 7969f70ffb81c3a6eee2d4f2f7032b694ce05349
       
   314   > # Parent  fc57c20be380f2878f4db139dad66d6cfb42ec62
       
   315   > foobar to changedfile
       
   316   > diff --git a/changedfile b/changedfile
       
   317   > --- a/changedfile
       
   318   > +++ b/changedfile
       
   319   > @@ -1,1 +1,1 @@
       
   320   > -Hello
       
   321   > +foobar
       
   322   > ENDOF
       
   323   > EOF
       
   324 
       
   325   $ HGEDITOR="sh ./editor.sh" hg amend --patch
       
   326   patching file changedfile
       
   327   Hunk #1 FAILED at 0
       
   328   abort: patch failed to apply
       
   329   [255]
       
   330 
       
   331 Add more addition to the patch
       
   332 
       
   333   $ cat > editor.sh <<EOF
       
   334   > #!/bin/sh
       
   335   > cat > \$1 <<ENDOF
       
   336   > # HG changeset patch
       
   337   > # User test
       
   338   > # Date 0 0
       
   339   > #      Thu Jan 01 00:00:00 1970 +0000
       
   340   > # Node ID 7969f70ffb81c3a6eee2d4f2f7032b694ce05349
       
   341   > # Parent  fc57c20be380f2878f4db139dad66d6cfb42ec62
       
   342   > foobar to changedfile
       
   343   > diff --git a/changedfile b/changedfile
       
   344   > --- a/changedfile
       
   345   > +++ b/changedfile
       
   346   > @@ -1,1 +1,2 @@
       
   347   > -Gello
       
   348   > +foobar
       
   349   > +babar
       
   350   > ENDOF
       
   351   > EOF
       
   352 
       
   353   $ HGEDITOR="sh ./editor.sh" hg amend --patch
       
   354 
       
   355   $ hg exp
       
   356   # HG changeset patch
       
   357   # User test
       
   358   # Date 0 0
       
   359   #      Thu Jan 01 00:00:00 1970 +0000
       
   360   # Node ID 5d54400acb70b88f07128a1df497ed794b0b177b
       
   361   # Parent  fc57c20be380f2878f4db139dad66d6cfb42ec62
       
   362   foobar to changedfile
       
   363   
       
   364   diff --git a/changedfile b/changedfile
       
   365   --- a/changedfile
       
   366   +++ b/changedfile
       
   367   @@ -1,1 +1,2 @@
       
   368   -Gello
       
   369   +foobar
       
   370   +babar
       
   371 
       
   372   $ cat changedfile
       
   373   foobar
       
   374   babar
       
   375 
       
   376 Introduce files which were not there
       
   377 ------------------------------------
       
   378 
       
   379   $ cat > editor.sh <<EOF
       
   380   > #!/bin/sh
       
   381   > cat > \$1 <<ENDOF
       
   382   > # HG changeset patch
       
   383   > # User test
       
   384   > # Date 0 0
       
   385   > #      Thu Jan 01 00:00:00 1970 +0000
       
   386   > # Node ID 5d54400acb70b88f07128a1df497ed794b0b177b
       
   387   > # Parent  fc57c20be380f2878f4db139dad66d6cfb42ec62
       
   388   > foobar to changedfile
       
   389   > diff --git a/changedfile b/changedfile
       
   390   > --- a/changedfile
       
   391   > +++ b/changedfile
       
   392   > @@ -1,1 +1,2 @@
       
   393   > -Gello
       
   394   > +foobar
       
   395   > +babar
       
   396   > diff --git a/a b/a
       
   397   > new file mode 100755
       
   398   > --- /dev/null
       
   399   > +++ b/a
       
   400   > @@ -0,0 +1,1 @@
       
   401   > +Gello
       
   402   > ENDOF
       
   403   > EOF
       
   404 
       
   405   $ HGEDITOR="sh ./editor.sh" hg amend --patch
       
   406 
       
   407   $ hg exp
       
   408   # HG changeset patch
       
   409   # User test
       
   410   # Date 0 0
       
   411   #      Thu Jan 01 00:00:00 1970 +0000
       
   412   # Node ID c3e29c061982c94418ce141d521434d6da76cd46
       
   413   # Parent  fc57c20be380f2878f4db139dad66d6cfb42ec62
       
   414   foobar to changedfile
       
   415   
       
   416   diff --git a/a b/a
       
   417   new file mode 100755
       
   418   --- /dev/null
       
   419   +++ b/a
       
   420   @@ -0,0 +1,1 @@
       
   421   +Gello
       
   422   diff --git a/changedfile b/changedfile
       
   423   --- a/changedfile
       
   424   +++ b/changedfile
       
   425   @@ -1,1 +1,2 @@
       
   426   -Gello
       
   427   +foobar
       
   428   +babar
       
   429 
       
   430 Delete files which were not deleted in the first place
       
   431 ------------------------------------------------------
       
   432 
       
   433   $ echo Hello >> a
       
   434   $ hg ci -m "hello to a"
       
   435   $ hg glog
       
   436   @  7:3d62c45a1699 hello to a
       
   437   |   () draft
       
   438   o  6:c3e29c061982 foobar to changedfile
       
   439   |   () draft
       
   440   o  3:fc57c20be380 added a
       
   441       () draft
       
   442 
       
   443   $ cat > editor.sh <<EOF
       
   444   > #!/bin/sh
       
   445   > cat > \$1 <<ENDOF
       
   446   > # HG changeset patch
       
   447   > # User test
       
   448   > # Date 0 0
       
   449   > #      Thu Jan 01 00:00:00 1970 +0000
       
   450   > # Node ID 3d62c45a1699b11c7ecae573f013601712f2cc5f
       
   451   > # Parent  c3e29c061982c94418ce141d521434d6da76cd46
       
   452   > hello to a
       
   453   > diff --git a/a b/a
       
   454   > --- a/a
       
   455   > +++ b/a
       
   456   > @@ -1,1 +1,2 @@
       
   457   >  Gello
       
   458   > +Hello
       
   459   > diff --git a/changedfile b/changedfile
       
   460   > deleted file mode 100755
       
   461   > --- a/changedfile
       
   462   > +++ /dev/null
       
   463   > @@ -1,2 +0,0 @@
       
   464   > -foobar
       
   465   > -babar
       
   466   > ENDOF
       
   467   > EOF
       
   468 
       
   469   $ HGEDITOR="sh ./editor.sh" hg amend --patch
       
   470 
       
   471   $ hg exp
       
   472   # HG changeset patch
       
   473   # User test
       
   474   # Date 0 0
       
   475   #      Thu Jan 01 00:00:00 1970 +0000
       
   476   # Node ID c9875799c53fb862c0dbaf01500459c9397373a4
       
   477   # Parent  c3e29c061982c94418ce141d521434d6da76cd46
       
   478   hello to a
       
   479   
       
   480   diff --git a/a b/a
       
   481   --- a/a
       
   482   +++ b/a
       
   483   @@ -1,1 +1,2 @@
       
   484    Gello
       
   485   +Hello
       
   486   diff --git a/changedfile b/changedfile
       
   487   deleted file mode 100755
       
   488   --- a/changedfile
       
   489   +++ /dev/null
       
   490   @@ -1,2 +0,0 @@
       
   491   -foobar
       
   492   -babar
       
   493 
       
   494   $ hg status
       
   495   ? editor.sh
       
   496 
       
   497   $ cat changedfile
       
   498   cat: changedfile: No such file or directory
       
   499   [1]
       
   500 
       
   501 Testing sercret phase preservation during `hg amend --patch`
       
   502 ------------------------------------------------------------
       
   503 
       
   504   $ hg phase -r . --secret --force
       
   505 
       
   506   $ hg phase -r .
       
   507   8: secret
       
   508 
       
   509   $ cat > editor.sh <<EOF
       
   510   > #!/bin/sh
       
   511   > cat > \$1 <<ENDOF
       
   512   > # HG changeset patch
       
   513   > # User test
       
   514   > # Date 0 0
       
   515   > #      Thu Jan 01 00:00:00 1970 +0000
       
   516   > # Node ID c9875799c53fb862c0dbaf01500459c9397373a4
       
   517   > # Parent  c3e29c061982c94418ce141d521434d6da76cd46
       
   518   > hello to a
       
   519   > diff --git a/a b/a
       
   520   > --- a/a
       
   521   > +++ b/a
       
   522   > @@ -1,1 +1,3 @@
       
   523   >  Gello
       
   524   > +Hello
       
   525   > +mello
       
   526   > diff --git a/changedfile b/changedfile
       
   527   > deleted file mode 100755
       
   528   > --- a/changedfile
       
   529   > +++ /dev/null
       
   530   > @@ -1,2 +0,0 @@
       
   531   > -foobar
       
   532   > -babar
       
   533   > ENDOF
       
   534   > EOF
       
   535 
       
   536   $ HGEDITOR="sh ./editor.sh" hg amend --patch
       
   537 
       
   538   $ hg exp
       
   539   # HG changeset patch
       
   540   # User test
       
   541   # Date 0 0
       
   542   #      Thu Jan 01 00:00:00 1970 +0000
       
   543   # Node ID 4414485658e719a1f3d5e58bc8b2412385aa1592
       
   544   # Parent  c3e29c061982c94418ce141d521434d6da76cd46
       
   545   hello to a
       
   546   
       
   547   diff --git a/a b/a
       
   548   --- a/a
       
   549   +++ b/a
       
   550   @@ -1,1 +1,3 @@
       
   551    Gello
       
   552   +Hello
       
   553   +mello
       
   554   diff --git a/changedfile b/changedfile
       
   555   deleted file mode 100755
       
   556   --- a/changedfile
       
   557   +++ /dev/null
       
   558   @@ -1,2 +0,0 @@
       
   559   -foobar
       
   560   -babar
       
   561 
       
   562   $ hg phase -r .
       
   563   9: secret
       
   564 
       
   565 Testing bookmark movement on amend --patch
       
   566 ------------------------------------------
       
   567 
       
   568   $ hg bookmark foo
       
   569   $ hg glog
       
   570   @  9:4414485658e7 hello to a
       
   571   |   (foo) secret
       
   572   o  6:c3e29c061982 foobar to changedfile
       
   573   |   () draft
       
   574   o  3:fc57c20be380 added a
       
   575       () draft
       
   576 
       
   577   $ cat > editor.sh <<EOF
       
   578   > #!/bin/sh
       
   579   > cat > \$1 <<ENDOF
       
   580   > # HG changeset patch
       
   581   > # User test
       
   582   > # Date 0 0
       
   583   > #      Thu Jan 01 00:00:00 1970 +0000
       
   584   > # Node ID 4414485658e719a1f3d5e58bc8b2412385aa1592
       
   585   > # Parent  c3e29c061982c94418ce141d521434d6da76cd46
       
   586   > hello to a
       
   587   > diff --git a/a b/a
       
   588   > --- a/a
       
   589   > +++ b/a
       
   590   > @@ -1,1 +1,3 @@
       
   591   >  Gello
       
   592   > +Hello
       
   593   > +bello
       
   594   > diff --git a/changedfile b/changedfile
       
   595   > deleted file mode 100755
       
   596   > --- a/changedfile
       
   597   > +++ /dev/null
       
   598   > @@ -1,2 +0,0 @@
       
   599   > -foobar
       
   600   > -babar
       
   601   > ENDOF
       
   602   > EOF
       
   603 
       
   604   $ HGEDITOR="sh ./editor.sh" hg amend --patch
       
   605 
       
   606   $ hg exp
       
   607   # HG changeset patch
       
   608   # User test
       
   609   # Date 0 0
       
   610   #      Thu Jan 01 00:00:00 1970 +0000
       
   611   # Node ID 36454bda1fdb8e2e4fe07bb084eef378e29cba74
       
   612   # Parent  c3e29c061982c94418ce141d521434d6da76cd46
       
   613   hello to a
       
   614   
       
   615   diff --git a/a b/a
       
   616   --- a/a
       
   617   +++ b/a
       
   618   @@ -1,1 +1,3 @@
       
   619    Gello
       
   620   +Hello
       
   621   +bello
       
   622   diff --git a/changedfile b/changedfile
       
   623   deleted file mode 100755
       
   624   --- a/changedfile
       
   625   +++ /dev/null
       
   626   @@ -1,2 +0,0 @@
       
   627   -foobar
       
   628   -babar
       
   629 
       
   630   $ hg glog
       
   631   @  10:36454bda1fdb hello to a
       
   632   |   (foo) secret
       
   633   o  6:c3e29c061982 foobar to changedfile
       
   634   |   () draft
       
   635   o  3:fc57c20be380 added a
       
   636       () draft
       
   637 
       
   638 Trying to amend --patch a public changeset
       
   639 ------------------------------------------
       
   640 
       
   641   $ hg phase -r . --public
       
   642   $ hg glog
       
   643   @  10:36454bda1fdb hello to a
       
   644   |   (foo) public
       
   645   o  6:c3e29c061982 foobar to changedfile
       
   646   |   () public
       
   647   o  3:fc57c20be380 added a
       
   648       () public
       
   649 
       
   650   $ HGEDITOR=cat hg amend --patch
       
   651   abort: cannot amend public changesets: 36454bda1fdb
       
   652   (see 'hg help phases' for details)
       
   653   [255]
       
   654 
       
   655   $ hg phase -r . --draft --force
       
   656 
       
   657 Trying on a dirty working directory
       
   658 -------------------------------------
       
   659 
       
   660   $ echo bar > bar
       
   661   $ hg add bar
       
   662   $ HGEDITOR=cat hg amend --patch
       
   663   abort: uncommitted changes
       
   664   [255]
       
   665 
       
   666   $ hg revert --all
       
   667   forgetting bar
       
   668 
       
   669 Trying to pass filenames, only mentioned file names should be popped up in
       
   670 editor and rest should stay in the commit as they were
       
   671 --------------------------------------------------------------------------
       
   672 
       
   673 Checking the we pop-up with the files which were mentioned
       
   674 
       
   675   $ HGEDITOR=cat hg amend --patch changedfile
       
   676   # HG changeset patch
       
   677   # User test
       
   678   # Date 0 0
       
   679   #      Thu Jan 01 00:00:00 1970 +0000
       
   680   # Node ID 36454bda1fdb8e2e4fe07bb084eef378e29cba74
       
   681   # Parent  c3e29c061982c94418ce141d521434d6da76cd46
       
   682   hello to a
       
   683   
       
   684   diff --git a/changedfile b/changedfile
       
   685   deleted file mode 100755
       
   686   --- a/changedfile
       
   687   +++ /dev/null
       
   688   @@ -1,2 +0,0 @@
       
   689   -foobar
       
   690   -babar
       
   691   abort: nothing changed
       
   692   [255]
       
   693 
       
   694   $ HGEDITOR=cat hg amend --patch a
       
   695   # HG changeset patch
       
   696   # User test
       
   697   # Date 0 0
       
   698   #      Thu Jan 01 00:00:00 1970 +0000
       
   699   # Node ID 36454bda1fdb8e2e4fe07bb084eef378e29cba74
       
   700   # Parent  c3e29c061982c94418ce141d521434d6da76cd46
       
   701   hello to a
       
   702   
       
   703   diff --git a/a b/a
       
   704   --- a/a
       
   705   +++ b/a
       
   706   @@ -1,1 +1,3 @@
       
   707    Gello
       
   708   +Hello
       
   709   +bello
       
   710   abort: nothing changed
       
   711   [255]
       
   712 
       
   713   $ HGEDITOR=cat hg amend --patch changedfile a
       
   714   # HG changeset patch
       
   715   # User test
       
   716   # Date 0 0
       
   717   #      Thu Jan 01 00:00:00 1970 +0000
       
   718   # Node ID 36454bda1fdb8e2e4fe07bb084eef378e29cba74
       
   719   # Parent  c3e29c061982c94418ce141d521434d6da76cd46
       
   720   hello to a
       
   721   
       
   722   diff --git a/a b/a
       
   723   --- a/a
       
   724   +++ b/a
       
   725   @@ -1,1 +1,3 @@
       
   726    Gello
       
   727   +Hello
       
   728   +bello
       
   729   diff --git a/changedfile b/changedfile
       
   730   deleted file mode 100755
       
   731   --- a/changedfile
       
   732   +++ /dev/null
       
   733   @@ -1,2 +0,0 @@
       
   734   -foobar
       
   735   -babar
       
   736   abort: nothing changed
       
   737   [255]
       
   738 
       
   739   $ HGEDITOR=cat hg amend --patch doesnotexists
       
   740   # HG changeset patch
       
   741   # User test
       
   742   # Date 0 0
       
   743   #      Thu Jan 01 00:00:00 1970 +0000
       
   744   # Node ID 36454bda1fdb8e2e4fe07bb084eef378e29cba74
       
   745   # Parent  c3e29c061982c94418ce141d521434d6da76cd46
       
   746   hello to a
       
   747   
       
   748   abort: nothing changed
       
   749   [255]
       
   750 
       
   751 Changing only one file
       
   752   $ cat > editor.sh <<EOF
       
   753   > #!/bin/sh
       
   754   > cat > \$1 <<ENDOF
       
   755   > # HG changeset patch
       
   756   > # User test
       
   757   > # Date 0 0
       
   758   > #      Thu Jan 01 00:00:00 1970 +0000
       
   759   > # Node ID 36454bda1fdb8e2e4fe07bb084eef378e29cba74
       
   760   > # Parent  c3e29c061982c94418ce141d521434d6da76cd46
       
   761   > hello to a
       
   762   > diff --git a/a b/a
       
   763   > --- a/a
       
   764   > +++ b/a
       
   765   > @@ -1,1 +1,3 @@
       
   766   >  Gello
       
   767   > +Hello
       
   768   > +betto
       
   769   > ENDOF
       
   770   > EOF
       
   771 
       
   772   $ HGEDITOR="sh ./editor.sh" hg amend --patch a
       
   773 
       
   774 file 'a' should be amended, rest of them should remain unchanged
       
   775 
       
   776   $ hg exp
       
   777   # HG changeset patch
       
   778   # User test
       
   779   # Date 0 0
       
   780   #      Thu Jan 01 00:00:00 1970 +0000
       
   781   # Node ID ea175dcc4ee38c106db157975e006b4092444c65
       
   782   # Parent  c3e29c061982c94418ce141d521434d6da76cd46
       
   783   hello to a
       
   784   
       
   785   diff --git a/a b/a
       
   786   --- a/a
       
   787   +++ b/a
       
   788   @@ -1,1 +1,3 @@
       
   789    Gello
       
   790   +Hello
       
   791   +betto
       
   792   diff --git a/changedfile b/changedfile
       
   793   deleted file mode 100755
       
   794   --- a/changedfile
       
   795   +++ /dev/null
       
   796   @@ -1,2 +0,0 @@
       
   797   -foobar
       
   798   -babar
       
   799 
       
   800   $ hg status
       
   801   ? bar
       
   802   ? editor.sh
       
   803 
       
   804   $ hg diff
       
   805 
       
   806 Testing again with file 'changedfile'
       
   807 
       
   808   $ cat > editor.sh <<EOF
       
   809   > #!/bin/sh
       
   810   > cat > \$1 <<ENDOF
       
   811   > # HG changeset patch
       
   812   > # User test
       
   813   > # Date 0 0
       
   814   > #      Thu Jan 01 00:00:00 1970 +0000
       
   815   > # Node ID ea175dcc4ee38c106db157975e006b4092444c65
       
   816   > # Parent  c3e29c061982c94418ce141d521434d6da76cd46
       
   817   > hello to a
       
   818   > diff --git a/changedfile b/changedfile
       
   819   > --- a/changedfile
       
   820   > +++ b/changedfile
       
   821   > @@ -1,2 +1,1 @@
       
   822   >  foobar
       
   823   > -babar
       
   824   > ENDOF
       
   825   > EOF
       
   826 
       
   827   $ HGEDITOR="sh ./editor.sh" hg amend --patch changedfile
       
   828 
       
   829   $ hg exp
       
   830   # HG changeset patch
       
   831   # User test
       
   832   # Date 0 0
       
   833   #      Thu Jan 01 00:00:00 1970 +0000
       
   834   # Node ID 0e64d76c3519308c398a28192cb095d48b29aede
       
   835   # Parent  c3e29c061982c94418ce141d521434d6da76cd46
       
   836   hello to a
       
   837   
       
   838   diff --git a/a b/a
       
   839   --- a/a
       
   840   +++ b/a
       
   841   @@ -1,1 +1,3 @@
       
   842    Gello
       
   843   +Hello
       
   844   +betto
       
   845   diff --git a/changedfile b/changedfile
       
   846   --- a/changedfile
       
   847   +++ b/changedfile
       
   848   @@ -1,2 +1,1 @@
       
   849    foobar
       
   850   -babar
       
   851 
       
   852   $ hg diff
       
   853   $ hg status
       
   854   ? bar
       
   855   ? editor.sh
       
   856 
       
   857 Dropping a file from commit by removing related hunks
       
   858 ------------------------------------------------------
       
   859 
       
   860   $ cat > editor.sh <<EOF
       
   861   > #!/bin/sh
       
   862   > cat > \$1 <<ENDOF
       
   863   > # HG changeset patch
       
   864   > # User test
       
   865   > # Date 0 0
       
   866   > #      Thu Jan 01 00:00:00 1970 +0000
       
   867   > # Node ID 0e64d76c3519308c398a28192cb095d48b29aede
       
   868   > # Parent  c3e29c061982c94418ce141d521434d6da76cd46
       
   869   > hello to a
       
   870   > diff --git a/a b/a
       
   871   > --- a/a
       
   872   > +++ b/a
       
   873   > @@ -1,1 +1,3 @@
       
   874   >  Gello
       
   875   > +Kello
       
   876   > +betto
       
   877   > ENDOF
       
   878   > EOF
       
   879 
       
   880   $ HGEDITOR="sh ./editor.sh" hg amend --patch
       
   881 
       
   882   $ hg exp
       
   883   # HG changeset patch
       
   884   # User test
       
   885   # Date 0 0
       
   886   #      Thu Jan 01 00:00:00 1970 +0000
       
   887   # Node ID 944e9f65fa55fdb2de98577c9d8ab30de0927d8e
       
   888   # Parent  c3e29c061982c94418ce141d521434d6da76cd46
       
   889   hello to a
       
   890   
       
   891   diff --git a/a b/a
       
   892   --- a/a
       
   893   +++ b/a
       
   894   @@ -1,1 +1,3 @@
       
   895    Gello
       
   896   +Kello
       
   897   +betto
       
   898 
       
   899 The part which was dropped from the patch will not be there in working directory
       
   900 too
       
   901   $ hg diff
       
   902 
       
   903   $ hg status
       
   904   ? bar
       
   905   ? editor.sh
       
   906 
       
   907 Changing metadata of a patch by editing patch content
       
   908 ======================================================
       
   909 
       
   910 Changing user
       
   911 -------------
       
   912 
       
   913   $ cat > editor.sh <<EOF
       
   914   > #!/bin/sh
       
   915   > cat > \$1 <<ENDOF
       
   916   > # HG changeset patch
       
   917   > # User RandomUser
       
   918   > # Date 0 0
       
   919   > #      Thu Jan 01 00:00:00 1970 +0000
       
   920   > # Node ID 944e9f65fa55fdb2de98577c9d8ab30de0927d8e
       
   921   > # Parent  c3e29c061982c94418ce141d521434d6da76cd46
       
   922   > hello to a
       
   923   > diff --git a/a b/a
       
   924   > --- a/a
       
   925   > +++ b/a
       
   926   > @@ -1,1 +1,3 @@
       
   927   >  Gello
       
   928   > +Kello
       
   929   > +betto
       
   930   > ENDOF
       
   931   > EOF
       
   932 
       
   933   $ HGEDITOR="sh ./editor.sh" hg amend --patch
       
   934 
       
   935   $ hg exp
       
   936   # HG changeset patch
       
   937   # User RandomUser
       
   938   # Date 0 0
       
   939   #      Thu Jan 01 00:00:00 1970 +0000
       
   940   # Node ID 5ded18a8c333a55da4b0e051162457cfe5d85558
       
   941   # Parent  c3e29c061982c94418ce141d521434d6da76cd46
       
   942   hello to a
       
   943   
       
   944   diff --git a/a b/a
       
   945   --- a/a
       
   946   +++ b/a
       
   947   @@ -1,1 +1,3 @@
       
   948    Gello
       
   949   +Kello
       
   950   +betto
       
   951 
       
   952 Changing Date
       
   953 -------------
       
   954 
       
   955   $ cat > editor.sh <<EOF
       
   956   > #!/bin/sh
       
   957   > cat > \$1 <<ENDOF
       
   958   > # HG changeset patch
       
   959   > # User RandomUser
       
   960   > # Date 123456 1200
       
   961   > #      Thu Jan 01 00:00:00 1970 +0000
       
   962   > # Node ID 944e9f65fa55fdb2de98577c9d8ab30de0927d8e
       
   963   > # Parent  c3e29c061982c94418ce141d521434d6da76cd46
       
   964   > hello to a
       
   965   > diff --git a/a b/a
       
   966   > --- a/a
       
   967   > +++ b/a
       
   968   > @@ -1,1 +1,3 @@
       
   969   >  Gello
       
   970   > +Kello
       
   971   > +betto
       
   972   > ENDOF
       
   973   > EOF
       
   974 
       
   975   $ HGEDITOR="sh ./editor.sh" hg amend --patch
       
   976 
       
   977   $ hg exp
       
   978   # HG changeset patch
       
   979   # User RandomUser
       
   980   # Date 123456 1200
       
   981   #      Fri Jan 02 09:57:36 1970 -0020
       
   982   # Node ID e2312ddcd8756665075a60bd05431ddca3c45050
       
   983   # Parent  c3e29c061982c94418ce141d521434d6da76cd46
       
   984   hello to a
       
   985   
       
   986   diff --git a/a b/a
       
   987   --- a/a
       
   988   +++ b/a
       
   989   @@ -1,1 +1,3 @@
       
   990    Gello
       
   991   +Kello
       
   992   +betto
       
   993 
       
   994 Changing branch
       
   995 ---------------
       
   996 
       
   997   $ cat > editor.sh <<EOF
       
   998   > #!/bin/sh
       
   999   > cat > \$1 <<ENDOF
       
  1000   > # HG changeset patch
       
  1001   > # User RandomUser
       
  1002   > # Date 123456 1200
       
  1003   > #      Thu Jan 01 00:00:00 1970 +0000
       
  1004   > # Branch stable
       
  1005   > # Node ID 944e9f65fa55fdb2de98577c9d8ab30de0927d8e
       
  1006   > # Parent  c3e29c061982c94418ce141d521434d6da76cd46
       
  1007   > hello to a
       
  1008   > diff --git a/a b/a
       
  1009   > --- a/a
       
  1010   > +++ b/a
       
  1011   > @@ -1,1 +1,3 @@
       
  1012   >  Gello
       
  1013   > +Kello
       
  1014   > +betto
       
  1015   > ENDOF
       
  1016   > EOF
       
  1017 
       
  1018   $ HGEDITOR="sh ./editor.sh" hg amend --patch
       
  1019 
       
  1020   $ hg exp
       
  1021   # HG changeset patch
       
  1022   # User RandomUser
       
  1023   # Date 123456 1200
       
  1024   #      Fri Jan 02 09:57:36 1970 -0020
       
  1025   # Branch stable
       
  1026   # Node ID ddc61a4058687b2dd4a316f4b5fe7d52a35b702a
       
  1027   # Parent  c3e29c061982c94418ce141d521434d6da76cd46
       
  1028   hello to a
       
  1029   
       
  1030   diff --git a/a b/a
       
  1031   --- a/a
       
  1032   +++ b/a
       
  1033   @@ -1,1 +1,3 @@
       
  1034    Gello
       
  1035   +Kello
       
  1036   +betto
       
  1037 
       
  1038 Changing parent (this should be fun)
       
  1039 ------------------------------------
       
  1040 
       
  1041   $ hg glog
       
  1042   @  16:ddc61a405868 hello to a
       
  1043   |   (foo) draft
       
  1044   o  6:c3e29c061982 foobar to changedfile
       
  1045   |   () public
       
  1046   o  3:fc57c20be380 added a
       
  1047       () public
       
  1048 
       
  1049   $ hg log -r .^^ -T '{node}'
       
  1050   fc57c20be380f2878f4db139dad66d6cfb42ec62 (no-eol)
       
  1051 
       
  1052   $ cat > editor.sh <<EOF
       
  1053   > #!/bin/sh
       
  1054   > cat > \$1 <<ENDOF
       
  1055   > # HG changeset patch
       
  1056   > # User RandomUser
       
  1057   > # Date 123456 1200
       
  1058   > #      Thu Jan 01 00:00:00 1970 +0000
       
  1059   > # Branch stable
       
  1060   > # Node ID 944e9f65fa55fdb2de98577c9d8ab30de0927d8e
       
  1061   > # Parent  fc57c20be380f2878f4db139dad66d6cfb42ec62
       
  1062   > hello to a
       
  1063   > diff --git a/a b/a
       
  1064   > --- a/a
       
  1065   > +++ b/a
       
  1066   > @@ -1,1 +1,3 @@
       
  1067   >  Gello
       
  1068   > +Kello
       
  1069   > +betto
       
  1070   > ENDOF
       
  1071   > EOF
       
  1072 
       
  1073   $ HGEDITOR="sh ./editor.sh" hg amend --patch
       
  1074 
       
  1075   $ hg exp
       
  1076   # HG changeset patch
       
  1077   # User RandomUser
       
  1078   # Date 123456 1200
       
  1079   #      Fri Jan 02 09:57:36 1970 -0020
       
  1080   # Branch stable
       
  1081   # Node ID b763f7cb2302f2efa1275e2a9202655872c9567f
       
  1082   # Parent  fc57c20be380f2878f4db139dad66d6cfb42ec62
       
  1083   hello to a
       
  1084   
       
  1085   diff --git a/a b/a
       
  1086   new file mode 100755
       
  1087   --- /dev/null
       
  1088   +++ b/a
       
  1089   @@ -0,0 +1,3 @@
       
  1090   +Gello
       
  1091   +Kello
       
  1092   +betto
       
  1093 
       
  1094   $ hg glog
       
  1095   @  17:b763f7cb2302 hello to a
       
  1096   |   (foo) draft
       
  1097   | o  6:c3e29c061982 foobar to changedfile
       
  1098   |/    () public
       
  1099   o  3:fc57c20be380 added a
       
  1100       () public
       
  1101 
       
  1102 Changing the commit desciption
       
  1103 -------------------------------
       
  1104 
       
  1105   $ cat > editor.sh <<EOF
       
  1106   > #!/bin/sh
       
  1107   > cat > \$1 <<ENDOF
       
  1108   > # HG changeset patch
       
  1109   > # User RandomUser
       
  1110   > # Date 123456 1200
       
  1111   > #      Thu Jan 01 00:00:00 1970 +0000
       
  1112   > # Branch stable
       
  1113   > # Node ID 944e9f65fa55fdb2de98577c9d8ab30de0927d8e
       
  1114   > # Parent  fc57c20be380f2878f4db139dad66d6cfb42ec62
       
  1115   > I am a message which is testing change of message
       
  1116   > diff --git a/a b/a
       
  1117   > new file mode 100755
       
  1118   > --- /dev/null
       
  1119   > +++ b/a
       
  1120   > @@ -0,0 +1,3 @@
       
  1121   > +Gello
       
  1122   > +Kello
       
  1123   > +betto
       
  1124   > ENDOF
       
  1125   > EOF
       
  1126 
       
  1127   $ HGEDITOR="sh ./editor.sh" hg amend --patch
       
  1128 
       
  1129   $ hg exp
       
  1130   # HG changeset patch
       
  1131   # User RandomUser
       
  1132   # Date 123456 1200
       
  1133   #      Fri Jan 02 09:57:36 1970 -0020
       
  1134   # Branch stable
       
  1135   # Node ID f14ecd7121e63915ac93edbad7f60f605e62dd52
       
  1136   # Parent  fc57c20be380f2878f4db139dad66d6cfb42ec62
       
  1137   I am a message which is testing change of message
       
  1138   
       
  1139   diff --git a/a b/a
       
  1140   new file mode 100755
       
  1141   --- /dev/null
       
  1142   +++ b/a
       
  1143   @@ -0,0 +1,3 @@
       
  1144   +Gello
       
  1145   +Kello
       
  1146   +betto
       
  1147 
       
  1148 Changing the Node ID of the patch
       
  1149 ---------------------------------
       
  1150 
       
  1151 Nothing happens in that case we dont care about the node ID. Look the above 3-4
       
  1152 tests to realize I was testing that too.