Mercurial > public > mercurial-scm > hg
comparison mercurial/hg.py @ 588:0c3bae18403b
[PATCH] hg revert
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
[PATCH] hg revert
From: Bryan O'Sullivan <bos@serpentine.com>
Add revert command.
manifest hash: 0094e6bf421f34bd0492a33f95400b1b095a6bdc
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCx2BaywK+sNU5EO8RAigMAKCrvgTtIDuirCsMVlbiTMqaJy3UNgCdEcTL
hMN1X8FZi6sH+NjUdr9sYBg=
=i58L
-----END PGP SIGNATURE-----
author | mpm@selenic.com |
---|---|
date | Sat, 02 Jul 2005 19:49:46 -0800 |
parents | df8a5a0098d4 |
children | d2994b5298fb |
comparison
equal
deleted
inserted
replaced
587:62a7b679a9ca | 588:0c3bae18403b |
---|---|
1063 % (files, changesets, revisions)) | 1063 % (files, changesets, revisions)) |
1064 | 1064 |
1065 tr.close() | 1065 tr.close() |
1066 return | 1066 return |
1067 | 1067 |
1068 def update(self, node, allow=False, force=False): | 1068 def update(self, node, allow=False, force=False, choose=None, |
1069 moddirstate=True): | |
1069 pl = self.dirstate.parents() | 1070 pl = self.dirstate.parents() |
1070 if not force and pl[1] != nullid: | 1071 if not force and pl[1] != nullid: |
1071 self.ui.warn("aborting: outstanding uncommitted merges\n") | 1072 self.ui.warn("aborting: outstanding uncommitted merges\n") |
1072 return | 1073 return |
1073 | 1074 |
1115 # If we're jumping between revisions (as opposed to merging), | 1116 # If we're jumping between revisions (as opposed to merging), |
1116 # and if neither the working directory nor the target rev has | 1117 # and if neither the working directory nor the target rev has |
1117 # the file, then we need to remove it from the dirstate, to | 1118 # the file, then we need to remove it from the dirstate, to |
1118 # prevent the dirstate from listing the file when it is no | 1119 # prevent the dirstate from listing the file when it is no |
1119 # longer in the manifest. | 1120 # longer in the manifest. |
1120 if linear_path and f not in m2: | 1121 if moddirstate and linear_path and f not in m2: |
1121 self.dirstate.forget((f,)) | 1122 self.dirstate.forget((f,)) |
1122 | 1123 |
1123 # Compare manifests | 1124 # Compare manifests |
1124 for f, n in mw.iteritems(): | 1125 for f, n in mw.iteritems(): |
1126 if choose and not choose(f): continue | |
1125 if f in m2: | 1127 if f in m2: |
1126 s = 0 | 1128 s = 0 |
1127 | 1129 |
1128 # is the wfile new since m1, and match m2? | 1130 # is the wfile new since m1, and match m2? |
1129 if f not in m1: | 1131 if f not in m1: |
1192 self.ui.debug("local created %s, keeping\n" % f) | 1194 self.ui.debug("local created %s, keeping\n" % f) |
1193 else: | 1195 else: |
1194 self.ui.debug("working dir created %s, keeping\n" % f) | 1196 self.ui.debug("working dir created %s, keeping\n" % f) |
1195 | 1197 |
1196 for f, n in m2.iteritems(): | 1198 for f, n in m2.iteritems(): |
1199 if choose and not choose(f): continue | |
1197 if f[0] == "/": continue | 1200 if f[0] == "/": continue |
1198 if not force and f in ma and n != ma[f]: | 1201 if not force and f in ma and n != ma[f]: |
1199 r = "" | 1202 r = "" |
1200 if linear_path or allow: | 1203 if linear_path or allow: |
1201 r = self.ui.prompt( | 1204 r = self.ui.prompt( |
1232 return 1 | 1235 return 1 |
1233 # we have to remember what files we needed to get/change | 1236 # we have to remember what files we needed to get/change |
1234 # because any file that's different from either one of its | 1237 # because any file that's different from either one of its |
1235 # parents must be in the changeset | 1238 # parents must be in the changeset |
1236 mode = 'm' | 1239 mode = 'm' |
1237 self.dirstate.update(mark.keys(), "m") | 1240 if moddirstate: |
1238 | 1241 self.dirstate.update(mark.keys(), "m") |
1239 self.dirstate.setparents(p1, p2) | 1242 |
1243 if moddirstate: | |
1244 self.dirstate.setparents(p1, p2) | |
1240 | 1245 |
1241 # get the files we don't need to change | 1246 # get the files we don't need to change |
1242 files = get.keys() | 1247 files = get.keys() |
1243 files.sort() | 1248 files.sort() |
1244 for f in files: | 1249 for f in files: |
1249 self.wfile(f, "w").write(t) | 1254 self.wfile(f, "w").write(t) |
1250 except IOError: | 1255 except IOError: |
1251 os.makedirs(os.path.dirname(self.wjoin(f))) | 1256 os.makedirs(os.path.dirname(self.wjoin(f))) |
1252 self.wfile(f, "w").write(t) | 1257 self.wfile(f, "w").write(t) |
1253 util.set_exec(self.wjoin(f), mf2[f]) | 1258 util.set_exec(self.wjoin(f), mf2[f]) |
1254 self.dirstate.update([f], mode) | 1259 if moddirstate: |
1260 self.dirstate.update([f], mode) | |
1255 | 1261 |
1256 # merge the tricky bits | 1262 # merge the tricky bits |
1257 files = merge.keys() | 1263 files = merge.keys() |
1258 files.sort() | 1264 files.sort() |
1259 for f in files: | 1265 for f in files: |
1260 self.ui.status("merging %s\n" % f) | 1266 self.ui.status("merging %s\n" % f) |
1261 m, o, flag = merge[f] | 1267 m, o, flag = merge[f] |
1262 self.merge3(f, m, o) | 1268 self.merge3(f, m, o) |
1263 util.set_exec(self.wjoin(f), flag) | 1269 util.set_exec(self.wjoin(f), flag) |
1264 self.dirstate.update([f], 'm') | 1270 if moddirstate: |
1271 self.dirstate.update([f], 'm') | |
1265 | 1272 |
1266 for f in remove: | 1273 for f in remove: |
1267 self.ui.note("removing %s\n" % f) | 1274 self.ui.note("removing %s\n" % f) |
1268 os.unlink(f) | 1275 os.unlink(f) |
1269 # try removing directories that might now be empty | 1276 # try removing directories that might now be empty |
1270 try: os.removedirs(os.path.dirname(f)) | 1277 try: os.removedirs(os.path.dirname(f)) |
1271 except: pass | 1278 except: pass |
1272 if mode == 'n': | 1279 if moddirstate: |
1273 self.dirstate.forget(remove) | 1280 if mode == 'n': |
1274 else: | 1281 self.dirstate.forget(remove) |
1275 self.dirstate.update(remove, 'r') | 1282 else: |
1283 self.dirstate.update(remove, 'r') | |
1276 | 1284 |
1277 def merge3(self, fn, my, other): | 1285 def merge3(self, fn, my, other): |
1278 """perform a 3-way merge in the working directory""" | 1286 """perform a 3-way merge in the working directory""" |
1279 | 1287 |
1280 def temp(prefix, node): | 1288 def temp(prefix, node): |