Mercurial > hg
comparison mercurial/localrepo.py @ 35025:5c6b96b832c2 stable
subrepo: extract preprocess of repo.commit() to free function
No code change other than extracting a function. Maybe we should stop mutating
the status argument, but that's out of the scope of stable changes.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 04 Nov 2017 19:21:39 +0900 |
parents | 8c9b08a0c48c |
children | ee64e677c3cf |
comparison
equal
deleted
inserted
replaced
35024:3f909147a2c3 | 35025:5c6b96b832c2 |
---|---|
1843 status = self.status(match=match, clean=force) | 1843 status = self.status(match=match, clean=force) |
1844 if force: | 1844 if force: |
1845 status.modified.extend(status.clean) # mq may commit clean files | 1845 status.modified.extend(status.clean) # mq may commit clean files |
1846 | 1846 |
1847 # check subrepos | 1847 # check subrepos |
1848 subs = [] | 1848 subs, commitsubs, newstate = subrepo.precommit( |
1849 commitsubs = set() | 1849 self.ui, wctx, status, match, force=force) |
1850 newstate = wctx.substate.copy() | |
1851 # only manage subrepos and .hgsubstate if .hgsub is present | |
1852 if '.hgsub' in wctx: | |
1853 # we'll decide whether to track this ourselves, thanks | |
1854 for c in status.modified, status.added, status.removed: | |
1855 if '.hgsubstate' in c: | |
1856 c.remove('.hgsubstate') | |
1857 | |
1858 # compare current state to last committed state | |
1859 # build new substate based on last committed state | |
1860 oldstate = wctx.p1().substate | |
1861 for s in sorted(newstate.keys()): | |
1862 if not match(s): | |
1863 # ignore working copy, use old state if present | |
1864 if s in oldstate: | |
1865 newstate[s] = oldstate[s] | |
1866 continue | |
1867 if not force: | |
1868 raise error.Abort( | |
1869 _("commit with new subrepo %s excluded") % s) | |
1870 dirtyreason = wctx.sub(s).dirtyreason(True) | |
1871 if dirtyreason: | |
1872 if not self.ui.configbool('ui', 'commitsubrepos'): | |
1873 raise error.Abort(dirtyreason, | |
1874 hint=_("use --subrepos for recursive commit")) | |
1875 subs.append(s) | |
1876 commitsubs.add(s) | |
1877 else: | |
1878 bs = wctx.sub(s).basestate() | |
1879 newstate[s] = (newstate[s][0], bs, newstate[s][2]) | |
1880 if oldstate.get(s, (None, None, None))[1] != bs: | |
1881 subs.append(s) | |
1882 | |
1883 # check for removed subrepos | |
1884 for p in wctx.parents(): | |
1885 r = [s for s in p.substate if s not in newstate] | |
1886 subs += [s for s in r if match(s)] | |
1887 if subs: | |
1888 if (not match('.hgsub') and | |
1889 '.hgsub' in (wctx.modified() + wctx.added())): | |
1890 raise error.Abort( | |
1891 _("can't commit subrepos without .hgsub")) | |
1892 status.modified.insert(0, '.hgsubstate') | |
1893 | |
1894 elif '.hgsub' in status.removed: | |
1895 # clean up .hgsubstate when .hgsub is removed | |
1896 if ('.hgsubstate' in wctx and | |
1897 '.hgsubstate' not in (status.modified + status.added + | |
1898 status.removed)): | |
1899 status.removed.insert(0, '.hgsubstate') | |
1900 | 1850 |
1901 # make sure all explicit patterns are matched | 1851 # make sure all explicit patterns are matched |
1902 if not force: | 1852 if not force: |
1903 self.checkcommitpatterns(wctx, vdirs, match, status, fail) | 1853 self.checkcommitpatterns(wctx, vdirs, match, status, fail) |
1904 | 1854 |