Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/commands.py @ 1959:d53a18f592be
add -f/--force to pull, incoming, outgoing, to work on unrelated repo.
before this, push would not push from e.g. "hg" repo to "kernel" repo
but other commands worked. this was bad idea, could merge unrelated
projects by accident. i did this tonight.
now, all commands still work with unrelated repo but need
--force/-f. abort is default. this is safer.
author | Vadim Gelfer <vadim.gelfer@gmail.com> |
---|---|
date | Tue, 14 Mar 2006 22:58:14 -0800 |
parents | ebe273a16048 |
children | 62aa1b90414f |
comparison
equal
deleted
inserted
replaced
1954:34d0e2e559ff | 1959:d53a18f592be |
---|---|
860 Unlike import/export, this exactly preserves all changeset | 860 Unlike import/export, this exactly preserves all changeset |
861 contents including permissions, rename data, and revision history. | 861 contents including permissions, rename data, and revision history. |
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 |
869 def cat(ui, repo, file1, *pats, **opts): | 869 def cat(ui, repo, file1, *pats, **opts): |
870 """output the latest or given revisions of files | 870 """output the latest or given revisions of files |
1764 For remote repository, using --bundle avoids downloading the changesets | 1764 For remote repository, using --bundle avoids downloading the changesets |
1765 twice if the incoming is followed by a pull. | 1765 twice if the incoming is followed by a pull. |
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 |
1773 cleanup = None | 1773 cleanup = None |
1774 if not other.local() or opts["bundle"]: | 1774 if not other.local() or opts["bundle"]: |
1976 | 1976 |
1977 See pull for valid source format details. | 1977 See pull for valid source format details. |
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() |
1985 displayer = show_changeset(ui, repo, opts) | 1985 displayer = show_changeset(ui, repo, opts) |
1986 for n in o: | 1986 for n in o: |
2064 revs = None | 2064 revs = None |
2065 if opts['rev'] and not other.local(): | 2065 if opts['rev'] and not other.local(): |
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) |
2073 else: | 2073 else: |
2074 ui.status(_("(run 'hg update' to get a working copy)\n")) | 2074 ui.status(_("(run 'hg update' to get a working copy)\n")) |
2644 ('I', 'include', [], _('include names matching the given patterns')), | 2644 ('I', 'include', [], _('include names matching the given patterns')), |
2645 ('X', 'exclude', [], _('exclude names matching the given patterns'))], | 2645 ('X', 'exclude', [], _('exclude names matching the given patterns'))], |
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, |
2653 [('o', 'output', '', _('print output to file with formatted name')), | 2654 [('o', 'output', '', _('print output to file with formatted name')), |
2654 ('r', 'rev', '', _('print the given revision')), | 2655 ('r', 'rev', '', _('print the given revision')), |
2755 ('f', 'force', None, | 2756 ('f', 'force', None, |
2756 _('skip check for outstanding uncommitted changes'))], | 2757 _('skip check for outstanding uncommitted changes'))], |
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')), |
2763 ('p', 'patch', None, _('show patch')), | 2766 ('p', 'patch', None, _('show patch')), |
2764 ('', 'template', '', _('display with template'))], | 2767 ('', 'template', '', _('display with template'))], |
2789 ('X', 'exclude', [], _('exclude names matching the given patterns'))], | 2792 ('X', 'exclude', [], _('exclude names matching the given patterns'))], |
2790 _('hg log [OPTION]... [FILE]')), | 2793 _('hg log [OPTION]... [FILE]')), |
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')), |
2797 ('', 'template', '', _('display with template'))], | 2802 ('', 'template', '', _('display with template'))], |
2798 _('hg outgoing [-M] [-p] [-n] [DEST]')), | 2803 _('hg outgoing [-M] [-p] [-n] [DEST]')), |
2806 "^pull": | 2811 "^pull": |
2807 (pull, | 2812 (pull, |
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'))], |
2814 _('hg pull [-u] [-e FILE] [-r REV]... [--remotecmd FILE] [SOURCE]')), | 2821 _('hg pull [-u] [-e FILE] [-r REV]... [--remotecmd FILE] [SOURCE]')), |
2815 "^push": | 2822 "^push": |