changeset 1961:eff46e2c9d67

merge with crew.
author Vadim Gelfer <vadim.gelfer@gmail.com>
date Tue, 14 Mar 2006 23:01:11 -0800
parents dac4bd67f6c5 (diff) f92cf4a8cedd (current diff)
children 2a676ad52c22
files
diffstat 4 files changed, 27 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Wed Mar 15 07:15:13 2006 +0100
+++ b/mercurial/commands.py	Tue Mar 14 23:01:11 2006 -0800
@@ -862,7 +862,7 @@
     """
     dest = ui.expandpath(dest)
     other = hg.repository(ui, dest)
-    o = repo.findoutgoing(other)
+    o = repo.findoutgoing(other, force=opts['force'])
     cg = repo.changegroup(o, 'bundle')
     write_bundle(cg, fname)
 
@@ -1766,7 +1766,7 @@
     """
     source = ui.expandpath(source)
     other = hg.repository(ui, source)
-    incoming = repo.findincoming(other)
+    incoming = repo.findincoming(other, force=opts["force"])
     if not incoming:
         return
 
@@ -1978,7 +1978,7 @@
     """
     dest = ui.expandpath(dest)
     other = hg.repository(ui, dest)
-    o = repo.findoutgoing(other)
+    o = repo.findoutgoing(other, force=opts['force'])
     o = repo.changelog.nodesbetween(o)[0]
     if opts['newest_first']:
         o.reverse()
@@ -2066,7 +2066,7 @@
         raise util.Abort(_("pull -r doesn't work for remote repositories yet"))
     elif opts['rev']:
         revs = [other.lookup(rev) for rev in opts['rev']]
-    r = repo.pull(other, heads=revs)
+    r = repo.pull(other, heads=revs, force=opts['force'])
     if not r:
         if opts['update']:
             return update(ui, repo)
@@ -2646,7 +2646,8 @@
          _('hg annotate [-r REV] [-a] [-u] [-d] [-n] [-c] FILE...')),
     "bundle":
         (bundle,
-         [],
+         [('f', 'force', None,
+           _('run even when remote repository is unrelated'))],
          _('hg bundle FILE DEST')),
     "cat":
         (cat,
@@ -2757,6 +2758,8 @@
          _('hg import [-p NUM] [-b BASE] [-f] PATCH...')),
     "incoming|in": (incoming,
          [('M', 'no-merges', None, _('do not show merges')),
+          ('f', 'force', None,
+           _('run even when remote repository is unrelated')),
           ('', 'style', '', _('display using template map file')),
           ('n', 'newest-first', None, _('show newest record first')),
           ('', 'bundle', '', _('file to store the bundles into')),
@@ -2791,6 +2794,8 @@
     "manifest": (manifest, [], _('hg manifest [REV]')),
     "outgoing|out": (outgoing,
          [('M', 'no-merges', None, _('do not show merges')),
+          ('f', 'force', None,
+           _('run even when remote repository is unrelated')),
           ('p', 'patch', None, _('show patch')),
           ('', 'style', '', _('display using template map file')),
           ('n', 'newest-first', None, _('show newest record first')),
@@ -2808,6 +2813,8 @@
          [('u', 'update', None,
            _('update the working directory to tip after pull')),
           ('e', 'ssh', '', _('specify ssh command to use')),
+          ('f', 'force', None,
+           _('run even when remote repository is unrelated')),
           ('r', 'rev', [], _('a specific revision you would like to pull')),
           ('', 'remotecmd', '',
            _('specify hg command to run on the remote side'))],
--- a/mercurial/localrepo.py	Wed Mar 15 07:15:13 2006 +0100
+++ b/mercurial/localrepo.py	Tue Mar 14 23:01:11 2006 -0800
@@ -785,7 +785,7 @@
 
         return r
 
-    def findincoming(self, remote, base=None, heads=None):
+    def findincoming(self, remote, base=None, heads=None, force=False):
         m = self.changelog.nodemap
         search = []
         fetch = {}
@@ -898,7 +898,10 @@
                 raise repo.RepoError(_("already have changeset ") + short(f[:4]))
 
         if base.keys() == [nullid]:
-            self.ui.warn(_("warning: pulling from an unrelated repository!\n"))
+            if force:
+                self.ui.warn(_("warning: repository is unrelated\n"))
+            else:
+                raise util.Abort(_("repository is unrelated"))
 
         self.ui.note(_("found new changesets starting at ") +
                      " ".join([short(f) for f in fetch]) + "\n")
@@ -907,10 +910,10 @@
 
         return fetch.keys()
 
-    def findoutgoing(self, remote, base=None, heads=None):
+    def findoutgoing(self, remote, base=None, heads=None, force=False):
         if base == None:
             base = {}
-            self.findincoming(remote, base, heads)
+            self.findincoming(remote, base, heads, force=force)
 
         self.ui.debug(_("common changesets up to ")
                       + " ".join(map(short, base.keys())) + "\n")
@@ -937,7 +940,7 @@
         # this is the set of all roots we have to push
         return subset
 
-    def pull(self, remote, heads=None):
+    def pull(self, remote, heads=None, force=False):
         l = self.lock()
 
         # if we have an empty repo, fetch everything
@@ -945,7 +948,7 @@
             self.ui.status(_("requesting all changes\n"))
             fetch = [nullid]
         else:
-            fetch = self.findincoming(remote)
+            fetch = self.findincoming(remote, force=force)
 
         if not fetch:
             self.ui.status(_("no changes found\n"))
@@ -962,7 +965,7 @@
 
         base = {}
         heads = remote.heads()
-        inc = self.findincoming(remote, base, heads)
+        inc = self.findincoming(remote, base, heads, force=force)
         if not force and inc:
             self.ui.warn(_("abort: unsynced remote changes!\n"))
             self.ui.status(_("(did you forget to sync? use push -f to force)\n"))
--- a/tests/test-unrelated-pull	Wed Mar 15 07:15:13 2006 +0100
+++ b/tests/test-unrelated-pull	Tue Mar 14 23:01:11 2006 -0800
@@ -16,4 +16,5 @@
 hg commit -m "b" -u b -d "1000000 0"
 
 hg pull ../a
+hg pull -f ../a
 hg heads
--- a/tests/test-unrelated-pull.out	Wed Mar 15 07:15:13 2006 +0100
+++ b/tests/test-unrelated-pull.out	Tue Mar 14 23:01:11 2006 -0800
@@ -1,6 +1,9 @@
 pulling from ../a
 searching for changes
-warning: pulling from an unrelated repository!
+abort: repository is unrelated
+pulling from ../a
+searching for changes
+warning: repository is unrelated
 adding changesets
 adding manifests
 adding file changes