[PATCH 2 of 3 STABLE] commands: make outgoing-like commands sensitive to branch in URL (issue3829)

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Sun Feb 17 09:26:36 CST 2013


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1361113469 -32400
# Branch stable
# Node ID 373c150caa5f20ae975e086b8f211811afbd1687
# Parent  f63d2a3d62855a430b7a4323bbfaef1e696dc471
commands: make outgoing-like commands sensitive to branch in URL (issue3829)

Before this patch, commands below are not sensitive to the branch
specified in the URL of the destination repository, even though "hg
push"/"hg outgoing" are so:

    - hg histedit --outgoing
    - hg summary --remote

These invoke "discovery.findcommonoutgoing()" without "onlyheads"
argument, so it returns revisions on branches other than the one
specified in the URL, too.

This patch specifies heads revisions, which are already detected by
"hg.addbranchrevs()" and "repo.lookup()", as "onlyheads" to
"discovery.findcommonoutgoing()" to limit calculation of outgoing
revisions.

This patch also removes "repo.changelog.nodesbetween()" invocations in
largefiles extension, because it is meaningless if
"discovery.findcommonoutgoing()" is invoked with "onlyheads".

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -459,7 +459,7 @@
         # contains special revset characters like ":" the revset
         # parser can choke.
         parent = [node.hex(n) for n in discovery.findcommonoutgoing(
-            repo, other, [], force=opts.get('force')).missing[0:1]]
+            repo, other, revs, force=opts.get('force')).missing[0:1]]
     else:
         if opts.get('force'):
             raise util.Abort(_('--force only allowed with --outgoing'))
diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -1000,15 +1000,15 @@
         remote = hg.peer(repo, opts, dest)
     except error.RepoError:
         return None
-    outgoing = discovery.findcommonoutgoing(repo, remote.peer(), force=False)
+    outgoing = discovery.findcommonoutgoing(repo, remote.peer(),
+                                            onlyheads=revs, force=False)
     if not outgoing.missing:
         return outgoing.missing
-    o = repo.changelog.nodesbetween(outgoing.missing, revs)[0]
     if opts.get('newest_first'):
-        o.reverse()
+        outgoing.missing.reverse()
 
     toupload = set()
-    for n in o:
+    for n in outgoing.missing:
         parents = [p for p in repo.changelog.parents(n) if p != node.nullid]
         ctx = repo[n]
         files = set(ctx.files())
diff --git a/hgext/largefiles/reposetup.py b/hgext/largefiles/reposetup.py
--- a/hgext/largefiles/reposetup.py
+++ b/hgext/largefiles/reposetup.py
@@ -406,11 +406,11 @@
 
         def push(self, remote, force=False, revs=None, newbranch=False):
             outgoing = discovery.findcommonoutgoing(repo, remote.peer(),
+                                                    onlyheads=revs,
                                                     force=force)
             if outgoing.missing:
                 toupload = set()
-                o = self.changelog.nodesbetween(outgoing.missing, revs)[0]
-                for n in o:
+                for n in outgoing.missing:
                     parents = [p for p in self.changelog.parents(n)
                                if p != node_.nullid]
                     ctx = self[n]
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -5691,8 +5691,10 @@
             other = hg.peer(repo, {}, dest)
             commoninc = None
             ui.debug('comparing with %s\n' % util.hidepassword(dest))
+        if revs:
+            revs = [repo.lookup(rev) for rev in revs]
         repo.ui.pushbuffer()
