strip: report both bundle files in case of exception (issue5368)
authorMartin von Zweigbergk <martinvonz@google.com>
Thu, 15 Sep 2016 09:45:29 -0700
changeset 29952 44ef21621ad7
parent 29951 e7acbe538baf
child 29953 94ebf56db04e
strip: report both bundle files in case of exception (issue5368) If strip fails while recovering the temporary bundle (e.g. because a hook fails), we tell the user only about the backup bundle, not about the temporary bundle. Since the user did not ask to strip the commits in the temporary bundle, that's the more important bundle to mention, so let's do that (and also mention the backup bundle as usual).
mercurial/repair.py
tests/test-strip.t
--- a/mercurial/repair.py	Thu Sep 15 10:18:56 2016 -0700
+++ b/mercurial/repair.py	Thu Sep 15 09:45:29 2016 -0700
@@ -230,7 +230,7 @@
         if backupfile:
             ui.warn(_("strip failed, full bundle stored in '%s'\n")
                     % vfs.join(backupfile))
-        elif chgrpfile:
+        if chgrpfile:
             ui.warn(_("strip failed, partial bundle stored in '%s'\n")
                     % vfs.join(chgrpfile))
         raise
--- a/tests/test-strip.t	Thu Sep 15 10:18:56 2016 -0700
+++ b/tests/test-strip.t	Thu Sep 15 09:45:29 2016 -0700
@@ -367,11 +367,50 @@
      date:        Thu Jan 01 00:00:00 1970 +0000
      summary:     a
   
+Failed hook while applying "saveheads" bundle.
+
+  $ hg strip 2 --config hooks.pretxnchangegroup.bad=false
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
+  transaction abort!
+  rollback completed
+  strip failed, full bundle stored in '$TESTTMP/test/.hg/strip-backup/*-backup.hg' (glob)
+  strip failed, partial bundle stored in '$TESTTMP/test/.hg/strip-backup/*-temp.hg' (glob)
+  abort: pretxnchangegroup.bad hook exited with status 1
+  [255]
+  $ restore
+  $ hg log -G
+  o  changeset:   4:443431ffac4f
+  |  tag:         tip
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     e
+  |
+  o  changeset:   3:65bd5f99a4a3
+  |  parent:      1:ef3a871183d7
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     d
+  |
+  | o  changeset:   2:264128213d29
+  |/   user:        test
+  |    date:        Thu Jan 01 00:00:00 1970 +0000
+  |    summary:     c
+  |
+  @  changeset:   1:ef3a871183d7
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     b
+  |
+  o  changeset:   0:9ab35a2d17cb
+     user:        test
+     date:        Thu Jan 01 00:00:00 1970 +0000
+     summary:     a
+  
 
 2 different branches: 2 strips
 
   $ hg strip 2 4
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
   $ hg log -G
   o  changeset:   2:65bd5f99a4a3