[PATCH 3 of 3 hglib] client: add bookmarks support to incoming and outgoing
Idan Kamara
idankk86 at gmail.com
Thu Aug 11 14:59:38 CDT 2011
# HG changeset patch
# User Idan Kamara <idankk86 at gmail.com>
# Date 1313092745 -10800
# Node ID 39cf14a0934225938ff10b0e655bd93872ef6ff3
# Parent 01b66cec19b88510ba24e9f4437f9cc10b7b0101
client: add bookmarks support to incoming and outgoing
diff -r 01b66cec19b8 -r 39cf14a09342 hglib/client.py
--- a/hglib/client.py Thu Aug 11 22:58:38 2011 +0300
+++ b/hglib/client.py Thu Aug 11 22:59:05 2011 +0300
@@ -308,6 +308,12 @@
def incoming(self, revrange=None, path=None, force=False, newest=False,
bundle=None, bookmarks=False, branch=None, limit=None,
nomerges=False, subrepos=False):
+ """
+ Return new changesets found in the specified path or the default pull
+ location.
+
+ When bookmarks=True, return a list of (name, node) of incoming bookmarks.
+ """
args = cmdbuilder('incoming',
path,
template=templates.changeset, r=revrange,
@@ -322,8 +328,15 @@
if not out:
return []
- out = util.eatlines(out, 2).split('\0')[:-1]
- return self._parserevs(out)
+ out = util.eatlines(out, 2)
+ if bookmarks:
+ bms = []
+ for line in out.splitlines():
+ bms.append(tuple(line.split()))
+ return bms
+ else:
+ out = out.split('\0')[:-1]
+ return self._parserevs(out)
def log(self, revrange=None, files=[], follow=False, followfirst=False,
date=None, copies=False, keyword=None, removed=False, onlymerges=False,
@@ -343,6 +356,13 @@
def outgoing(self, revrange=None, path=None, force=False, newest=False,
bookmarks=False, branch=None, limit=None, nomerges=False,
subrepos=False):
+ """
+ Return changesets not found in the specified path or the default push
+ location.
+
+ When bookmarks=True, return a list of (name, node) of bookmarks that will
+ be pushed.
+ """
args = cmdbuilder('outgoing',
path,
template=templates.changeset, r=revrange,
@@ -357,8 +377,15 @@
if not out:
return []
- out = util.eatlines(out, 2).split('\0')[:-1]
- return self._parserevs(out)
+ out = util.eatlines(out, 2)
+ if bookmarks:
+ bms = []
+ for line in out.splitlines():
+ bms.append(tuple(line.split()))
+ return bms
+ else:
+ out = out.split('\0')[:-1]
+ return self._parserevs(out)
def parents(self, rev=None, file=None):
args = cmdbuilder('parents', file, template=templates.changeset, r=rev)
diff -r 01b66cec19b8 -r 39cf14a09342 tests/test-outgoing-incoming.py
--- a/tests/test-outgoing-incoming.py Thu Aug 11 22:58:38 2011 +0300
+++ b/tests/test-outgoing-incoming.py Thu Aug 11 22:59:05 2011 +0300
@@ -32,3 +32,20 @@
self.assertEquals(out[0].node, node)
self.assertEquals(out, other.incoming())
+
+ def test_bookmarks(self):
+ self.append('a', 'a')
+ self.client.commit('first', addremove=True)
+ self.append('a', 'a')
+ self.client.commit('second')
+
+ self.client.clone(dest='other')
+ other = hglib.open('other')
+
+ self.client.bookmark('bm1', 1)
+
+ self.assertEquals(other.incoming(bookmarks=True),
+ [('bm1', self.client.tip().node[:12])])
+
+ self.assertEquals(self.client.outgoing(path='other', bookmarks=True),
+ [('bm1', self.client.tip().node[:12])])
More information about the Mercurial-devel
mailing list