-        outgoing = discovery.findcommonoutgoing(repo, other,
+        outgoing = discovery.findcommonoutgoing(repo, other, onlyheads=revs,
                                                 commoninc=commoninc)
         repo.ui.popbuffer()
         o = outgoing.missing
diff --git a/tests/test-histedit-outgoing.t b/tests/test-histedit-outgoing.t
--- a/tests/test-histedit-outgoing.t
+++ b/tests/test-histedit-outgoing.t
@@ -82,3 +82,24 @@
   #
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ cd ..
+
+test sensitivity to branch in URL (issue3829):
+
+  $ cd r2
+  $ hg -q update 2
+  $ hg -q branch foo
+  $ hg commit -m 'create foo branch'
+  $ HGEDITOR=cat hg histedit --outgoing '../r#foo' | grep -v comparing | grep -v searching
+  pick f26599ee3441 6 create foo branch
+  
+  # Edit history between f26599ee3441 and f26599ee3441
+  #
+  # Commands:
+  #  p, pick = use commit
+  #  e, edit = use commit, but stop for amending
+  #  f, fold = use commit, but fold into previous commit (combines N and N-1)
+  #  d, drop = remove commit from history
+  #  m, mess = edit message without changing commit content
+  #
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ cd ..
diff --git a/tests/test-largefiles.t b/tests/test-largefiles.t
--- a/tests/test-largefiles.t
+++ b/tests/test-largefiles.t
@@ -2111,4 +2111,72 @@
   b
   
 
+test sensitivity to branch in URL (issue3829):
+
+  $ cd clone2
+  $ hg -q update 0
+  $ hg -q branch foo
+  $ echo c > c
+  $ hg add --large c
+  $ hg -q commit -m 'create foo branch'
+  Invoking status precommit hook
+  A c
+
+  $ hg outgoing --large --template '{rev}\n'
+  comparing with $TESTTMP/issue3651/src
+  searching for changes
+  1
+  2
+  searching for changes
+  largefiles to upload:
+  b
+  c
+  
+  $ hg summary --large --remote
+  parent: 2:d8c88cf19687 tip
+   create foo branch
+  branch: foo
+  commit: (clean)
+  update: (current)
+  remote: 2 outgoing
+  searching for changes
+  largefiles: 2 to upload
+
+  $ hg outgoing --large --template '{rev}\n' --config paths.default='../src#default'
+  comparing with $TESTTMP/issue3651/src
+  searching for changes
+  1
+  searching for changes
+  largefiles to upload:
+  b
+  
+  $ hg summary --large --remote --config paths.default='../src#default'
+  parent: 2:d8c88cf19687 tip
+   create foo branch
+  branch: foo
+  commit: (clean)
+  update: (current)
+  remote: 1 outgoing
+  searching for changes
+  largefiles: 1 to upload
+
+  $ ls -1 ../src/.hg/largefiles
+  3f786850e387550fdab836ed7e6dc881de23001b
+  dirstate
+  $ hg -q push '../src#default'
+  $ ls -1 ../src/.hg/largefiles
+  3f786850e387550fdab836ed7e6dc881de23001b
+  89e6c98d92887913cadf06b2adb97f26cde4849b
+  dirstate
+  $ hg outgoing --large --template '{rev}\n'
+  comparing with $TESTTMP/issue3651/src
+  searching for changes
+  2
+  searching for changes
+  largefiles to upload:
+  c
+  
+
   $ cd ..
+
+  $ cd ..
diff --git a/tests/test-url-rev.t b/tests/test-url-rev.t
--- a/tests/test-url-rev.t
+++ b/tests/test-url-rev.t
@@ -80,8 +80,25 @@
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     add a
   
+  $ hg -q outgoing '../clone'
+  2:faba9097cad4
+  3:4cd725637392
+  $ hg --config paths.default='../clone' summary --remote
+  parent: 3:4cd725637392 tip
+   add bar
+  branch: default
+  commit: (clean)
+  update: (current)
+  remote: 2 outgoing
   $ hg -q outgoing '../clone#foo'
   2:faba9097cad4
+  $ hg --config paths.default='../clone#foo' summary --remote
+  parent: 3:4cd725637392 tip
+   add bar
+  branch: default
+  commit: (clean)
+  update: (current)
+  remote: 1 outgoing
 
   $ hg -q push '../clone#foo'
 


More information about the Mercurial-devel mailing list