Patchwork D6529: strip: during merge allow strip only when -f is used

login
register
mail settings
Submitter phabricator
Date June 14, 2019, 12:59 p.m.
Message ID <differential-rev-PHID-DREV-j3cqbymt65pnydulhje5-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/40509/
State Superseded
Headers show

Comments

phabricator - June 14, 2019, 12:59 p.m.
taapas1128 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This ensures to abort strip to `hg strip` when we have a merge
  in progress and allow it only when a `--force` flag is used.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D6529

AFFECTED FILES
  hgext/strip.py
  tests/test-strip.t

CHANGE DETAILS




To: taapas1128, #hg-reviewers
Cc: mercurial-devel
phabricator - June 14, 2019, 1:28 p.m.
pulkit added inline comments.

INLINE COMMENTS

> strip.py:54
> +        if len(repo[None].parents()) > 1:
> +            raise error.Abort(_('outstanding uncommitted merge'))
>          if s.modified or s.added or s.removed or s.deleted:

we will need a similar dance for i18n tool detection which is done below.

also we need to add excsuffix to error message too.

> test-strip.t:282
> +  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
> +  saved backup bundle to $TESTTMP/test/.hg/strip-backup/264128213d29-0b39d6bf-backup.hg
>  

this and the similar changes below should be globbed as they were before.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6529/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D6529

To: taapas1128, #hg-reviewers
Cc: pulkit, mercurial-devel

Patch

diff --git a/tests/test-strip.t b/tests/test-strip.t
--- a/tests/test-strip.t
+++ b/tests/test-strip.t
@@ -272,9 +272,14 @@ 
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     c
   
+##strip not allowed with merge in progress
   $ hg strip 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)
+  abort: outstanding uncommitted merge
+  [255]
+##strip allowed --force with merge in progress
+  $ hg strip 4 --force
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  saved backup bundle to $TESTTMP/test/.hg/strip-backup/264128213d29-0b39d6bf-backup.hg
 
 after strip of merge parent
 
@@ -322,7 +327,7 @@ 
 2 is parent of 3, only one strip should happen
 
   $ hg strip "roots(2)" 3
-  saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
+  saved backup bundle to $TESTTMP/test/.hg/strip-backup/65bd5f99a4a3-0eb9aae0-backup.hg
   $ hg log -G
   @  changeset:   2:264128213d29
   |  tag:         tip
@@ -373,12 +378,12 @@ 
 
   $ 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)
+  saved backup bundle to $TESTTMP/test/.hg/strip-backup/264128213d29-0b39d6bf-backup.hg
   transaction abort!
   rollback completed
-  strip failed, backup bundle stored in '$TESTTMP/test/.hg/strip-backup/*-backup.hg' (glob)
-  strip failed, unrecovered changes stored in '$TESTTMP/test/.hg/strip-backup/*-temp.hg' (glob)
-  (fix the problem, then recover the changesets with "hg unbundle '$TESTTMP/test/.hg/strip-backup/*-temp.hg'") (glob)
+  strip failed, backup bundle stored in '$TESTTMP/test/.hg/strip-backup/264128213d29-0b39d6bf-backup.hg'
+  strip failed, unrecovered changes stored in '$TESTTMP/test/.hg/strip-backup/264128213d29-0eb9aae0-temp.hg'
+  (fix the problem, then recover the changesets with "hg unbundle '$TESTTMP/test/.hg/strip-backup/264128213d29-0eb9aae0-temp.hg'")
   abort: pretxnchangegroup.bad hook exited with status 1
   [255]
   $ restore
@@ -414,7 +419,7 @@ 
 2 different branches: 2 strips
 
   $ hg strip 2 4
-  saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
+  saved backup bundle to $TESTTMP/test/.hg/strip-backup/443431ffac4f-21215376-backup.hg
   $ hg log -G
   o  changeset:   2:65bd5f99a4a3
   |  tag:         tip
@@ -438,7 +443,7 @@ 
 
   $ hg strip 1 "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)
+  saved backup bundle to $TESTTMP/test/.hg/strip-backup/ef3a871183d7-7c4e7e70-backup.hg
   $ restore
 
 verify fncache is kept up-to-date
diff --git a/hgext/strip.py b/hgext/strip.py
--- a/hgext/strip.py
+++ b/hgext/strip.py
@@ -50,6 +50,8 @@ 
     cmdutil.checkunfinished(repo)
     s = repo.status()
     if not force:
+        if len(repo[None].parents()) > 1:
+            raise error.Abort(_('outstanding uncommitted merge'))
         if s.modified or s.added or s.removed or s.deleted:
             _("local changes found") # i18n tool detection
             raise error.Abort(_("local changes found" + excsuffix))