Patchwork [1,of,2] phases: allow sharing secrets with friends (support for outgoing)

login
register
mail settings
Submitter Dov Feldstern
Date Feb. 17, 2014, 1:05 a.m.
Message ID <2a72585fec2c89d2f6d6.1392599100@pollen.home>
Download mbox | patch
Permalink /patch/3679/
State Rejected
Headers show

Comments

Dov Feldstern - Feb. 17, 2014, 1:05 a.m.
# HG changeset patch
# User Dov Feldstern <dovdevel@gmail.com>
# Date 1392588813 -7200
#      Mon Feb 17 00:13:33 2014 +0200
# Branch stable
# Node ID 2a72585fec2c89d2f6d65c335fbc94dd3b6e3053
# Parent  4e41b2fe46ccfb9722e51e23902f7019d286b15d
phases: allow sharing secrets with friends (support for outgoing)

THIS IS NOT FOR INCLUSION AS-IS! This is just for reference along with the
discussion titled "sharing secret changesets with friends".
Sean Farley - Feb. 17, 2014, 4:17 a.m.
Dov Feldstern <dovdevel@gmail.com> writes:

> # HG changeset patch
> # User Dov Feldstern <dovdevel@gmail.com>
> # Date 1392588813 -7200
> #      Mon Feb 17 00:13:33 2014 +0200
> # Branch stable
> # Node ID 2a72585fec2c89d2f6d65c335fbc94dd3b6e3053
> # Parent  4e41b2fe46ccfb9722e51e23902f7019d286b15d
> phases: allow sharing secrets with friends (support for outgoing)
>
> THIS IS NOT FOR INCLUSION AS-IS! This is just for reference along with the
> discussion titled "sharing secret changesets with friends".

Just a heads up that we usually just pass the '--flag RFC' option for 'hg email'.

Patch

diff -r 4e41b2fe46cc -r 2a72585fec2c mercurial/commands.py
--- a/mercurial/commands.py	Thu Feb 13 13:05:09 2014 +0100
+++ b/mercurial/commands.py	Mon Feb 17 00:13:33 2014 +0200
@@ -4330,6 +4330,7 @@ 
     ('B', 'bookmarks', False, _('compare bookmarks')),
     ('b', 'branch', [], _('a specific branch you would like to push'),
      _('BRANCH')),
+    ('F', 'friend', False, _('share secret changesets with peer')),
     ] + logopts + remoteopts + subrepoopts,
     _('[-M] [-p] [-n] [-f] [-r REV]... [DEST]'))
 def outgoing(ui, repo, dest=None, **opts):
diff -r 4e41b2fe46cc -r 2a72585fec2c mercurial/discovery.py
--- a/mercurial/discovery.py	Thu Feb 13 13:05:09 2014 +0100
+++ b/mercurial/discovery.py	Mon Feb 17 00:13:33 2014 +0200
@@ -88,7 +88,7 @@ 
         return self._missing
 
 def findcommonoutgoing(repo, other, onlyheads=None, force=False,
-                       commoninc=None, portable=False):
+                       commoninc=None, portable=False, friend=False):
     '''Return an outgoing instance to identify the nodes present in repo but
     not in other.
 
@@ -115,8 +115,12 @@ 
         og.missingheads = onlyheads or repo.heads()
     elif onlyheads is None:
         # use visible heads as it should be cached
-        og.missingheads = repo.filtered("served").heads()
-        og.excluded = [ctx.node() for ctx in repo.set('secret() or extinct()')]
+        if friend:
+            og.missingheads = repo.filtered("visible").heads()
+            og.excluded = [ctx.node() for ctx in repo.set('extinct()')]
+        else:
+            og.missingheads = repo.filtered("served").heads()
+            og.excluded = [ctx.node() for ctx in repo.set('secret() or extinct()')]
     else:
         # compute common, missing and exclude secret stuff
         sets = repo.changelog.findcommonmissing(og.commonheads, onlyheads)
@@ -125,7 +129,7 @@ 
         og.excluded = excluded = []
         for node in allmissing:
             ctx = repo[node]
-            if ctx.phase() >= phases.secret or ctx.extinct():
+            if (ctx.phase() >= phases.secret and not friend) or ctx.extinct():
                 excluded.append(node)
             else:
                 missing.append(node)
diff -r 4e41b2fe46cc -r 2a72585fec2c mercurial/hg.py
--- a/mercurial/hg.py	Thu Feb 13 13:05:09 2014 +0100
+++ b/mercurial/hg.py	Mon Feb 17 00:13:33 2014 +0200
@@ -555,7 +555,7 @@ 
 
     other = peer(repo, opts, dest)
     outgoing = discovery.findcommonoutgoing(repo.unfiltered(), other, revs,
-                                            force=opts.get('force'))
+                                            force=opts.get('force'), friend=opts.get('friend'))
     o = outgoing.missing
     if not o:
         scmutil.nochangesfound(repo.ui, repo, outgoing.excluded)