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