histedit: abort if there are multiple roots in "--outgoing" revisions
authorFUJIWARA Katsunori <foozy@lares.dti.ne.jp>
Tue, 01 Oct 2013 00:12:34 +0900
changeset 19835 44d7bfe08c14
parent 19834 80633eac7b9d
child 19836 e7c0e5f81367
histedit: abort if there are multiple roots in "--outgoing" revisions Before this patch, if there are multiple roots in "--outgoing" revisions, result of "histedit --outgoing" depends on the parent of the working directory. It succeeds only when the parent of the working directory is a descendant of the oldest root in "--outgoing" revisions, and fails otherwise. It seems to be ambiguous and difficult for users. This patch makes "histedit --outgoing" abort if there are multiple roots in "--outgoing" revisions always.
hgext/histedit.py
tests/test-histedit-outgoing.t
--- a/hgext/histedit.py	Fri Sep 06 13:30:58 2013 +0400
+++ b/hgext/histedit.py	Tue Oct 01 00:12:34 2013 +0900
@@ -422,7 +422,12 @@
     outgoing = discovery.findcommonoutgoing(repo, other, revs, force=force)
     if not outgoing.missing:
         raise util.Abort(_('no outgoing ancestors'))
-    return outgoing.missing[0]
+    roots = list(repo.revs("roots(%ln)", outgoing.missing))
+    if 1 < len(roots):
+        msg = _('there are ambiguous outgoing revisions')
+        hint = _('see "hg help histedit" for more detail')
+        raise util.Abort(msg, hint=hint)
+    return repo.lookup(roots[0])
 
 actiontable = {'p': pick,
                'pick': pick,
--- a/tests/test-histedit-outgoing.t	Fri Sep 06 13:30:58 2013 +0400
+++ b/tests/test-histedit-outgoing.t	Tue Oct 01 00:12:34 2013 +0900
@@ -102,4 +102,38 @@
   #  m, mess = edit message without changing commit content
   #
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+test to check number of roots in outgoing revisions
+
+  $ hg -q outgoing -G --template '{node|short}({branch})' '../r'
+  @  f26599ee3441(foo)
+  
+  o  652413bf663e(default)
+  |
+  o  e860deea161a(default)
+  |
+  o  055a42cdd887(default)
+  
+  $ HGEDITOR=cat hg -q histedit --outgoing '../r'
+  abort: there are ambiguous outgoing revisions
+  (see "hg help histedit" for more detail)
+  [255]
+
+  $ hg -q update -C 2
+  $ echo aa >> a
+  $ hg -q commit -m 'another head on default'
+  $ hg -q outgoing -G --template '{node|short}({branch})' '../r#default'
+  @  3879dc049647(default)
+  
+  o  652413bf663e(default)
+  |
+  o  e860deea161a(default)
+  |
+  o  055a42cdd887(default)
+  
+  $ HGEDITOR=cat hg -q histedit --outgoing '../r#default'
+  abort: there are ambiguous outgoing revisions
+  (see "hg help histedit" for more detail)
+  [255]
+
   $ cd ..