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

login
register
mail settings
Submitter Angel Ezquerra
Date Nov. 23, 2013, 8:28 p.m.
Message ID <1a56126a49ffe082e850.1385238481@Angel-PC.localdomain>
Download mbox | patch
Permalink /patch/3113/
State Superseded
Headers show

Comments

Angel Ezquerra - Nov. 23, 2013, 8:28 p.m.
# HG changeset patch
# User Angel Ezquerra <angel.ezquerra@gmail.com>
# Date 1360519814 -3600
#      Sun Feb 10 19:10:14 2013 +0100
# Node ID 1a56126a49ffe082e8505dbdebc9bceed5d829de
# Parent  ecd1ca99f1b3e4d0f6ea8abd606990ef24667779
subrepo: add pull --subrev support to git subrepos

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

Patch

# HG changeset patch
# User Angel Ezquerra <angel.ezquerra@gmail.com>
# Date 1360519814 -3600
#      Sun Feb 10 19:10:14 2013 +0100
# Node ID 1a56126a49ffe082e8505dbdebc9bceed5d829de
# Parent  ecd1ca99f1b3e4d0f6ea8abd606990ef24667779
subrepo: add pull --subrev support to git subrepos

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

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -1204,19 +1204,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))