comparison mercurial/commands.py @ 14073:72c84f24b420

discovery: drop findoutgoing and simplify findcommonincoming's api This is a long desired cleanup and paves the way for new discovery. To specify subsets for bundling changes, all code should use the heads of the desired subset ("heads") and the heads of the common subset ("common") to be excluded from the bundled set. These can be used revlog.findmissing instead of revlog.nodesbetween. This fixes an actual bug exposed by the change in test-bundle-r.t where we try to bundle a changeset while specifying that said changeset is to be assumed already present in the target. This used to still bundle the changeset. It no longer does. This is similar to the bugs fixed by the recent switch to heads/common for incoming/pull.
author Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
date Sat, 30 Apr 2011 17:21:37 +0200
parents e4bfb9c337f3
children 924c82157d46
comparison
equal deleted inserted replaced
14072:2e4d79dcc0a0 14073:72c84f24b420
694 base = cmdutil.revrange(repo, opts.get('base')) 694 base = cmdutil.revrange(repo, opts.get('base'))
695 if base: 695 if base:
696 if dest: 696 if dest:
697 raise util.Abort(_("--base is incompatible with specifying " 697 raise util.Abort(_("--base is incompatible with specifying "
698 "a destination")) 698 "a destination"))
699 base = [repo.lookup(rev) for rev in base] 699 common = [repo.lookup(rev) for rev in base]
700 # create the right base
701 # XXX: nodesbetween / changegroup* should be "fixed" instead
702 o = []
703 has = set((nullid,))
704 for n in base:
705 has.update(repo.changelog.reachable(n))
706 if revs:
707 revs = [repo.lookup(rev) for rev in revs]
708 visit = revs[:]
709 has.difference_update(visit)
710 else:
711 visit = repo.changelog.heads()
712 seen = {}
713 while visit:
714 n = visit.pop(0)
715 parents = [p for p in repo.changelog.parents(n) if p not in has]
716 if len(parents) == 0:
717 if n not in has:
718 o.append(n)
719 else:
720 for p in parents:
721 if p not in seen:
722 seen[p] = 1
723 visit.append(p)
724 else: 700 else:
725 dest = ui.expandpath(dest or 'default-push', dest or 'default') 701 dest = ui.expandpath(dest or 'default-push', dest or 'default')
726 dest, branches = hg.parseurl(dest, opts.get('branch')) 702 dest, branches = hg.parseurl(dest, opts.get('branch'))
727 other = hg.repository(hg.remoteui(repo, opts), dest) 703 other = hg.repository(hg.remoteui(repo, opts), dest)
728 revs, checkout = hg.addbranchrevs(repo, other, branches, revs) 704 revs, checkout = hg.addbranchrevs(repo, other, branches, revs)
729 if revs: 705 inc = discovery.findcommonincoming(repo, other, force=opts.get('force'))
730 revs = [repo.lookup(rev) for rev in revs] 706 common, _anyinc, _heads = inc
731 o = discovery.findoutgoing(repo, other, force=opts.get('force')) 707
732 708 nodes = revs and map(repo.lookup, revs) or revs
733 if not o: 709 cg = repo.getbundle('bundle', common=common, heads=nodes)
710 if not cg:
734 ui.status(_("no changes found\n")) 711 ui.status(_("no changes found\n"))
735 return 1 712 return 1
736
737 if revs:
738 cg = repo.changegroupsubset(o, revs, 'bundle')
739 else:
740 cg = repo.changegroup(o, 'bundle')
741 713
742 bundletype = opts.get('type', 'bzip2').lower() 714 bundletype = opts.get('type', 'bzip2').lower()
743 btypes = {'none': 'HG10UN', 'bzip2': 'HG10BZ', 'gzip': 'HG10GZ'} 715 btypes = {'none': 'HG10UN', 'bzip2': 'HG10BZ', 'gzip': 'HG10GZ'}
744 bundletype = btypes.get(bundletype) 716 bundletype = btypes.get(bundletype)
745 if bundletype not in changegroup.bundletypes: 717 if bundletype not in changegroup.bundletypes:
3957 dest, branches = hg.parseurl(ui.expandpath('default-push', 'default')) 3929 dest, branches = hg.parseurl(ui.expandpath('default-push', 'default'))
3958 revs, checkout = hg.addbranchrevs(repo, repo, branches, None) 3930 revs, checkout = hg.addbranchrevs(repo, repo, branches, None)
3959 other = hg.repository(hg.remoteui(repo, {}), dest) 3931 other = hg.repository(hg.remoteui(repo, {}), dest)
3960 ui.debug('comparing with %s\n' % url.hidepassword(dest)) 3932 ui.debug('comparing with %s\n' % url.hidepassword(dest))
3961 repo.ui.pushbuffer() 3933 repo.ui.pushbuffer()
3962 o = discovery.findoutgoing(repo, other) 3934 common, _anyinc, _heads = discovery.findcommonincoming(repo, other)
3963 repo.ui.popbuffer() 3935 repo.ui.popbuffer()
3964 o = repo.changelog.nodesbetween(o, None)[0] 3936 o = repo.changelog.findmissing(common=common)
3965 if o: 3937 if o:
3966 t.append(_('%d outgoing') % len(o)) 3938 t.append(_('%d outgoing') % len(o))
3967 if 'bookmarks' in other.listkeys('namespaces'): 3939 if 'bookmarks' in other.listkeys('namespaces'):
3968 lmarks = repo.listkeys('bookmarks') 3940 lmarks = repo.listkeys('bookmarks')
3969 rmarks = other.listkeys('bookmarks') 3941 rmarks = other.listkeys('bookmarks')