896 for f in fetch.keys(): |
896 for f in fetch.keys(): |
897 if f in m: |
897 if f in m: |
898 raise repo.RepoError(_("already have changeset ") + short(f[:4])) |
898 raise repo.RepoError(_("already have changeset ") + short(f[:4])) |
899 |
899 |
900 if base.keys() == [nullid]: |
900 if base.keys() == [nullid]: |
901 self.ui.warn(_("warning: pulling from an unrelated repository!\n")) |
901 if force: |
|
902 self.ui.warn(_("warning: repository is unrelated\n")) |
|
903 else: |
|
904 raise util.Abort(_("repository is unrelated")) |
902 |
905 |
903 self.ui.note(_("found new changesets starting at ") + |
906 self.ui.note(_("found new changesets starting at ") + |
904 " ".join([short(f) for f in fetch]) + "\n") |
907 " ".join([short(f) for f in fetch]) + "\n") |
905 |
908 |
906 self.ui.debug(_("%d total queries\n") % reqcnt) |
909 self.ui.debug(_("%d total queries\n") % reqcnt) |
907 |
910 |
908 return fetch.keys() |
911 return fetch.keys() |
909 |
912 |
910 def findoutgoing(self, remote, base=None, heads=None): |
913 def findoutgoing(self, remote, base=None, heads=None, force=False): |
911 if base == None: |
914 if base == None: |
912 base = {} |
915 base = {} |
913 self.findincoming(remote, base, heads) |
916 self.findincoming(remote, base, heads, force=force) |
914 |
917 |
915 self.ui.debug(_("common changesets up to ") |
918 self.ui.debug(_("common changesets up to ") |
916 + " ".join(map(short, base.keys())) + "\n") |
919 + " ".join(map(short, base.keys())) + "\n") |
917 |
920 |
918 remain = dict.fromkeys(self.changelog.nodemap) |
921 remain = dict.fromkeys(self.changelog.nodemap) |
935 subset.append(n) |
938 subset.append(n) |
936 |
939 |
937 # this is the set of all roots we have to push |
940 # this is the set of all roots we have to push |
938 return subset |
941 return subset |
939 |
942 |
940 def pull(self, remote, heads=None): |
943 def pull(self, remote, heads=None, force=False): |
941 l = self.lock() |
944 l = self.lock() |
942 |
945 |
943 # if we have an empty repo, fetch everything |
946 # if we have an empty repo, fetch everything |
944 if self.changelog.tip() == nullid: |
947 if self.changelog.tip() == nullid: |
945 self.ui.status(_("requesting all changes\n")) |
948 self.ui.status(_("requesting all changes\n")) |
946 fetch = [nullid] |
949 fetch = [nullid] |
947 else: |
950 else: |
948 fetch = self.findincoming(remote) |
951 fetch = self.findincoming(remote, force=force) |
949 |
952 |
950 if not fetch: |
953 if not fetch: |
951 self.ui.status(_("no changes found\n")) |
954 self.ui.status(_("no changes found\n")) |
952 return 1 |
955 return 1 |
953 |
956 |
960 def push(self, remote, force=False, revs=None): |
963 def push(self, remote, force=False, revs=None): |
961 lock = remote.lock() |
964 lock = remote.lock() |
962 |
965 |
963 base = {} |
966 base = {} |
964 heads = remote.heads() |
967 heads = remote.heads() |
965 inc = self.findincoming(remote, base, heads) |
968 inc = self.findincoming(remote, base, heads, force=force) |
966 if not force and inc: |
969 if not force and inc: |
967 self.ui.warn(_("abort: unsynced remote changes!\n")) |
970 self.ui.warn(_("abort: unsynced remote changes!\n")) |
968 self.ui.status(_("(did you forget to sync? use push -f to force)\n")) |
971 self.ui.status(_("(did you forget to sync? use push -f to force)\n")) |
969 return 1 |
972 return 1 |
970 |
973 |