Add an option to store remote refs as bookmarks
authorGregory Szorc <gps@mozilla.com>
Tue, 15 Oct 2013 19:37:02 -0700
changeset 47 b33779100773eb3bf05347c677c182098cc46e11
parent 46 7ccbb28852e5da83668061f3041467aa1ff30f63
child 48 373b4c93db0fe569d5544367b915f247d1e05e37
push id30
push usergszorc@mozilla.com
push dateWed, 16 Oct 2013 02:37:20 +0000
Add an option to store remote refs as bookmarks
__init__.py
--- a/__init__.py
+++ b/__init__.py
@@ -66,16 +66,20 @@ When pulling from known Gecko repositori
 creates references to branches on the remote. These can be referenced via
 the revision <tree>/<name>. e.g. 'central/default'.
 
 Remote refs are read-only and are updated automatically during repository pull
 and push operations.
 
 This feature is similar to Git remote refs.
 
+If the config bool ``refs_as_bookmarks`` is True, remote references will be
+stored in the repo's bookmarks file. This is useful for hosted unified
+repositories.
+
 Static Analysis
 ===============
 
 This extension provides static analysis to patches. Currently, only Python
 style checking is performed.
 
 To perform style checking for a single patch, run `hg critic`. By default,
 this will analyze the current working directory. If the working directory is
@@ -626,22 +630,32 @@ def reposetup(ui, repo):
                     self._update_remote_refs(remote, tree)
 
             finally:
                 lock.release()
 
             return res
 
         def _update_remote_refs(self, remote, tree):
+            mb = self.ui.configbool('mozext', 'refs_as_bookmarks',
+                default=False)
+
             for branch, nodes in remote.branchmap().items():
                 for node in nodes:
-                    self.remoterefs['%s/%s' % (tree, branch)] = node
+                    ref = '%s/%s' % (tree, branch)
+                    self.remoterefs[ref] = node
+
+                    if mb:
+                        self._bookmarks[ref] = node
 
             self.remoterefs.write()
 
+            if mb:
+                self._bookmarks.write()
+
         def _milestone_changesets(self):
             """Look up Gecko milestone changes.
 
             Returns a mapping of changeset node to milestone text.
             """
             m = {}
 
             for rev in self.file('config/milestone.txt'):