Patchwork [4,of,4,STABLE,V2] summary: clear "commonincoming" also if branches are different

login
register
mail settings
Submitter Katsunori FUJIWARA
Date April 9, 2013, 3:05 p.m.
Message ID <b51b9dfb1fdab9999c04.1365519906@juju>
Download mbox | patch
Permalink /patch/1263/
State Accepted
Commit 4cf09a1bf5b2c88b753a2fcc6ad11fdeb3d99889
Headers show

Comments

Katsunori FUJIWARA - April 9, 2013, 3:05 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1365518411 -32400
# Branch stable
# Node ID b51b9dfb1fdab9999c04d99f955490de33673cae
# Parent  e4aff2f0f9968551a9896504bebe0680d629c770
summary: clear "commonincoming" also if branches are different

Before this patch, "commonincoming" calculated by
"discovery.findcommonincoming()" is cleared, only if "default" URL
without branch part (tail "#branch" of URL) differs from
"default-push" URL without branch part.

But common revisions in "commonincoming" calculated for a branch
doesn't include ones for another branch, even if URLs without branch
part are same. The result of "discovery.findcommonoutgoing()"
invocation with such "commonincoming" becomes incorrect in some cases.

This patch clears "commonincoming", also if branch part of "default"
differs from one of "default-push".

To avoid redundant looking up:

  - "ui.expandpath('default')" and "ui.expandpath('default-push',
    'default')" are not compared directly, even though they contain
    branch information, because they are not yet normalized by
    "hg.parseurl()": tail "/" of path, for example

  - "commonincoming" is not cleared, if branch isn't specified in
    "default" URL, because such "commonincoming" contains common
    revisions for all branches

This patch also tests "different path, same branch" pattern to check
careless degrading around comparison between source and destination.
Matt Mackall - April 16, 2013, 11:56 p.m.
On Wed, 2013-04-10 at 00:05 +0900, FUJIWARA Katsunori wrote:
> # HG changeset patch
> # User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
> # Date 1365518411 -32400
> # Branch stable
> # Node ID b51b9dfb1fdab9999c04d99f955490de33673cae
> # Parent  e4aff2f0f9968551a9896504bebe0680d629c770
> summary: clear "commonincoming" also if branches are different

These look good, queued for default.

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -5674,6 +5674,7 @@ 
     if opts.get('remote'):
         t = []
         source, branches = hg.parseurl(ui.expandpath('default'))
+        sbranch = branches[0]
         other = hg.peer(repo, {}, source)
         revs, checkout = hg.addbranchrevs(repo, other, branches,
                                           opts.get('rev'))
@@ -5688,11 +5689,13 @@ 
             t.append(_('1 or more incoming'))
 
         dest, branches = hg.parseurl(ui.expandpath('default-push', 'default'))
+        dbranch = branches[0]
         revs, checkout = hg.addbranchrevs(repo, repo, branches, None)
         if source != dest:
             other = hg.peer(repo, {}, dest)
+            ui.debug('comparing with %s\n' % util.hidepassword(dest))
+        if (source != dest or (sbranch is not None and sbranch != dbranch)):
             commoninc = None
-            ui.debug('comparing with %s\n' % util.hidepassword(dest))
         if revs:
             revs = [repo.lookup(rev) for rev in revs]
         repo.ui.pushbuffer()
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
@@ -245,3 +245,60 @@ 
   [255]
 
   $ cd ..
+
+Test handling common incoming revisions between "default" and
+"default-push"
+
+  $ hg -R clone rollback
+  repository tip rolled back to revision 1 (undo pull)
+  working directory now based on revision 0
+
+  $ cd repo
+
+  $ hg update -q -C default
+  $ echo modified >> bar
+  $ hg commit -m "new head to push current default head"
+  $ hg -q push -r ".^1" '../clone'
+
+  $ hg -q outgoing '../clone'
+  2:faba9097cad4
+  4:d515801a8f3d
+
+  $ hg summary --remote --config paths.default='../clone#default' --config paths.default-push='../clone#foo'
+  parent: 4:d515801a8f3d tip
+   new head to push current default head
+  branch: default
+  commit: (clean)
+  update: (current)
+  remote: 1 outgoing
+
+  $ hg summary --remote --config paths.default='../clone#foo' --config paths.default-push='../clone'
+  parent: 4:d515801a8f3d tip
+   new head to push current default head
+  branch: default
+  commit: (clean)
+  update: (current)
+  remote: 2 outgoing
+
+  $ hg summary --remote --config paths.default='../clone' --config paths.default-push='../clone#foo'
+  parent: 4:d515801a8f3d tip
+   new head to push current default head
+  branch: default
+  commit: (clean)
+  update: (current)
+  remote: 1 outgoing
+
+  $ hg clone -q -r 0 . ../another
+  $ hg -q outgoing '../another#default'
+  3:4cd725637392
+  4:d515801a8f3d
+
+  $ hg summary --remote --config paths.default='../another#default' --config paths.default-push='../clone#default'
+  parent: 4:d515801a8f3d tip
+   new head to push current default head
+  branch: default
+  commit: (clean)
+  update: (current)
+  remote: 1 outgoing
+
+  $ cd ..