# HG changeset patch # User Thomas Arendsen Hein # Date 1145690367 -7200 # Node ID 366e6328d10eabd5689ea19ef08c8b3a90b236e0 # Parent fd77b7ee4aaca7681f228f08fb4465c3a4734b7c# Parent 2f3e644decd74b01fc772fac663c9997634bb4f7 Merge with upstream diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -831,13 +831,18 @@ class localrepository(object): if base == None: base = {} + if not heads: + heads = remote.heads() + + if self.changelog.tip() == nullid: + if heads != [nullid]: + return [nullid] + return [] + # assume we're closer to the tip than the root # and start by examining the heads self.ui.status(_("searching for changes\n")) - if not heads: - heads = remote.heads() - unknown = [] for h in heads: if h not in m: @@ -998,12 +1003,9 @@ class localrepository(object): def pull(self, remote, heads=None, force=False): l = self.lock() - # if we have an empty repo, fetch everything - if self.changelog.tip() == nullid: + fetch = self.findincoming(remote, force=force) + if fetch == [nullid]: self.ui.status(_("requesting all changes\n")) - fetch = [nullid] - else: - fetch = self.findincoming(remote, force=force) if not fetch: self.ui.status(_("no changes found\n")) @@ -1037,14 +1039,10 @@ class localrepository(object): self.ui.status(_("no changes found\n")) return 1 elif not force: - if revs is not None: - updated_heads = {} - for base in msng_cl: - for parent in self.changelog.parents(base): - if parent in remote_heads: - updated_heads[parent] = True - updated_heads = updated_heads.keys() - if len(updated_heads) < len(heads): + # FIXME we don't properly detect creation of new heads + # in the push -r case, assume the user knows what he's doing + if not revs and len(remote_heads) < len(heads) \ + and remote_heads != [nullid]: self.ui.warn(_("abort: push creates new remote branches!\n")) self.ui.status(_("(did you forget to merge?" " use push -f to force)\n")) @@ -1386,7 +1384,9 @@ class localrepository(object): yield chnk yield changegroup.closechunk() - self.hook('outgoing', node=hex(nodes[0]), source=source) + + if nodes: + self.hook('outgoing', node=hex(nodes[0]), source=source) return util.chunkbuffer(gengroup()) diff --git a/tests/test-bad-pull.out b/tests/test-bad-pull.out --- a/tests/test-bad-pull.out +++ b/tests/test-bad-pull.out @@ -1,7 +1,5 @@ -requesting all changes abort: error: Connection refused 255 copy: No such file or directory -requesting all changes abort: HTTP Error 404: File not found 255 diff --git a/tests/test-clone-failure.out b/tests/test-clone-failure.out --- a/tests/test-clone-failure.out +++ b/tests/test-clone-failure.out @@ -1,6 +1,5 @@ abort: repository a not found! 255 -requesting all changes abort: error: Connection refused 255 abort: repository a not found! diff --git a/tests/test-push-warn.out b/tests/test-push-warn.out --- a/tests/test-push-warn.out +++ b/tests/test-push-warn.out @@ -30,9 +30,13 @@ searching for changes no changes found pushing to ../c searching for changes -abort: push creates new remote branches! -(did you forget to merge? use push -f to force) +adding changesets +adding manifests +adding file changes +added 2 changesets with 2 changes to 1 files (+2 heads) pushing to ../c searching for changes -abort: push creates new remote branches! -(did you forget to merge? use push -f to force) +adding changesets +adding manifests +adding file changes +added 1 changesets with 1 changes to 1 files