Patchwork D8437: phabricator: prevent posting obsolete commits

login
register
mail settings
Submitter phabricator
Date April 16, 2020, 4:43 p.m.
Message ID <fad7dfaa95a014ba7671898e4571688e@localhost.localdomain>
Download mbox | patch
Permalink /patch/46164/
State Not Applicable
Headers show

Comments

phabricator - April 16, 2020, 4:43 p.m.
Closed by commit rHGc482e2fe444c: phabricator: prevent posting obsolete commits (authored by mharbison72).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8437?vs=21114&id=21136

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

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

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

CHANGE DETAILS




To: mharbison72, #hg-reviewers, Alphare
Cc: Alphare, Kwan, mercurial-devel

Patch

diff --git a/tests/test-phabricator.t b/tests/test-phabricator.t
--- a/tests/test-phabricator.t
+++ b/tests/test-phabricator.t
@@ -229,6 +229,58 @@ 
   o  0   5cbade24e0fa   1970-01-01 00:00 +0000   test
        added
   
+Posting obsolete commits is disallowed
+
+  $ echo "mod3" > file1.txt
+  $ hg ci -m 'modified A'
+  $ echo "mod4" > file1.txt
+  $ hg ci -m 'modified B'
+
+  $ hg up '.^'
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ echo 'obsolete' > file1.txt
+  $ hg amend --config extensions.amend=
+  1 new orphan changesets
+  $ hg log -G
+  @  changeset:   8:8d83edb3cbac
+  |  tag:         tip
+  |  parent:      5:1dff6b051abf
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     modified A
+  |
+  | *  changeset:   7:d4ea1b2e3511
+  | |  user:        test
+  | |  date:        Thu Jan 01 00:00:00 1970 +0000
+  | |  instability: orphan
+  | |  summary:     modified B
+  | |
+  | x  changeset:   6:4635d7f0d1ff
+  |/   user:        test
+  |    date:        Thu Jan 01 00:00:00 1970 +0000
+  |    obsolete:    rewritten using amend as 8:8d83edb3cbac
+  |    summary:     modified A
+  |
+  o  changeset:   5:1dff6b051abf
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     modified 2
+  |
+  o  changeset:   4:eb3752621d45
+  |  parent:      0:5cbade24e0fa
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     modified 1
+  |
+  o  changeset:   0:5cbade24e0fa
+     user:        test
+     date:        Thu Jan 01 00:00:00 1970 +0000
+     summary:     added
+  
+  $ hg phabsend -r 5::
+  abort: obsolete commits cannot be posted for review
+  [255]
+
   $ cd ..
 
 Phabesending a new binary, a modified binary, and a removed binary
diff --git a/hgext/phabricator.py b/hgext/phabricator.py
--- a/hgext/phabricator.py
+++ b/hgext/phabricator.py
@@ -1304,6 +1304,9 @@ 
 
     ctxs = [repo[rev] for rev in revs]
 
+    if any(c for c in ctxs if c.obsolete()):
+        raise error.Abort(_(b"obsolete commits cannot be posted for review"))
+
     fold = opts.get(b'fold')
     if fold:
         if len(revs) == 1: