Add generic repo commands for pull and push
authorMatt Mackall <mpm@selenic.com>
Tue, 05 Jul 2005 17:50:02 -0800
changeset 622 e9fe5d5e67f7
parent 621 004e811f7706
child 623 314867960a4a
Add generic repo commands for pull and push
mercurial/hg.py
--- 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