71 except SubrepoAbort as ex: |
71 except SubrepoAbort as ex: |
72 # This exception has already been handled |
72 # This exception has already been handled |
73 raise ex |
73 raise ex |
74 except error.Abort as ex: |
74 except error.Abort as ex: |
75 subrepo = subrelpath(self) |
75 subrepo = subrelpath(self) |
76 errormsg = str(ex) + ' ' + _('(in subrepo %s)') % subrepo |
76 errormsg = str(ex) + ' ' + _('(in subrepository "%s")') % subrepo |
77 # avoid handling this exception by raising a SubrepoAbort exception |
77 # avoid handling this exception by raising a SubrepoAbort exception |
78 raise SubrepoAbort(errormsg, hint=ex.hint, subrepo=subrepo, |
78 raise SubrepoAbort(errormsg, hint=ex.hint, subrepo=subrepo, |
79 cause=sys.exc_info()) |
79 cause=sys.exc_info()) |
80 return res |
80 return res |
81 return decoratedmethod |
81 return decoratedmethod |
145 state = {} |
145 state = {} |
146 for path, src in p[''].items(): |
146 for path, src in p[''].items(): |
147 kind = 'hg' |
147 kind = 'hg' |
148 if src.startswith('['): |
148 if src.startswith('['): |
149 if ']' not in src: |
149 if ']' not in src: |
150 raise error.Abort(_('missing ] in subrepo source')) |
150 raise error.Abort(_('missing ] in subrepository source')) |
151 kind, src = src.split(']', 1) |
151 kind, src = src.split(']', 1) |
152 kind = kind[1:] |
152 kind = kind[1:] |
153 src = src.lstrip() # strip any extra whitespace after ']' |
153 src = src.lstrip() # strip any extra whitespace after ']' |
154 |
154 |
155 if not util.url(src).isabs(): |
155 if not util.url(src).isabs(): |
475 of exception. |
475 of exception. |
476 |
476 |
477 This returns None, otherwise. |
477 This returns None, otherwise. |
478 """ |
478 """ |
479 if self.dirty(ignoreupdate=ignoreupdate, missing=missing): |
479 if self.dirty(ignoreupdate=ignoreupdate, missing=missing): |
480 return _("uncommitted changes in subrepository '%s'" |
480 return _('uncommitted changes in subrepository "%s"' |
481 ) % subrelpath(self) |
481 ) % subrelpath(self) |
482 |
482 |
483 def bailifchanged(self, ignoreupdate=False, hint=None): |
483 def bailifchanged(self, ignoreupdate=False, hint=None): |
484 """raise Abort if subrepository is ``dirty()`` |
484 """raise Abort if subrepository is ``dirty()`` |
485 """ |
485 """ |
894 if inrepo: |
894 if inrepo: |
895 urepo = repo.unfiltered() |
895 urepo = repo.unfiltered() |
896 ctx = urepo[revision] |
896 ctx = urepo[revision] |
897 if ctx.hidden(): |
897 if ctx.hidden(): |
898 urepo.ui.warn( |
898 urepo.ui.warn( |
899 _('revision %s in subrepo %s is hidden\n') \ |
899 _('revision %s in subrepository "%s" is hidden\n') \ |
900 % (revision[0:12], self._path)) |
900 % (revision[0:12], self._path)) |
901 repo = urepo |
901 repo = urepo |
902 hg.updaterepo(repo, revision, overwrite) |
902 hg.updaterepo(repo, revision, overwrite) |
903 |
903 |
904 @annotatesubrepoerror |
904 @annotatesubrepoerror |
908 dst = self._repo[state[1]] |
908 dst = self._repo[state[1]] |
909 anc = dst.ancestor(cur) |
909 anc = dst.ancestor(cur) |
910 |
910 |
911 def mergefunc(): |
911 def mergefunc(): |
912 if anc == cur and dst.branch() == cur.branch(): |
912 if anc == cur and dst.branch() == cur.branch(): |
913 self.ui.debug("updating subrepo %s\n" % subrelpath(self)) |
913 self.ui.debug('updating subrepository "%s"\n' |
|
914 % subrelpath(self)) |
914 hg.update(self._repo, state[1]) |
915 hg.update(self._repo, state[1]) |
915 elif anc == dst: |
916 elif anc == dst: |
916 self.ui.debug("skipping subrepo %s\n" % subrelpath(self)) |
917 self.ui.debug('skipping subrepository "%s"\n' |
|
918 % subrelpath(self)) |
917 else: |
919 else: |
918 self.ui.debug("merging subrepo %s\n" % subrelpath(self)) |
920 self.ui.debug('merging subrepository "%s"\n' % subrelpath(self)) |
919 hg.merge(self._repo, state[1], remind=False) |
921 hg.merge(self._repo, state[1], remind=False) |
920 |
922 |
921 wctx = self._repo[None] |
923 wctx = self._repo[None] |
922 if self.dirty(): |
924 if self.dirty(): |
923 if anc != dst: |
925 if anc != dst: |
1553 self.ui.status(_('pulling subrepo %s from %s\n') % |
1555 self.ui.status(_('pulling subrepo %s from %s\n') % |
1554 (self._relpath, self._gitremote('origin'))) |
1556 (self._relpath, self._gitremote('origin'))) |
1555 # try only origin: the originally cloned repo |
1557 # try only origin: the originally cloned repo |
1556 self._gitcommand(['fetch']) |
1558 self._gitcommand(['fetch']) |
1557 if not self._githavelocally(revision): |
1559 if not self._githavelocally(revision): |
1558 raise error.Abort(_("revision %s does not exist in subrepo %s\n") % |
1560 raise error.Abort(_('revision %s does not exist in subrepository ' |
1559 (revision, self._relpath)) |
1561 '"%s"\n') % (revision, self._relpath)) |
1560 |
1562 |
1561 @annotatesubrepoerror |
1563 @annotatesubrepoerror |
1562 def dirty(self, ignoreupdate=False, missing=False): |
1564 def dirty(self, ignoreupdate=False, missing=False): |
1563 if self._gitmissing(): |
1565 if self._gitmissing(): |
1564 return self._state[1] != '' |
1566 return self._state[1] != '' |
1609 self._gitcommand(cmd + args) |
1611 self._gitcommand(cmd + args) |
1610 _sanitize(self.ui, self.wvfs, '.git') |
1612 _sanitize(self.ui, self.wvfs, '.git') |
1611 |
1613 |
1612 def rawcheckout(): |
1614 def rawcheckout(): |
1613 # no branch to checkout, check it out with no branch |
1615 # no branch to checkout, check it out with no branch |
1614 self.ui.warn(_('checking out detached HEAD in subrepo %s\n') % |
1616 self.ui.warn(_('checking out detached HEAD in ' |
1615 self._relpath) |
1617 'subrepository "%s"\n') % self._relpath) |
1616 self.ui.warn(_('check out a git branch if you intend ' |
1618 self.ui.warn(_('check out a git branch if you intend ' |
1617 'to make changes\n')) |
1619 'to make changes\n')) |
1618 checkout(['-q', revision]) |
1620 checkout(['-q', revision]) |
1619 |
1621 |
1620 if revision not in rev2branch: |
1622 if revision not in rev2branch: |
1729 current = self._gitcurrentbranch() |
1731 current = self._gitcurrentbranch() |
1730 if current: |
1732 if current: |
1731 # determine if the current branch is even useful |
1733 # determine if the current branch is even useful |
1732 if not self._gitisancestor(self._state[1], current): |
1734 if not self._gitisancestor(self._state[1], current): |
1733 self.ui.warn(_('unrelated git branch checked out ' |
1735 self.ui.warn(_('unrelated git branch checked out ' |
1734 'in subrepo %s\n') % self._relpath) |
1736 'in subrepository "%s"\n') % self._relpath) |
1735 return False |
1737 return False |
1736 self.ui.status(_('pushing branch %s of subrepo %s\n') % |
1738 self.ui.status(_('pushing branch %s of subrepository "%s"\n') % |
1737 (current.split('/', 2)[2], self._relpath)) |
1739 (current.split('/', 2)[2], self._relpath)) |
1738 ret = self._gitdir(cmd + ['origin', current]) |
1740 ret = self._gitdir(cmd + ['origin', current]) |
1739 return ret[1] == 0 |
1741 return ret[1] == 0 |
1740 else: |
1742 else: |
1741 self.ui.warn(_('no branch checked out in subrepo %s\n' |
1743 self.ui.warn(_('no branch checked out in subrepository "%s"\n' |
1742 'cannot push revision %s\n') % |
1744 'cannot push revision %s\n') % |
1743 (self._relpath, self._state[1])) |
1745 (self._relpath, self._state[1])) |
1744 return False |
1746 return False |
1745 |
1747 |
1746 @annotatesubrepoerror |
1748 @annotatesubrepoerror |