Mercurial > hg
changeset 275:61d45b0ba8fb
various merge improvements
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
various merge improvements
add -C flag: force update and overwrite local changes
add -m flag: allow merges with conflicts
we no longer do merge by default
and we print a warning message when the merge fails
fix bug in printing merge failure message
fix bug diffing files in 'm' state
manifest hash: 75545a6db45d1e371082343d01c9f177df0f9db3
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCpm6tywK+sNU5EO8RAvb+AJ0euC3YkUYA944hds3ooPxbw6NpVwCfc1dj
TiNsPIds560S5jgw44eWNto=
=GPXN
-----END PGP SIGNATURE-----
author | mpm@selenic.com |
---|---|
date | Tue, 07 Jun 2005 20:06:05 -0800 |
parents | 5da941efbb52 |
children | 10e325db7347 |
files | mercurial/commands.py mercurial/hg.py |
diffstat | 2 files changed, 33 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/commands.py Tue Jun 07 19:02:31 2005 -0800 +++ b/mercurial/commands.py Tue Jun 07 20:06:05 2005 -0800 @@ -57,7 +57,9 @@ c, a, d = map(lambda x: filterfiles(files, x), (c, a, d)) for f in c: - to = repo.file(f).read(mmap[f]) + to = None + if f in mmap: + to = repo.file(f).read(mmap[f]) tn = read(f) sys.stdout.write(mdiff.unidiff(to, date1, tn, date2, f)) for f in a: @@ -450,7 +452,7 @@ """undo the last transaction""" repo.undo() -def update(ui, repo, node=None): +def update(ui, repo, node=None, merge=False, clean=False): '''update or merge working directory If there are no outstanding changes in the working directory and @@ -464,7 +466,7 @@ are allowed. ''' node = node and repo.lookup(node) or repo.changelog.tip() - repo.update(node) + return repo.update(node, allow=merge, force=clean) def verify(ui, repo): """verify the integrity of the repository""" @@ -524,7 +526,12 @@ "tags": (tags, [], 'hg tags'), "tip": (tip, [], 'hg tip'), "undo": (undo, [], 'hg undo'), - "update|up|checkout|co|resolve": (update, [], 'hg update [node]'), + "update|up|checkout|co|resolve": (update, + [('m', 'merge', None, + 'allow merging of conflicts'), + ('C', 'clean', None, + 'overwrite locally modified files')], + 'hg update [options] [node]'), "verify": (verify, [], 'hg verify'), } @@ -599,6 +606,7 @@ tb = traceback.extract_tb(sys.exc_info()[2]) if len(tb) > 2: # no raise + raise u.warn("%s: invalid arguments\n" % i[0].__name__) u.warn("syntax: %s\n" % i[2]) sys.exit(-1)
--- a/mercurial/hg.py Tue Jun 07 19:02:31 2005 -0800 +++ b/mercurial/hg.py Tue Jun 07 20:06:05 2005 -0800 @@ -835,9 +835,9 @@ tr.close() return - def update(self, node): + def update(self, node, allow=False, force=False): pl = self.dirstate.parents() - if pl[1] != nullid: + if not force and pl[1] != nullid: self.ui.warn("aborting: outstanding uncommitted merges\n") return @@ -880,7 +880,7 @@ get[f] = m2[f] del m2[f] elif f in ma: - if n != ma[f]: + if not force and n != ma[f]: r = self.ui.prompt( (" local changed %s which remote deleted\n" % f) + "(k)eep or (d)elete?", "[kd]", "k") @@ -898,22 +898,34 @@ for f, n in m2.iteritems(): if f[0] == "/": continue - if f in ma and n != ma[f]: - r = self.ui.prompt( - ("remote changed %s which local deleted\n" % f) + - "(k)eep or (d)elete?", "[kd]", "k") - if r == "d": remove.append(f) + if not force and f in ma and n != ma[f]: + r = self.ui.prompt( + ("remote changed %s which local deleted\n" % f) + + "(k)eep or (d)elete?", "[kd]", "k") + if r == "d": remove.append(f) else: self.ui.debug("remote created %s\n" % f) get[f] = n del mw, m1, m2, ma + if force: + for f in merge: + get[f] = merge[f][1] + merge = {} + if not merge: # we don't need to do any magic, just jump to the new rev mode = 'n' p1, p2 = p2, nullid else: + if not allow: + self.ui.status("the following files conflict:\n") + for f in merge: + self.ui.status(" %s\n" % f) + self.ui.warn("aborting update due to conflicting files!\n") + self.ui.status("(use update -m to allow a merge)\n") + return 1 # we have to remember what files we needed to get/change # because any file that's different from either one of its # parents must be in the changeset @@ -976,7 +988,7 @@ cmd = os.environ.get("HGMERGE", "hgmerge") r = os.system("%s %s %s %s" % (cmd, a, b, c)) if r: - self.ui.warn("merging %s failed!\n" % f) + self.ui.warn("merging %s failed!\n" % fn) os.unlink(b) os.unlink(c)