changeset 622:e9fe5d5e67f7

Add generic repo commands for pull and push
author Matt Mackall <mpm@selenic.com>
date Tue, 05 Jul 2005 17:50:02 -0800
parents 004e811f7706
children 314867960a4a
files mercurial/hg.py
diffstat 1 files changed, 20 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hg.py	Tue Jul 05 17:49:01 2005 -0800
+++ b/mercurial/hg.py	Tue Jul 05 17:50:02 2005 -0800
@@ -995,6 +995,26 @@
         # this is the set of all roots we have to push
         return subset
 
+    def pull(self, remote):
+        lock = self.lock()
+        fetch = self.findincoming(remote)
+        if not fetch:
+            self.ui.status("no changes found\n")
+            return 1
+
+        cg = remote.changegroup(fetch)
+        return self.addchangegroup(cg)
+
+    def push(self, remote):
+        lock = remote.lock()
+        update = self.findoutgoing(remote)
+        if not update:
+            self.ui.status("no changes found\n")
+            return 1
+
+        cg = self.changegroup(update)
+        return remote.addchangegroup(cg)
+
     def changegroup(self, basenodes):
         nodes = self.newer(basenodes)
 
@@ -1062,7 +1082,6 @@
         changesets = files = revisions = 0
 
         source = genread(generator)
-        lock = self.lock()
         tr = self.transaction()
 
         # pull off the changeset group