Mercurial > hg-stable
changeset 2781:ae726521717c
merge with brendan.
author | Vadim Gelfer <vadim.gelfer@gmail.com> |
---|---|
date | Thu, 03 Aug 2006 11:12:02 -0700 |
parents | ee48e5ef8753 (current diff) 663094f5595b (diff) |
children | 0148869345f7 |
files | hgext/mq.py |
diffstat | 5 files changed, 91 insertions(+), 66 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/mq.py Thu Aug 03 11:09:12 2006 -0700 +++ b/hgext/mq.py Thu Aug 03 11:12:02 2006 -0700 @@ -67,7 +67,7 @@ if os.path.exists(os.path.join(self.path, self.series_path)): self.full_series = self.opener(self.series_path).read().splitlines() - self.read_series(self.full_series) + self.parse_series() if os.path.exists(os.path.join(self.path, self.status_path)): self.applied = [StatusEntry(l) @@ -86,34 +86,21 @@ index += 1 return None - def read_series(self, list): - def matcher(list): - pre = re.compile("(\s*)([^#]+)") - for l in list: - m = pre.match(l) - if m: - s = m.group(2) - s = s.rstrip() - if len(s) > 0: - yield s + def parse_series(self): self.series = [] - self.series = [ x for x in matcher(list) ] + for l in self.full_series: + s = l.split('#', 1)[0].strip() + if s: + self.series.append(s) def save_dirty(self): - if self.applied_dirty: - if len(self.applied) > 0: - nl = "\n" - else: - nl = "" - f = self.opener(self.status_path, "w") - f.write("\n".join([str(x) for x in self.applied]) + nl) - if self.series_dirty: - if len(self.full_series) > 0: - nl = "\n" - else: - nl = "" - f = self.opener(self.series_path, "w") - f.write("\n".join(self.full_series) + nl) + def write_list(items, path): + fp = self.opener(path, 'w') + for i in items: + print >> fp, i + fp.close() + if self.applied_dirty: write_list(map(str, self.applied), self.status_path) + if self.series_dirty: write_list(self.full_series, self.series_path) def readheaders(self, patch): def eatdiff(lines): @@ -406,7 +393,7 @@ os.unlink(os.path.join(self.path, patch)) i = self.find_series(patch) del self.full_series[i] - self.read_series(self.full_series) + self.parse_series() self.series_dirty = 1 def check_toppatch(self, repo): @@ -443,7 +430,7 @@ raise util.Abort(_("repo commit failed")) self.full_series[insert:insert] = [patch] self.applied.append(StatusEntry(revlog.hex(n), patch)) - self.read_series(self.full_series) + self.parse_series() self.series_dirty = 1 self.applied_dirty = 1 p = self.opener(patch, "w") @@ -941,10 +928,7 @@ start = self.series_end() else: start = self.series.index(patch) + 1 - for p in self.series[start:]: - if self.ui.verbose: - self.ui.write("%d " % self.series.index(p)) - self.ui.write("%s\n" % p) + return [(i, self.series[i]) for i in xrange(start, len(self.series))] def qseries(self, repo, missing=None, summary=False): start = self.series_end() @@ -1019,7 +1003,7 @@ self.ui.warn("restoring status: %s\n" % lines[0]) self.full_series = series self.applied = applied - self.read_series(self.full_series) + self.parse_series() self.series_dirty = 1 self.applied_dirty = 1 heads = repo.changelog.heads() @@ -1165,7 +1149,7 @@ % patch) index = self.full_series_end() + i self.full_series[index:index] = [patch] - self.read_series(self.full_series) + self.parse_series() self.ui.warn("adding %s to series file\n" % patch) i += 1 added.append(patch) @@ -1192,8 +1176,10 @@ def unapplied(ui, repo, patch=None, **opts): """print the patches not yet applied""" - repo.mq.unapplied(repo, patch) - return 0 + for i, p in repo.mq.unapplied(repo, patch): + if ui.verbose: + ui.write("%d " % i) + ui.write("%s\n" % p) def qimport(ui, repo, *filename, **opts): """import a patch""" @@ -1234,7 +1220,7 @@ Source patch repository is looked for in <src>/.hg/patches by default. Use -p <url> to change. ''' - commands.setremoteconfig(**opts) + commands.setremoteconfig(ui, opts) if dest is None: dest = hg.defaultdest(source) sr = hg.repository(ui, ui.expandpath(source)) @@ -1303,10 +1289,7 @@ -m or -l set the patch header as well as the commit message. If neither is specified, the patch header is empty and the - commit message is 'New patch: PATCH' - - If -f is specified, the patch will be initialized with any - uncommitted changes. Otherwise, if there outsta""" + commit message is 'New patch: PATCH'""" q = repo.mq message=commands.logmessage(**opts) q.new(repo, patch, msg=message, force=opts['force']) @@ -1336,7 +1319,13 @@ def fold(ui, repo, *files, **opts): """fold the named patches into the current patch - Patches must not yet be applied. + Patches must not yet be applied. Each patch will be successively + applied to the current patch in the order given. If all the + patches apply successfully, the current patch will be refreshed + with the new cumulative patch, and the folded patches will + be deleted. With -f/--force, the folded patch files will + be removed afterwards. + The header for each folded patch will be concatenated with the current patch header, separated by a line of '* * *'.""" @@ -1384,7 +1373,7 @@ q.refresh(repo, msg=message) for patch in patches: - q.delete(repo, patch) + q.delete(repo, patch, force=opts['force']) q.save_dirty() @@ -1493,7 +1482,7 @@ ui.write('Renaming %s to %s\n' % (patch, name)) i = q.find_series(patch) q.full_series[i] = name - q.read_series(q.full_series) + q.parse_series() q.series_dirty = 1 info = q.isapplied(patch) @@ -1617,6 +1606,7 @@ 'qfold': (fold, [('e', 'edit', None, _('edit patch header')), + ('f', 'force', None, _('delete folded patch files')), ('m', 'message', '', _('set patch header to <text>')), ('l', 'logfile', '', _('set patch header to contents of <file>'))], 'hg qfold [-e] [-m <text>] [-l <file] PATCH...'),
--- a/mercurial/hg.py Thu Aug 03 11:09:12 2006 -0700 +++ b/mercurial/hg.py Thu Aug 03 11:12:02 2006 -0700 @@ -13,7 +13,8 @@ demandload(globals(), "errno lock os shutil util") def _local(path): - return os.path.isfile(util.drop_scheme('file', path)) and bundlerepo or localrepo + return (os.path.isfile(path and util.drop_scheme('file', path)) and + bundlerepo or localrepo) schemes = { 'bundle': bundlerepo,
--- a/tests/test-backout.out Thu Aug 03 11:09:12 2006 -0700 +++ b/tests/test-backout.out Thu Aug 03 11:12:02 2006 -0700 @@ -27,7 +27,7 @@ reverting a changeset 3:4cbb1e70196a backs out changeset 1:22bca4c721e5 the backout changeset is a new head - do not forget to merge -(use "backout -m" if you want to auto-merge) +(use "backout --merge" if you want to auto-merge) b: No such file or directory adding a adding b
--- a/tests/test-import Thu Aug 03 11:09:12 2006 -0700 +++ b/tests/test-import Thu Aug 03 11:12:02 2006 -0700 @@ -1,7 +1,10 @@ #!/bin/sh hg init a +mkdir a/d1 +mkdir a/d1/d2 echo line 1 > a/a +echo line 1 > a/d1/d2/a hg --cwd a ci -d '0 0' -Ama echo line 2 >> a/a @@ -79,3 +82,19 @@ hg --cwd b tip | grep second rm -rf b +# bug non regression test +# importing a patch in a subdirectory failed at the commit stage +echo line 2 >> a/d1/d2/a +hg --cwd a ci -u someoneelse -d '1 0' -m'subdir change' +echo % hg import in a subdirectory +hg clone -r0 a b +hg --cwd a export tip | sed -e 's/d1\/d2\///' > tip.patch +pushd b/d1/d2 2>&1 > /dev/null +hg import ../../../tip.patch +popd 2>&1 > /dev/null +echo "% message should be 'subdir change'" +hg --cwd b tip | grep 'subdir change' +echo "% committer should be 'someoneelse'" +hg --cwd b tip | grep someoneelse +echo "% should be empty" +hg --cwd b status
--- a/tests/test-import.out Thu Aug 03 11:09:12 2006 -0700 +++ b/tests/test-import.out Thu Aug 03 11:12:02 2006 -0700 @@ -1,11 +1,12 @@ adding a +adding d1/d2/a % import exported patch requesting all changes adding changesets adding manifests adding file changes -added 1 changesets with 1 changes to 1 files -1 files updated, 0 files merged, 0 files removed, 0 files unresolved +added 1 changesets with 2 changes to 2 files +2 files updated, 0 files merged, 0 files removed, 0 files unresolved applying ../tip.patch patching file a % message should be same @@ -17,8 +18,8 @@ adding changesets adding manifests adding file changes -added 1 changesets with 1 changes to 1 files -1 files updated, 0 files merged, 0 files removed, 0 files unresolved +added 1 changesets with 2 changes to 2 files +2 files updated, 0 files merged, 0 files removed, 0 files unresolved applying ../tip.patch patching file a transaction abort! @@ -28,8 +29,8 @@ adding changesets adding manifests adding file changes -added 1 changesets with 1 changes to 1 files -1 files updated, 0 files merged, 0 files removed, 0 files unresolved +added 1 changesets with 2 changes to 2 files +2 files updated, 0 files merged, 0 files removed, 0 files unresolved applying ../tip.patch patching file a % import from stdin @@ -37,8 +38,8 @@ adding changesets adding manifests adding file changes -added 1 changesets with 1 changes to 1 files -1 files updated, 0 files merged, 0 files removed, 0 files unresolved +added 1 changesets with 2 changes to 2 files +2 files updated, 0 files merged, 0 files removed, 0 files unresolved applying patch from stdin patching file a % override commit message @@ -46,8 +47,8 @@ adding changesets adding manifests adding file changes -added 1 changesets with 1 changes to 1 files -1 files updated, 0 files merged, 0 files removed, 0 files unresolved +added 1 changesets with 2 changes to 2 files +2 files updated, 0 files merged, 0 files removed, 0 files unresolved applying patch from stdin patching file a summary: override @@ -56,8 +57,8 @@ adding changesets adding manifests adding file changes -added 1 changesets with 1 changes to 1 files -1 files updated, 0 files merged, 0 files removed, 0 files unresolved +added 1 changesets with 2 changes to 2 files +2 files updated, 0 files merged, 0 files removed, 0 files unresolved applying ../msg.patch patching file a user: email patcher @@ -67,8 +68,8 @@ adding changesets adding manifests adding file changes -added 1 changesets with 1 changes to 1 files -1 files updated, 0 files merged, 0 files removed, 0 files unresolved +added 1 changesets with 2 changes to 2 files +2 files updated, 0 files merged, 0 files removed, 0 files unresolved applying patch from stdin patching file a % plain diff in email, subject, no message body @@ -76,8 +77,8 @@ adding changesets adding manifests adding file changes -added 1 changesets with 1 changes to 1 files -1 files updated, 0 files merged, 0 files removed, 0 files unresolved +added 1 changesets with 2 changes to 2 files +2 files updated, 0 files merged, 0 files removed, 0 files unresolved applying patch from stdin patching file a % plain diff in email, no subject, no message body, should fail @@ -85,8 +86,8 @@ adding changesets adding manifests adding file changes -added 1 changesets with 1 changes to 1 files -1 files updated, 0 files merged, 0 files removed, 0 files unresolved +added 1 changesets with 2 changes to 2 files +2 files updated, 0 files merged, 0 files removed, 0 files unresolved applying patch from stdin patching file a transaction abort! @@ -96,8 +97,22 @@ adding changesets adding manifests adding file changes -added 1 changesets with 1 changes to 1 files -1 files updated, 0 files merged, 0 files removed, 0 files unresolved +added 1 changesets with 2 changes to 2 files +2 files updated, 0 files merged, 0 files removed, 0 files unresolved applying patch from stdin patching file a summary: second change +% hg import in a subdirectory +requesting all changes +adding changesets +adding manifests +adding file changes +added 1 changesets with 2 changes to 2 files +2 files updated, 0 files merged, 0 files removed, 0 files unresolved +applying ../../../tip.patch +patching file a +% message should be 'subdir change' +summary: subdir change +% committer should be 'someoneelse' +user: someoneelse +% should be empty