##// END OF EJS Templates
add -f/--force to pull, incoming, outgoing, to work on unrelated repo....
Vadim Gelfer -
r1959:d53a18f5 default
parent child Browse files
Show More
@@ -862,7 +862,7 b' def bundle(ui, repo, fname, dest="defaul'
862 """
862 """
863 dest = ui.expandpath(dest)
863 dest = ui.expandpath(dest)
864 other = hg.repository(ui, dest)
864 other = hg.repository(ui, dest)
865 o = repo.findoutgoing(other)
865 o = repo.findoutgoing(other, force=opts['force'])
866 cg = repo.changegroup(o, 'bundle')
866 cg = repo.changegroup(o, 'bundle')
867 write_bundle(cg, fname)
867 write_bundle(cg, fname)
868
868
@@ -1766,7 +1766,7 b' def incoming(ui, repo, source="default",'
1766 """
1766 """
1767 source = ui.expandpath(source)
1767 source = ui.expandpath(source)
1768 other = hg.repository(ui, source)
1768 other = hg.repository(ui, source)
1769 incoming = repo.findincoming(other)
1769 incoming = repo.findincoming(other, force=opts["force"])
1770 if not incoming:
1770 if not incoming:
1771 return
1771 return
1772
1772
@@ -1978,7 +1978,7 b' def outgoing(ui, repo, dest="default-pus'
1978 """
1978 """
1979 dest = ui.expandpath(dest)
1979 dest = ui.expandpath(dest)
1980 other = hg.repository(ui, dest)
1980 other = hg.repository(ui, dest)
1981 o = repo.findoutgoing(other)
1981 o = repo.findoutgoing(other, force=opts['force'])
1982 o = repo.changelog.nodesbetween(o)[0]
1982 o = repo.changelog.nodesbetween(o)[0]
1983 if opts['newest_first']:
1983 if opts['newest_first']:
1984 o.reverse()
1984 o.reverse()
@@ -2066,7 +2066,7 b' def pull(ui, repo, source="default", **o'
2066 raise util.Abort(_("pull -r doesn't work for remote repositories yet"))
2066 raise util.Abort(_("pull -r doesn't work for remote repositories yet"))
2067 elif opts['rev']:
2067 elif opts['rev']:
2068 revs = [other.lookup(rev) for rev in opts['rev']]
2068 revs = [other.lookup(rev) for rev in opts['rev']]
2069 r = repo.pull(other, heads=revs)
2069 r = repo.pull(other, heads=revs, force=opts['force'])
2070 if not r:
2070 if not r:
2071 if opts['update']:
2071 if opts['update']:
2072 return update(ui, repo)
2072 return update(ui, repo)
@@ -2646,7 +2646,8 b' table = {'
2646 _('hg annotate [-r REV] [-a] [-u] [-d] [-n] [-c] FILE...')),
2646 _('hg annotate [-r REV] [-a] [-u] [-d] [-n] [-c] FILE...')),
2647 "bundle":
2647 "bundle":
2648 (bundle,
2648 (bundle,
2649 [],
2649 [('f', 'force', None,
2650 _('run even when remote repository is unrelated'))],
2650 _('hg bundle FILE DEST')),
2651 _('hg bundle FILE DEST')),
2651 "cat":
2652 "cat":
2652 (cat,
2653 (cat,
@@ -2757,6 +2758,8 b' table = {'
2757 _('hg import [-p NUM] [-b BASE] [-f] PATCH...')),
2758 _('hg import [-p NUM] [-b BASE] [-f] PATCH...')),
2758 "incoming|in": (incoming,
2759 "incoming|in": (incoming,
2759 [('M', 'no-merges', None, _('do not show merges')),
2760 [('M', 'no-merges', None, _('do not show merges')),
2761 ('f', 'force', None,
2762 _('run even when remote repository is unrelated')),
2760 ('', 'style', '', _('display using template map file')),
2763 ('', 'style', '', _('display using template map file')),
2761 ('n', 'newest-first', None, _('show newest record first')),
2764 ('n', 'newest-first', None, _('show newest record first')),
2762 ('', 'bundle', '', _('file to store the bundles into')),
2765 ('', 'bundle', '', _('file to store the bundles into')),
@@ -2791,6 +2794,8 b' table = {'
2791 "manifest": (manifest, [], _('hg manifest [REV]')),
2794 "manifest": (manifest, [], _('hg manifest [REV]')),
2792 "outgoing|out": (outgoing,
2795 "outgoing|out": (outgoing,
2793 [('M', 'no-merges', None, _('do not show merges')),
2796 [('M', 'no-merges', None, _('do not show merges')),
2797 ('f', 'force', None,
2798 _('run even when remote repository is unrelated')),
2794 ('p', 'patch', None, _('show patch')),
2799 ('p', 'patch', None, _('show patch')),
2795 ('', 'style', '', _('display using template map file')),
2800 ('', 'style', '', _('display using template map file')),
2796 ('n', 'newest-first', None, _('show newest record first')),
2801 ('n', 'newest-first', None, _('show newest record first')),
@@ -2808,6 +2813,8 b' table = {'
2808 [('u', 'update', None,
2813 [('u', 'update', None,
2809 _('update the working directory to tip after pull')),
2814 _('update the working directory to tip after pull')),
2810 ('e', 'ssh', '', _('specify ssh command to use')),
2815 ('e', 'ssh', '', _('specify ssh command to use')),
2816 ('f', 'force', None,
2817 _('run even when remote repository is unrelated')),
2811 ('r', 'rev', [], _('a specific revision you would like to pull')),
2818 ('r', 'rev', [], _('a specific revision you would like to pull')),
2812 ('', 'remotecmd', '',
2819 ('', 'remotecmd', '',
2813 _('specify hg command to run on the remote side'))],
2820 _('specify hg command to run on the remote side'))],
@@ -785,7 +785,7 b' class localrepository(object):'
785
785
786 return r
786 return r
787
787
788 def findincoming(self, remote, base=None, heads=None):
788 def findincoming(self, remote, base=None, heads=None, force=False):
789 m = self.changelog.nodemap
789 m = self.changelog.nodemap
790 search = []
790 search = []
791 fetch = {}
791 fetch = {}
@@ -898,7 +898,10 b' class localrepository(object):'
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")
@@ -907,10 +910,10 b' class localrepository(object):'
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")
@@ -937,7 +940,7 b' class localrepository(object):'
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
@@ -945,7 +948,7 b' class localrepository(object):'
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"))
@@ -962,7 +965,7 b' class localrepository(object):'
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"))
General Comments 0
You need to be logged in to leave comments. Login now