##// END OF EJS Templates
remotenames: move function to pull remotenames from the remoterepo to core...
Pulkit Goyal -
r35236:5a629109 default
parent child Browse files
Show More
@@ -0,0 +1,43 b''
1 # remotenames.py
2 #
3 # Copyright 2017 Augie Fackler <raf@durin42.com>
4 # Copyright 2017 Sean Farley <sean@farley.io>
5 #
6 # This software may be used and distributed according to the terms of the
7 # GNU General Public License version 2 or any later version.
8
9 from __future__ import absolute_import
10
11 from .node import hex
12
13 def pullremotenames(localrepo, remoterepo):
14 """
15 pulls bookmarks and branches information of the remote repo during a
16 pull or clone operation.
17 localrepo is our local repository
18 remoterepo is the peer instance
19 """
20 remotepath = remoterepo.url()
21 bookmarks = remoterepo.listkeys('bookmarks')
22 # on a push, we don't want to keep obsolete heads since
23 # they won't show up as heads on the next pull, so we
24 # remove them here otherwise we would require the user
25 # to issue a pull to refresh the storage
26 bmap = {}
27 repo = localrepo.unfiltered()
28 for branch, nodes in remoterepo.branchmap().iteritems():
29 bmap[branch] = []
30 for node in nodes:
31 if node in repo and not repo[node].obsolete():
32 bmap[branch].append(hex(node))
33
34 # writing things to ui till the time we import the saving functionality
35 ui = localrepo.ui
36 ui.write("\nRemotenames info\npath: %s\n" % remotepath)
37 ui.write("Bookmarks:\n")
38 for bm, node in bookmarks.iteritems():
39 ui.write("%s: %s\n" % (bm, node))
40 ui.write("Branches:\n")
41 for branch, node in bmap.iteritems():
42 ui.write("%s: %s\n" % (branch, node))
43 ui.write("\n")
@@ -0,0 +1,73 b''
1 Testing the functionality to pull remotenames
2 =============================================
3
4 $ cat >> $HGRCPATH << EOF
5 > [alias]
6 > glog = log -G -T '{rev}:{node|short} {desc}'
7 > EOF
8
9 Making a server repo
10 --------------------
11
12 $ hg init server
13 $ cd server
14 $ for ch in {a..h}; do echo "foo" >> $ch; hg ci -Aqm "Added "$ch; done
15 $ hg glog
16 @ 7:ec2426147f0e Added h
17 |
18 o 6:87d6d6676308 Added g
19 |
20 o 5:825660c69f0c Added f
21 |
22 o 4:aa98ab95a928 Added e
23 |
24 o 3:62615734edd5 Added d
25 |
26 o 2:28ad74487de9 Added c
27 |
28 o 1:29becc82797a Added b
29 |
30 o 0:18d04c59bb5d Added a
31
32 $ hg bookmark -r 3 foo
33 $ hg bookmark -r 6 bar
34 $ hg up 4
35 0 files updated, 0 files merged, 3 files removed, 0 files unresolved
36 $ hg branch wat
37 marked working directory as branch wat
38 (branches are permanent and global, did you want a bookmark?)
39 $ echo foo >> bar
40 $ hg ci -Aqm "added bar"
41
42 Making a client repo
43 --------------------
44
45 $ cd ..
46 $ hg init client
47 $ cd client
48 $ cat >> .hg/hgrc << EOF
49 > [experimental]
50 > remotenames = True
51 > EOF
52
53 $ hg pull ../server/
54 pulling from ../server/
55 requesting all changes
56 adding changesets
57 adding manifests
58 adding file changes
59 added 9 changesets with 9 changes to 9 files (+1 heads)
60 adding remote bookmark bar
61 adding remote bookmark foo
62 new changesets 18d04c59bb5d:3e1487808078
63
64 Remotenames info
65 path: file:$TESTTMP/server
66 Bookmarks:
67 foo: 62615734edd52f06b6fb9c2beb429e4fe30d57b8
68 bar: 87d6d66763085b629e6d7ed56778c79827273022
69 Branches:
70 wat: ['3e1487808078543b0af6d10dadf5d46943578db0']
71 default: ['ec2426147f0e39dbc9cef599b066be6035ce691d']
72
73 (run 'hg heads' to see heads)
@@ -532,6 +532,9 b" coreconfigitem('experimental', 'obsmarke"
532 coreconfigitem('experimental', 'rebase.multidest',
532 coreconfigitem('experimental', 'rebase.multidest',
533 default=False,
533 default=False,
534 )
534 )
535 coreconfigitem('experimental', 'remotenames',
536 default=False,
537 )
535 coreconfigitem('experimental', 'revlogv2',
538 coreconfigitem('experimental', 'revlogv2',
536 default=None,
539 default=None,
537 )
540 )
@@ -27,6 +27,7 b' from . import ('
27 phases,
27 phases,
28 pushkey,
28 pushkey,
29 pycompat,
29 pycompat,
30 remotenames,
30 scmutil,
31 scmutil,
31 sslutil,
32 sslutil,
32 streamclone,
33 streamclone,
@@ -1304,6 +1305,10 b' def pull(repo, remote, heads=None, force'
1304 finally:
1305 finally:
1305 lockmod.release(pullop.trmanager, lock, wlock)
1306 lockmod.release(pullop.trmanager, lock, wlock)
1306
1307
1308 # storing remotenames
1309 if repo.ui.configbool('experimental', 'remotenames'):
1310 remotenames.pullremotenames(repo, remote)
1311
1307 return pullop
1312 return pullop
1308
1313
1309 # list of steps to perform discovery before pull
1314 # list of steps to perform discovery before pull
General Comments 0
You need to be logged in to leave comments. Login now