# HG changeset patch # User FUJIWARA Katsunori # Date 2013-04-09 14:40:11 # Node ID 4cf09a1bf5b2c88b753a2fcc6ad11fdeb3d99889 # Parent 160d8416e286862acb9a97e2c5f1335990d2e4be 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. diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -5464,6 +5464,7 @@ def summary(ui, repo, **opts): 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')) @@ -5478,11 +5479,13 @@ def summary(ui, repo, **opts): 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 @@ Test handling of invalid urls [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 ..