1846 status = self.status(match=match, clean=force) |
1846 status = self.status(match=match, clean=force) |
1847 if force: |
1847 if force: |
1848 status.modified.extend(status.clean) # mq may commit clean files |
1848 status.modified.extend(status.clean) # mq may commit clean files |
1849 |
1849 |
1850 # check subrepos |
1850 # check subrepos |
1851 subs = [] |
1851 subs, commitsubs, newstate = subrepo.precommit( |
1852 commitsubs = set() |
1852 self.ui, wctx, status, match, force=force) |
1853 newstate = wctx.substate.copy() |
|
1854 # only manage subrepos and .hgsubstate if .hgsub is present |
|
1855 if '.hgsub' in wctx: |
|
1856 # we'll decide whether to track this ourselves, thanks |
|
1857 for c in status.modified, status.added, status.removed: |
|
1858 if '.hgsubstate' in c: |
|
1859 c.remove('.hgsubstate') |
|
1860 |
|
1861 # compare current state to last committed state |
|
1862 # build new substate based on last committed state |
|
1863 oldstate = wctx.p1().substate |
|
1864 for s in sorted(newstate.keys()): |
|
1865 if not match(s): |
|
1866 # ignore working copy, use old state if present |
|
1867 if s in oldstate: |
|
1868 newstate[s] = oldstate[s] |
|
1869 continue |
|
1870 if not force: |
|
1871 raise error.Abort( |
|
1872 _("commit with new subrepo %s excluded") % s) |
|
1873 dirtyreason = wctx.sub(s).dirtyreason(True) |
|
1874 if dirtyreason: |
|
1875 if not self.ui.configbool('ui', 'commitsubrepos'): |
|
1876 raise error.Abort(dirtyreason, |
|
1877 hint=_("use --subrepos for recursive commit")) |
|
1878 subs.append(s) |
|
1879 commitsubs.add(s) |
|
1880 else: |
|
1881 bs = wctx.sub(s).basestate() |
|
1882 newstate[s] = (newstate[s][0], bs, newstate[s][2]) |
|
1883 if oldstate.get(s, (None, None, None))[1] != bs: |
|
1884 subs.append(s) |
|
1885 |
|
1886 # check for removed subrepos |
|
1887 for p in wctx.parents(): |
|
1888 r = [s for s in p.substate if s not in newstate] |
|
1889 subs += [s for s in r if match(s)] |
|
1890 if subs: |
|
1891 if (not match('.hgsub') and |
|
1892 '.hgsub' in (wctx.modified() + wctx.added())): |
|
1893 raise error.Abort( |
|
1894 _("can't commit subrepos without .hgsub")) |
|
1895 status.modified.insert(0, '.hgsubstate') |
|
1896 |
|
1897 elif '.hgsub' in status.removed: |
|
1898 # clean up .hgsubstate when .hgsub is removed |
|
1899 if ('.hgsubstate' in wctx and |
|
1900 '.hgsubstate' not in (status.modified + status.added + |
|
1901 status.removed)): |
|
1902 status.removed.insert(0, '.hgsubstate') |
|
1903 |
1853 |
1904 # make sure all explicit patterns are matched |
1854 # make sure all explicit patterns are matched |
1905 if not force: |
1855 if not force: |
1906 self.checkcommitpatterns(wctx, vdirs, match, status, fail) |
1856 self.checkcommitpatterns(wctx, vdirs, match, status, fail) |
1907 |
1857 |