Patchwork [2,of,3] subrepo: add pull --subrepos support to git subrepos

login
register
mail settings
Submitter Angel Ezquerra
Date Feb. 17, 2013, 12:19 p.m.
Message ID <33063dc38f45ef3a707d.1361103557@Angel-PC.localdomain>
Download mbox | patch
Permalink /patch/1021/
State Superseded, archived
Headers show

Comments

Angel Ezquerra - Feb. 17, 2013, 12:19 p.m.
# HG changeset patch
# User Angel Ezquerra <angel.ezquerra@gmail.com>
# Date 1360519814 -3600
# Node ID 33063dc38f45ef3a707ddf95f1a716e370315840
# Parent  abbd26cca35280fb8f784b3f2c02eef71696c47b
subrepo: add pull --subrepos support to git subrepos

Note that I am not a git subrepo user myself so please review this carefully.

Patch

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -1059,19 +1059,22 @@ 
         self._subsource = source
         return _abssource(self)
 
+    def pull(self, source):
+        self._fetch(source, None)
+
     def _fetch(self, source, revision):
         if self._gitmissing():
             source = self._abssource(source)
             self._ui.status(_('cloning subrepo %s from %s\n') %
                             (self._relpath, source))
             self._gitnodir(['clone', source, self._abspath])
-        if self._githavelocally(revision):
+        if revision is not None and self._githavelocally(revision):
             return
         self._ui.status(_('pulling subrepo %s from %s\n') %
                         (self._relpath, self._gitremote('origin')))
         # try only origin: the originally cloned repo
         self._gitcommand(['fetch'])
-        if not self._githavelocally(revision):
+        if revision is not None and not self._githavelocally(revision):
             raise util.Abort(_("revision %s does not exist in subrepo %s\n") %
                                (revision, self._relpath))